feat(voice)!: migrate STT streaming to match GA Realtime API (#1759)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user