Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Audio Transcription with Whisper

Transcribe audio files into text using OpenAI's Whisper speech recognition model.

Features

  • Automatic model selection based on available GPU VRAM
  • GPU acceleration (CUDA) with automatic CPU fallback
  • Language auto-detection for multilingual audio
  • Progress tracking with visual progress bar
  • Memory efficient segment-by-segment processing
  • Multiple audio formats supported (MP3, WAV, etc. via ffmpeg)

Requirements

Python Version

  • Recommended: Python 3.9.9 (Whisper was trained and tested with this version)
  • Supported: Python 3.8 - 3.11

Dependencies

pip install -r requirements.txt

Additional Requirements

  • ffmpeg: Required for audio file loading
    • Download from ffmpeg.org or
    • Windows: choco install ffmpeg or scoop install ffmpeg
    • Mac: brew install ffmpeg
    • Linux: [you know better]

Recommended

  • PyTorch: Version 1.10.1 (Whisper was tested with this version, but it also works with 2.8.0+cuda126)
  • CUDA-Version: Install via PyTorch Get Started
  • Audio file can be converted from mp4 file with (Windows):
    ffmpeg -i <video_filename>.mp4 -vn -acodec libmp3lame -q:a 0 <audoi_filename>.mp3

Usage

Basic Usage

python transcribe_audio.py --audio-file-path audio.mp3

Specify Model Size

python transcribe_audio.py --audio-file-path audio.mp3 --model-size medium

Custom Output Folder

python transcribe_audio.py --audio-file-path audio.mp3 --output-folder-path ./my_transcripts

Command Line Options

Option Description Default
--audio-file-path Path to the audio file to transcribe Required
--model-size Whisper model (tiny, base, small, medium, large, auto) auto
--output-folder-path Folder where transcription will be saved ./transcripts

Model Sizes

Model VRAM Required Relative Speed Accuracy
tiny ~1 GB Fastest Lowest
base ~1 GB Very Fast Low
small ~2 GB Fast Medium
medium ~5 GB Moderate High
large ~10 GB Slow Highest
auto N/A Auto-selected based on available VRAM Varies

How It Works

  1. Model Selection: Automatically selects the best Whisper model based on available GPU VRAM
  2. Audio Loading: Loads and resamples audio to 16kHz (Whisper's expected format)
  3. Language Detection: Detects the spoken language from the first 30 seconds
  4. Segmented Processing: Processes audio in 30-second segments for memory efficiency
  5. Transcription: Converts speech to text and saves to a .txt file

Output

  • Transcription saved as: <audio_filename>.txt
  • Located in the specified output folder (default: ./transcripts)
  • Format: Plain text with spaces between segments

Troubleshooting

"CUDA not available"

  • Script will automatically use CPU mode
  • Install CUDA-compatible PyTorch for GPU support:
    pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126

"ffmpeg not found"

  • Install ffmpeg and ensure it's in your system PATH
  • Verify: ffmpeg -version

Incomplete transcription

  • Check that your audio file is not corrupted
  • Try a smaller model size if running out of memory
  • Ensure audio file is in a supported format

License

This project uses OpenAI's Whisper model. Please refer to the Whisper repository for license information.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages