Skip to content

Commit 429fbfa

Browse files
authored
Add traffictype in speech tts requests. (#1431)
* add traffic log to local mcp * fix SR live tests
1 parent 4a0986c commit 429fbfa

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

tools/Azure.Mcp.Tools.Speech/src/Services/Synthesizers/RealtimeTtsSynthesizer.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,13 @@ public async Task<SynthesisResult> SynthesizeToFileAsync(
105105
var tokenRequestContext = new TokenRequestContext(["https://cognitiveservices.azure.com/.default"]);
106106
var accessToken = await credential.GetTokenAsync(tokenRequestContext, cancellationToken);
107107

108+
// Convert https endpoint to wss for WebSocket-based TTS
109+
var wssEndpoint = endpoint
110+
.Replace("https://", "wss://", StringComparison.OrdinalIgnoreCase)
111+
.TrimEnd('/') + "/tts/cognitiveservices/websocket/v1?traffictype=localmcp";
112+
108113
// Configure Speech SDK with endpoint
109-
var config = SpeechConfig.FromEndpoint(new Uri(endpoint));
114+
var config = SpeechConfig.FromEndpoint(new Uri(wssEndpoint));
110115

111116
// Set the authorization token
112117
config.AuthorizationToken = accessToken.Token;

tools/Azure.Mcp.Tools.Speech/src/SpeechSetup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public CommandGroup RegisterCommands(IServiceProvider serviceProvider)
4040
var speech = new CommandGroup(Name,
4141
"""
4242
Speech operations - Commands for Azure AI Services Speech functionality including speech-to-text (STT)
43-
recognition, audio processing, and language detection. Use this tool when you need to convert spoken
44-
audio to text, process audio files, or work with speech recognition services. This tool supports
43+
recognition, text-to-speech (TTS) synthesis, audio processing, and language detection. Use this tool when you need to convert spoken
44+
audio to text, convert text to spoken audio, process audio files, or work with speech recognition services. This tool supports
4545
multiple audio formats, configurable recognition languages, profanity filtering options, and both
4646
simple and detailed output formats. This tool is a hierarchical MCP command router where sub-commands
4747
are routed to MCP servers that require specific fields inside the "parameters" object. To invoke a

tools/Azure.Mcp.Tools.Speech/tests/Azure.Mcp.Tools.Speech.LiveTests/SpeechCommandTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public async Task SpeechToText_ShouldHandleMissingAudioFileGracefully()
4040
[InlineData("en-US", "TheGreatGatsby.wav", "In my younger and more vulnerable years, my father gave me some advice that I've been turning over in my mind ever since. Whenever you feel like criticizing anyone, he told me, just remember that all the people in this world haven't had the advantages that you've had. He didn't say anymore, but we've always been unusually commutative in a reserved way, and I understood that he meant a great deal more than that. In consequence, I'm inclined to reserve all judgments, a habit that has opened up many curious natures to me.")]
4141
[InlineData("ar-AE", "ar-rewind-music.wav", "ارجع الموسيقى 20 ثانية.")]
4242
[InlineData("es-ES", "es-ES.wav", "Rebobinar la música 20 segundos.")]
43-
[InlineData("fr-FR", "fr-FR.wav", "Rembobinez la musique de Vingt secondes.")]
44-
[InlineData("de-DE", "de-DE.wav", "Treffen heute um 17 Uhr.")]
43+
[InlineData("fr-FR", "fr-FR.wav", "Rembobinez la musique de vingt secondes.")]
44+
[InlineData("de-DE", "de-DE.wav", "Treffen heute um 17 Uhr")]
4545
public async Task SpeechToText_WithFastSupportedLanguage_ShouldRecognizeSpeechWithFastTranscription(string? language, string fileName, string expectedText)
4646
{
4747
// Arrange

0 commit comments

Comments
 (0)