load_align_model, then running align.
load_align_model
(model, metadata) tuple to pass directly to align().
Parameters
BCP-47 language code for the audio (e.g.
"en", "fr", "ja"). A default wav2vec2 model is selected automatically for 30+ languages including English, French, German, Spanish, Italian, Japanese, Chinese, Arabic, Hindi, and more.Override the default alignment model for the language. Pass any wav2vec2 model name from Hugging Face or a torchaudio pipeline name (e.g.
"WAV2VEC2_ASR_BASE_960H").Directory to cache downloaded alignment model files. Defaults to the Hugging Face cache directory.
When
True, load alignment models from local cache only — no network requests. Raises an error if the model is not already cached. Useful for offline environments.Returns
A tuple(model, metadata):
Dictionary with keys
"language", "dictionary", and "type". Pass this directly to align().Full signature
align
AlignedTranscriptionResult with per-word start and end times.
Parameters
The same audio used for transcription. A file path string, a 16 kHz mono float32 numpy array, or a PyTorch tensor. File paths are loaded automatically via
load_audio.PyTorch device for alignment inference (
"cpu" or "mps"). Should match the device used in load_align_model.When
True, each aligned segment includes a chars field with per-character timestamps in addition to word timestamps.Method used to fill in timestamps for words that could not be directly aligned.
"nearest" assigns the timestamp of the nearest aligned neighbor.Called with a float between
0.0 and 100.0 after each segment is processed. See ProgressCallback.Returns
AnAlignedTranscriptionResult TypedDict:
Aligned segments. Each segment contains a
words list with per-word timestamps.Flat list of all word segments across every aligned segment. Convenient for word-level iteration without nesting.
Full signature
Usage
When
task="translate" is used during transcription, the output text is in English but the audio is not — forced alignment cannot be performed on translated output. Skip alignment in this case.Related
MLXWhisperPipeline.transcribe
Produce the transcript that alignment operates on.
Diarization
Assign speaker labels to aligned segments.
Schema & Types
Full TypedDict definitions for AlignedTranscriptionResult.