OpenAI Whisper Beginner
Whisper is OpenAI's open-source speech recognition model. Trained on 680,000 hours of multilingual data, it delivers near-human accuracy across 99 languages. You can run it locally for free or use the OpenAI API for production workloads.
Installing Whisper Locally
Whisper can be installed via pip. It requires Python 3.8+ and ffmpeg for audio processing.
# Install Whisper and its dependencies pip install openai-whisper # Install ffmpeg (macOS) brew install ffmpeg # Install ffmpeg (Ubuntu/Debian) sudo apt install ffmpeg # For faster inference, install faster-whisper pip install faster-whisper
Whisper Model Sizes
Whisper comes in several model sizes. Larger models are more accurate but slower and require more VRAM:
| Model | Parameters | VRAM | Relative Speed | Best For |
|---|---|---|---|---|
| tiny | 39M | ~1 GB | ~10x | Quick testing, low-resource devices |
| base | 74M | ~1 GB | ~7x | Simple transcription tasks |
| small | 244M | ~2 GB | ~4x | Good balance of speed and accuracy |
| medium | 769M | ~5 GB | ~2x | High accuracy for most use cases |
| large-v3 | 1550M | ~10 GB | 1x | Maximum accuracy, multilingual |
Basic Transcription with Python
import whisper # Load the model (downloads on first use) model = whisper.load_model("base") # Transcribe an audio file result = model.transcribe("meeting.mp3") # Print the full transcript print(result["text"]) # Access word-level timestamps for segment in result["segments"]: print(f"[{segment['start']:.1f}s - {segment['end']:.1f}s] {segment['text']}")
Using the Whisper CLI
Whisper also includes a command-line interface for quick transcription:
# Basic transcription whisper audio.mp3 --model base # Specify language and output format whisper audio.mp3 --model medium --language en --output_format srt # Translate non-English audio to English whisper french_audio.mp3 --model large --task translate
Using the OpenAI Whisper API
For production use, the OpenAI API provides a hosted Whisper endpoint with fast response times and no GPU requirement on your end:
from openai import OpenAI client = OpenAI() # Transcribe audio via API with open("meeting.mp3", "rb") as audio_file: transcript = client.audio.transcriptions.create( model="whisper-1", file=audio_file, response_format="verbose_json", timestamp_granularities=["word"] ) print(transcript.text) # Access word-level timestamps for word in transcript.words: print(f"[{word.start:.2f}s] {word.word}")
Faster Whisper
Faster Whisper uses CTranslate2 for up to 4x faster inference with the same accuracy:
from faster_whisper import WhisperModel # Load model with int8 quantization for speed model = WhisperModel("large-v3", compute_type="int8") segments, info = model.transcribe("audio.mp3", beam_size=5) print(f"Detected language: {info.language} ({info.language_probability:.0%})") for segment in segments: print(f"[{segment.start:.2f}s -> {segment.end:.2f}s] {segment.text}")
int8 quantization on the large-v3 model gives you the best accuracy-to-speed ratio. It runs well on a GPU with 6+ GB VRAM or even on CPU for shorter audio files.
Try It Yourself
Install Whisper, download a sample audio file, and transcribe it using both the local model and the CLI. Experiment with different model sizes to see the accuracy-speed tradeoff.
Next: Cloud APIs →Ready to Go Deeper?
Live instructor-led courses from our partners. Affiliate disclosure.
AI & ML Courses - 30% Off
Live instructor-led AI, machine learning, data science, and cloud courses for working professionals. Use code Limited30 at checkout.
EdurekaDataCamp - AI & Data Science
Hands-on Python, machine learning, and AI courses with interactive exercises and real projects.
DataCampedX - Top AI Courses
University-level AI courses from MIT, Harvard, Stanford. Earn certificates that employers recognize.
edX