ai-call-agent icon indicating copy to clipboard operation
ai-call-agent copied to clipboard

Call speach does not work due to Turn detection not being set

Open tropxy opened this issue 8 months ago • 1 comments

In the code here:

async def send_session_update(openai_ws):
    """Send session update to OpenAI WebSocket."""
    session_update = {
        "type": "session.update",
        "session": {
            "input_audio_format": "g711_ulaw",
            "output_audio_format": "g711_ulaw",
            "voice": VOICE,
            "instructions": SYSTEM_MESSAGE,
            "modalities": ["text", "audio"],
            "temperature": 0.8,
        },
    }
    print('Sending session update:', json.dumps(session_update))
    await openai_ws.send(json.dumps(session_update))

the setting "turn_detection": {"type": "server_vad"}, is not present and therefore no conversation can be made.

The final code shall be:

async def send_session_update(openai_ws):
    """Send session update to OpenAI WebSocket."""
    session_update = {
        "type": "session.update",
        "session": {
            "turn_detection": {"type": "server_vad"},
            "input_audio_format": "g711_ulaw",
            "output_audio_format": "g711_ulaw",
            "voice": VOICE,
            "instructions": SYSTEM_MESSAGE,
            "modalities": ["text", "audio"],
            "temperature": 0.8,
        }
    }
    print('Sending session update:', json.dumps(session_update))
    await openai_ws.send(json.dumps(session_update))

tropxy avatar Apr 05 '25 15:04 tropxy

@tropxy thanks for sharing this, will update after test.

rehan-dev avatar Apr 14 '25 10:04 rehan-dev