feat(voice)!: migrate STT streaming to match GA Realtime API (#1759)

This commit is contained in:
Shagun Bera
2025-09-17 10:23:41 +05:30
committed by GitHub
parent aeaf83f70f
commit ee751cb203
3 changed files with 13 additions and 7 deletions
+1
View File
@@ -22,6 +22,7 @@ class SpanError(TypedDict):
message: A human-readable error description
data: Optional dictionary containing additional error context
"""
message: str
data: dict[str, Any] | None
+9 -4
View File
@@ -163,11 +163,16 @@ class OpenAISTTTranscriptionSession(StreamedTranscriptionSession):
await self._websocket.send(
json.dumps(
{
"type": "transcription_session.update",
"type": "session.update",
"session": {
"input_audio_format": "pcm16",
"input_audio_transcription": {"model": self._model},
"turn_detection": self._turn_detection,
"type": "transcription",
"audio": {
"input": {
"format": {"type": "audio/pcm", "rate": 24000},
"transcription": {"model": self._model},
"turn_detection": self._turn_detection,
}
},
},
}
)
+3 -3
View File
@@ -115,10 +115,10 @@ async def test_session_connects_and_configures_successfully():
assert headers.get("OpenAI-Beta") is None
assert headers.get("OpenAI-Log-Session") == "1"
# Check that we sent a 'transcription_session.update' message
# Check that we sent a 'session.update' message
sent_messages = [call.args[0] for call in mock_ws.send.call_args_list]
assert any('"type": "transcription_session.update"' in msg for msg in sent_messages), (
f"Expected 'transcription_session.update' in {sent_messages}"
assert any('"type": "session.update"' in msg for msg in sent_messages), (
f"Expected 'session.update' in {sent_messages}"
)
await session.close()