Repository navigation
Conversation
With Say on, the reconnect prompt and the hang-up and transfer lines of a realtime call were spoken with Say, while the model speaks with its own voice, so the caller heard two voices in one call. - AppendSpeech(preferRecording) plays a prerecorded prompt as recorded even when its text is configured in PromptTexts. The prompts queued before the realtime stream and the prompt of a stream reconnect use it. - SaveSpeechAsync(preferAudio) synthesizes the mp3 even when Say is on. The hang-up and transfer functions ask for it when their agent has the realtime label (TwilioService.IsRealtimeAgentAsync). Calls that are not realtime behave as before. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
PR Summary by QodoPlay recorded prompts and synthesized speech on realtime Twilio calls
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
There was a problem hiding this comment.
🟡 Changes recommended
Transfer and hang-up messages can still use Say during an active realtime call because audio preference is derived from the current agent’s label rather than the active call/session mode.
1 open issue
What changed in this PR
This PR updates Twilio speech handling to avoid switching to Twilio Say for prompts and closing messages during realtime calls.
Changes:
- Prefer recordings for prompts before realtime streams and during reconnects.
- Allow speech synthesis even when
SayGeneratedSpeechis enabled. - Use the current agent’s realtime label to request synthesized hang-up and transfer messages.
| File | Description |
|---|---|
src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioService.cs |
Adds audio preferences and realtime-agent detection. |
src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/TransferPhoneCallFn.cs |
Requests audio for realtime-agent transfer messages. |
src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/HangupPhoneCallFn.cs |
Requests audio for realtime-agent ending messages. |
src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioReconnectController.cs |
Prefers recordings for reconnect prompts. |
Review effort: Balanced
The hang-up and transfer lines asked for a recording when the current agent carried the realtime label. After a routing to an agent without the label the stream stays, but the lines were spoken with Say again. TwilioInboundController records the mode once, by the label of the agent that took the call, as the call state twilio_realtime_call. TwilioService.IsRealtimeCall reads it, so the routing no longer matters and no agent has to be looked up. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
TwilioInboundController wrote twilio_realtime_call only for a realtime agent and never cleared it, so a conversation later served by an agent without the label kept reading as realtime. It is now written as true or false on each call. Also puts back two trailing spaces in ReturnBidirectionalMediaStreamsInstructions that an earlier commit of this branch removed, so the diff holds no whitespace-only lines. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
reviewed |

With Say on, the reconnect prompt and the hang-up and transfer lines of a realtime call were spoken with Say, while the model speaks with its own voice, so the caller heard two voices in one call.
Calls that are not realtime behave as before.