Repository navigation
Let a cascaded realtime deployment be given a speaking speed and style - #282
Merged
Merged
Conversation
A cascade spoke at its speaking leg's default pace, which callers found slow with gpt-4o-mini-tts, and nothing could change it. - CascadedRealtimeMetadata.SpeechSpeed and SpeakingStyle reach the speaking leg with every fragment, as TextToSpeechOptions.Speed and the new TextToSpeechOptionsProperties.Instructions additional property. - The OpenAI provider sends the style as the model's instructions (not to tts-1 or tts-1-hd) and keeps the speed within 0.25 to 4. - Azure Speech honors TextToSpeechOptions.Speed as SSML prosody rate. - A cascaded session supports the listener's speed control, on top of the configured pace, from the next sentence spoken. Fixes #273
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.
Fixes #273
A cascaded realtime deployment spoke at its speaking leg's default pace and nothing could change it. With
gpt-4o-mini-tts, callers found that pace slow. This follows the issue's proposal; the default pace lives on the cascade's metadata.Changes
CascadedRealtimeMetadatagets two optional settings:SpeechSpeed: the cascade's pace, as a multiple of the speaking leg's normal pace (1.2is 20% faster).SpeakingStyle: how to speak, in words ("Speak at a brisk, natural phone pace…").CascadedRealtimeClientpasses both with every fragment: the speed asTextToSpeechOptions.Speed, and the style as the newTextToSpeechOptionsProperties.Instructionsadditional property, sinceTextToSpeechOptionshas no field for it.DefaultAIClientFactorysets them from the metadata.DefaultRealtimeOrchestratorno longer turnsSupportsSpeechSpeedoff for a cascade.DefaultRealtimeConversation.UpdateSpeechSpeedAsynchands the speed to the cascaded session instead of sending asession.updateto its transcription leg.1.2, a listener's 1.25× speaks at 1.5.OpenAITextToSpeechStyleClient, wrapped inside the existing format client):instructions, through the SDK'sSpeechGenerationOptions(RawRepresentationFactory). It is left out fortts-1andtts-1-hd, which take no instructions.TextToSpeechOptions.Speed, which it ignored before. A speed other than 1 is spoken as SSML withprosody rate, clamped to the 0.5 to 2 Azure accepts. The voice is named in its own locale, and the text is XML-escaped. Without a voice to name, the plain-text path is kept. Azure has no free-text style, soSpeakingStyledoes not apply to it.core/realtime-voice.md: a "Pace and speaking style" section, and the speaking-speed control on a cascade.providers/openai.md: speed and instructions.Tests
CascadedRealtimeSessionTests:DefaultRealtimeConversationmultiplies the configured pace (4 cases) and sends nothing to the transcription leg.OpenAITextToSpeechTests: through a loopback stand-in for OpenAI, the request carriesspeed(clamped to 0.25 and 4) andinstructionsforgpt-4o-mini-tts, but noinstructionsfortts-1andtts-1-hd.AzureSpeechServiceSpeedTests: the SSML'sprosody rate(including clamping), the voice and locale, escaping, and when the plain text is kept.Verified live
en-US-JennyNeural, raw PCM at 24 kHz. One sentence took 7.15 s at the normal pace, 5.50 s at 1.3× and 8.94 s at 0.8×, which match 7.15/1.3 and 7.15/0.8 exactly. Streamed and single-shot synthesis gave the same result.Note
providers/openai.mdandOpenAIClientProviderare next to lines that #281 (OpenAI PCM resampling for #279) also changes. Whichever merges second may need a small rebase.🤖 Generated with Claude Code