Fix Telnyx: enable bidirectional streaming so caller hears TTS audio - #8
Open
lucaspfingsten wants to merge 1 commit into
Open
Fix Telnyx: enable bidirectional streaming so caller hears TTS audio#8lucaspfingsten wants to merge 1 commit into
lucaspfingsten wants to merge 1 commit into
Conversation
The Telnyx `actions/answer` payload was sending only `stream_url` and `stream_track`, which opens an inbound-only media stream — Telnyx forwards caller audio to the WebSocket but silently drops anything the server sends back. The Deepgram Voice Agent's TTS frames are emitted but never reach the caller, so the call appears one-way. Setting `stream_bidirectional_mode: "rtp"` switches Telnyx into bidirectional mode, and `stream_bidirectional_codec: "PCMU"` aligns the outbound codec with what the existing `telnyx_media_websocket` receive loop already sends back (PCMU/8kHz, matching the inbound `BUFFER_SIZE` comment at line 532). Fixes deepgram#6.
lucaspfingsten
force-pushed
the
fix/telnyx-bidirectional-streaming
branch
from
April 29, 2026 21:16
191e838 to
cff1e71
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6.
The Telnyx
actions/answerpayload indeepclaw/voice_agent_server.pyonly setstream_urlandstream_track, which opens an inbound-only media stream. Telnyx forwards caller audio to the WebSocket but silently drops anything sent back, so Deepgram's TTS frames never reach the caller — the call appears one-way and the caller hears nothing.This adds the two fields needed to flip the stream into bidirectional mode:
PCMUmatches the codec the existingtelnyx_media_websocketreceive loop already assumes (see theBUFFER_SIZE = 20 * 160 # 0.4 seconds at 8kHz PCMUcomment).Test plan
mode: "rtp"is the right choice here vs.mode: "mp4". The existing receive code already sends audio back as base64mediaevents over the WebSocket, which works underrtpin my testing but is worth confirming against Telnyx's preferred path.Notes on scope
Kept the change minimal — only the two new fields plus a short comment explaining why they're required. Happy to extend with
stream_bidirectional_sampling_rate: 8000andstream_bidirectional_target_legs: "opposite"(both Telnyx defaults today, but defensive for future API changes) if reviewers prefer.