Skip to main content
transcribeStream consumes an AsyncStream<Data> of PCM chunks and yields partial results as the native session decodes them. Segmentation and endpointing happen inside the SDK, so the app just pumps microphone audio in.

Basic usage

Method signature

The call is neither async nor throws: it returns immediately. Failures arrive as a terminal RASTTPartialResult with isFinal == true and the failure text in text, prefixed "STT stream failed". Each element of audio must be Data holding PCM samples at 16 kHz mono.

RASTTPartialResult

Live transcription

SwiftUI integration

Voice command detection

Act on non-final partials so a command fires without waiting for the utterance to close.

Options

transcribeStream takes the same RASTTOptions as transcribe. Two fields matter most here:

Performance tips

Yield microphone buffers as they arrive rather than accumulating seconds of audio. The native session handles buffering.
Always call continuation.finish() when the session ends. An unfinished stream keeps the native session and its buffers alive.
Decoding runs off the main thread. Hop back to the main actor before touching view state.

Error handling

There is nothing to catch. Errors surface in-band as a terminal partial.
The stream also finishes silently without yielding anything when the SDK is not initialized or no model is loaded under .speechRecognition. Check currentModel(_:) before starting a session.

Basic Transcription

Non-streaming transcription

STT Options

Configure transcription