Audio Transcription Scripts
This repository contains Python scripts for transcribing audio files to text using various methods.
Features
- Support for multiple audio formats (MP3, WAV, M4A, FLAC, etc.)
- Multiple transcription engines (OpenAI Whisper, Google Speech Recognition)
- Various output formats (TXT, SRT, VTT)
- Command-line interface
- Simple and advanced versions
Installation
- Clone this repository:
git clone <repository-url>
cd transcribe-audio-to-text
- Install Python dependencies:
pip install -r requirements.txt
- Install FFmpeg (required for audio processing):
Usage
Simple Transcription (simple_transcribe.py)
Basic usage for quick transcriptions:
python simple_transcribe.py audio_file.mp3
This will create a text file with the transcription.
Advanced Transcription (transcribe_audio.py)
Full-featured script with more options:
# Basic usage
python transcribe_audio.py audio_file.mp3
# Specify output file
python transcribe_audio.py audio_file.mp3 -o transcript.txt
# Use different Whisper model (tiny, base, small, medium, large)
python transcribe_audio.py audio_file.mp3 -m large
# Output as subtitle file (SRT format)
python transcribe_audio.py audio_file.mp3 -f srt
# Use Google Speech Recognition (requires internet)
python transcribe_audio.py audio_file.mp3 --method google
Command Line Options
-o, --output: Specify output file path
-m, --model: Choose Whisper model size (tiny, base, small, medium, large)
-f, --format: Output format (txt, srt, vtt)
--method: Transcription method (whisper, google)
Supported Audio Formats
- MP3
- WAV
- M4A
- FLAC
- AAC
- OGG
- WMA
Transcription Methods
OpenAI Whisper (Recommended)
- Works offline
- High accuracy
- Multiple model sizes available
- Supports 99 languages
Google Speech Recognition
- Requires internet connection
- Good accuracy for English
- Free tier available
Model Size Comparison
| Model | Size | Speed | Accuracy | Use Case |
|---|
| tiny | 39MB | Fastest | Good | Quick drafts |
| base | 142MB | Fast | Better | General use |
| small | 244MB | Medium | Good | Balanced |
| medium | 769MB | Slow | Better | High quality |
| large | 1550MB | Slowest | Best | Maximum accuracy |
Examples
Transcribe a podcast episode:
python transcribe_audio.py podcast_episode.mp3 -m medium -o podcast_transcript.txt
Create subtitles for a video:
python transcribe_audio.py video_audio.wav -f srt -o subtitles.srt
Quick transcription of a voice memo:
python simple_transcribe.py voice_memo.m4a
Tips for Best Results
- Audio Quality: Use clear, high-quality audio for better transcription
- Model Selection: Use larger models for better accuracy, smaller for speed
- File Size: Large files may take significant time to process
- Language: Whisper auto-detects language but works best with English
- Background Noise: Minimize background noise for better results
Troubleshooting
Common Issues:
- FFmpeg not found: Install FFmpeg and ensure it's in your system PATH
- Memory errors: Use smaller Whisper models or process shorter audio segments
- Slow processing: Use smaller models or ensure you have adequate hardware
Error Messages:
File not found: Check the audio file path
Unsupported format: Convert to a supported format first
Model loading failed: Check internet connection for first-time model download
License
This project is open source and available under the MIT License.