Transcribe audio files into text using OpenAI's Whisper speech recognition model.
- 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)
- Recommended: Python 3.9.9 (Whisper was trained and tested with this version)
- Supported: Python 3.8 - 3.11
pip install -r requirements.txt- ffmpeg: Required for audio file loading
- Download from ffmpeg.org or
- Windows:
choco install ffmpegorscoop install ffmpeg - Mac:
brew install ffmpeg - Linux: [you know better]
- 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
python transcribe_audio.py --audio-file-path audio.mp3python transcribe_audio.py --audio-file-path audio.mp3 --model-size mediumpython transcribe_audio.py --audio-file-path audio.mp3 --output-folder-path ./my_transcripts| 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 | 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 |
- Model Selection: Automatically selects the best Whisper model based on available GPU VRAM
- Audio Loading: Loads and resamples audio to 16kHz (Whisper's expected format)
- Language Detection: Detects the spoken language from the first 30 seconds
- Segmented Processing: Processes audio in 30-second segments for memory efficiency
- Transcription: Converts speech to text and saves to a
.txtfile
- Transcription saved as:
<audio_filename>.txt - Located in the specified output folder (default:
./transcripts) - Format: Plain text with spaces between segments
- 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
- Install ffmpeg and ensure it's in your system PATH
- Verify:
ffmpeg -version
- 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
This project uses OpenAI's Whisper model. Please refer to the Whisper repository for license information.