Provides a provider-agnostic protocol and events for real-time speech-to-speech voice sessions, supporting multiple backends including Qwen, Gemini, and OpenAI Realtime.
import Foundation
/// A provider-agnostic event from a real-time speech-to-speech session. Qwen,
/// Gemini Live, and OpenAI Realtime all map onto this, so the audio/UI layer
/// stays the same and providers are swappable.
public enum RealtimeVoiceEvent: Sendable {
case connected
case userTranscript(text: String, final: Bool) // what the user said
case assistantTranscript(text: String, final: Bool) // what the model says
case audioDelta(Data) // PCM 24 kHz mono 16-bit, to play
case speechStarted // server VAD: user started talking โ barge-in
case responseDone
case toolCall(name: String, arguments: String, callID: String) // model wants to run a function tool
case failed(String)
c
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key