Transcribe audio locally with word timestamps
Use faster-whisper with word_timestamps and VAD, consume its segment generator, and preserve source-time offsets. Choose model size and compute type for your machine.
Use faster-whisper to transcribe an audio file on your machine, request word_timestamps=True, and enable voice activity detection with vad_filter=True. Consume the returned segment generator to perform transcription. Segment boundaries and word alignments are estimates; review them before using them for precise editing or quoting.
Set up a CPU baseline
Create an isolated environment and pin both faster-whisper and its audio decoder. faster-whisper 1.2.1 passes metadata_errors to PyAV; PyAV 19.0.2 rejects that argument. Use PyAV 18.1.0 with this sample:
python3 -m venv /tmp/whisper-example-env
/tmp/whisper-example-env/bin/pip install faster-whisper==1.2.1 av==18.1.0
The following uses the faster-whisper 1.2.1 WhisperModel.transcribe API in the official faster-whisper usage guide. Save it as transcribe.py, place your audio at audio.wav, and run /tmp/whisper-example-env/bin/python transcribe.py.
from faster_whisper import WhisperModel
model = WhisperModel("small", device="cpu", compute_type="int8")
segments, info = model.transcribe(
"audio.wav",
beam_size=5,
word_timestamps=True,
vad_filter=True,
vad_parameters={"min_silence_duration_ms": 500},
condition_on_previous_text=False,
)
print(f"language={info.language} probability={info.language_probability:.3f}")
for segment in segments:
print(f"[{segment.start:.3f} --> {segment.end:.3f}] {segment.text}")
for word in segment.words or []:
print(f" {word.start:.3f} {word.end:.3f} {word.word}")
small selects the multilingual model. Loading by model name downloads converted weights the first time, so prepare the model ahead of time for an offline machine. To avoid a download at runtime, replace the name with a directory containing a compatible CTranslate2 Whisper model and use local_files_only=True in WhisperModel.
The PyAV 18.1.0 audio API accepts the decoder argument used by faster-whisper 1.2.1. The library decodes audio through PyAV, which bundles FFmpeg libraries; this basic example does not require a separate ffmpeg command. The Python package and model files must still be installed before offline use.
Pick a model and device
| Starting point | When to try it | Trade-off |
|---|---|---|
tiny or base |
Fast CPU experiment | More recognition errors on difficult speech |
small |
Practical CPU baseline | More work than base, often better recognition |
medium or large-v3 |
Accuracy-focused transcription | Higher memory and compute requirements |
turbo |
Faster large-model-style transcription | Optimized for transcription; evaluate your language and audio |
English-only names such as small.en can suit English material. For CUDA, the documented pattern is device="cuda", compute_type="float16"; int8_float16 is another option on supported hardware. Check the installed CTranslate2 release’s CUDA/cuDNN requirements rather than copying library versions from an old tutorial.
Reduce silence hallucinations
Whisper can invent plausible text over music, silence or noise. VAD removes regions judged not to contain speech before decoding. The standard pipeline’s conservative default removes silence longer than two seconds; the 500 ms setting above is a more aggressive starting point. Short pauses, soft speech and distant speakers need care: overaggressive VAD can discard real words.
Disabling conditioning on previous text can reduce repeated-text loops, with a possible loss of continuity. If you know the language, pass language="en" or the appropriate code to avoid language-detection mistakes. Neither setting guarantees a clean transcript. Inspect empty clips, long pauses and repeated phrases, and compare questionable regions with the audio.
Word timestamps are mapped back to the original timeline after VAD; do not subtract removed silence again. If you manually split the recording into files, add each file’s original offset yourself. Keep diarization separate: word timestamps do not identify speakers.
Go deeper into timestamp alignment and streaming speech recognition.