Skip to main content
RunAnywhere.voice assembles speech-to-text, a language model, and text-to-speech into one session that listens, thinks, and answers out loud. It owns the microphone while it runs.

Signature

Leaving vad unset ensures the catalogued default Silero VAD. downloadIfNeeded defaults to true, so any of the three models that is missing is fetched first.

VoiceSession

say speaks a line without waiting for the user, which is how you greet someone. interrupt cuts off whatever is being spoken. Always close() the session. It holds the microphone.

Turn handling

Raise interruption.minDurationMs in a noisy room, or a cough will cut the model off.

Steering the replies

Spoken replies want to be short. A model that writes four paragraphs is unbearable to listen to, so cap maxOutputTokens lower than you would for a chat interface.

A complete session

Microphone permission

Add NSMicrophoneUsageDescription to your Info.plist. The session cannot start without it.

Diarization

To answer “who spoke when” over a recording rather than run a live conversation, use the diarization namespace:
It also streams: