Repository navigation
Smart turn detection for realtime
client.realtime.connect(turn_detection="smart") tells a voice agent when the user starts speaking, stops, and has finished their turn. The session then yields three new event types alongside RealtimeTranscript:
RealtimeSpeechStarted—speech.started, ~100 ms after the user starts talking (interrupt the agent).RealtimeSpeechEnded—speech.ended, ~280 ms after silence; not necessarily the end of the turn.RealtimeTurnEnd—turn.end, the turn's completetextandwords, withconfidence(>= 0.5model decided,< 0.53 s silence limit,Noneclosed byfinish()). Arrives after every transcript of its turn and before any of the next.
Every RealtimeTranscript gains turn: int | None. Works with any delay_ms, diarize and multichannel (turns are counted per channel).
Typing
RealtimeSession is now generic in its event type. connect() is overloaded: without turn_detection iteration still yields RealtimeTranscript, so existing typed code is unaffected; with turn_detection="smart" it yields the RealtimeEvent union — narrow on event.type.
New exports: RealtimeEvent, RealtimeSpeechStarted, RealtimeSpeechEnded, RealtimeTurnEnd, RealtimeTurnDetection.