Command-Line Usage
Basic Transcription
The simplest way to use Whisper is via the command line. Theturbo model is used by default for optimal speed and accuracy:
Transcribing Non-English Audio
To transcribe audio in a specific language, use the--language parameter:
Translating to English
Whisper can translate speech from any supported language directly into English:Common CLI Options
Python API
Basic Transcription
Transcribe audio files programmatically using Whisper’s Python API:The
transcribe() method reads the entire file and processes the audio with a sliding 30-second window, performing autoregressive sequence-to-sequence predictions on each window.Choosing a Model
Select different models based on your speed and accuracy requirements:Checking Available Models
Advanced Usage: Language Detection and Decoding
For lower-level access to the model, usedetect_language() and decode():
Device Selection
By default, Whisper uses CUDA if available, otherwise CPU. You can specify the device explicitly:Complete Examples
1
Transcribe a Podcast Episode
2
Translate Foreign Language Audio
3
Batch Process Multiple Files
Output Format
Thetranscribe() method returns a dictionary containing:
text: The full transcribed textsegments: List of segments with timestampslanguage: Detected or specified language
Performance Tips
Choose the Right Model
Use
turbo for the best balance of speed and accuracy. Use tiny or base for real-time applications.Use GPU Acceleration
Ensure PyTorch is installed with CUDA support for 10-20x faster transcription on NVIDIA GPUs.
Batch Processing
Load the model once and reuse it for multiple files to avoid repeated model loading overhead.
English-only Models
Use
.en models (e.g., base.en) for better accuracy when transcribing English-only content.Next Steps
Explore Advanced Features
Learn about word-level timestamps, language detection, and custom decoding options
View All Languages
Check the tokenizer.py file for the complete list of 99+ supported languages