Audio Transcription
WhisperKit provides flexible APIs for transcribing audio from files, arrays, or live input. All transcription methods returnTranscriptionResult objects containing the recognized text and detailed metadata.
Basic Transcription
Transcribe from File Path
The simplest way to transcribe audio:Transcribe from Audio Array
For pre-loaded audio samples:Decoding Options
Customize transcription behavior withDecodingOptions:
Key DecodingOptions Parameters
DecodingTask
default:".transcribe"
.transcribe- Transcribe audio in its original language.translate- Translate to English
String?
default:"nil"
Language code (e.g., “en”, “es”, “fr”). If nil, language is auto-detected for multilingual models.
Float
default:"0.0"
Sampling temperature. 0.0 uses greedy decoding (most accurate), higher values increase randomness.
Bool
default:"false"
Enable word-level timestamps in the output.
Bool
default:"false"
Disable all timestamps (faster decoding).
Float?
default:"2.4"
If text compression ratio exceeds this, mark as failed (indicates repetition/hallucination).
Float?
default:"-1.0"
If average log probability is below this, mark as failed (low confidence).
Int
default:"16 (macOS) / 4 (iOS)"
Number of concurrent workers for parallel transcription of multiple audio files.
Batch Transcription
Transcribe Multiple Files
Using Results for Error Handling
TranscriptionResult Structure
Each transcription returns aTranscriptionResult with:
TranscriptionSegment Properties
id: Int- Segment identifierseek: Int- Seek position in audio samplesstart: Float- Start time in secondsend: Float- End time in secondstext: String- Transcribed texttokens: [Int]- Token IDswords: [WordTiming]?- Word-level timestamps (if enabled)
Language Detection
Detect the language of an audio file:Language detection only works with multilingual models. English-only models (tiny.en, base.en, etc.) will throw an error.
Progress Tracking
Monitor transcription progress with a callback:TranscriptionProgress Properties
windowId: Int- Current audio window being processedtext: String- Current decoded texttokens: [Int]- Generated tokensavgLogprob: Float?- Average log probabilitytimings: TranscriptionTimings- Performance metrics
Advanced Features
Clip Timestamps
Transcribe specific time segments:Prompt Tokens
Provide context to improve accuracy:Temperature Fallback
Automatically retry with higher temperature on failure:Best Practices
Audio Format
WhisperKit expects 16kHz mono audio. Use
AudioProcessor.loadAudio() to convert formats automatically.Model Selection
Use smaller models (tiny, base) for real-time needs and larger models (medium, large) for accuracy.
Error Handling
Use
transcribeWithResults() for robust error handling when processing multiple files.Memory Management
Unload models when not in use:
await whisperKit.unloadModels()Next Steps
Streaming
Learn real-time transcription
Voice Activity Detection
Optimize with VAD