SpeechSynthesizer sometimes plays speech depending on SpeechSynthesisOutputFormat

One More Henry 20 Reputation points
2024-07-03T14:10:30.4733333+00:00

In a C# WPF application, I call this function to convert text to speech:

SpeechSynthesisResult speechSynthesisResult = await speechSynthesizer.SpeakSsmlAsync(strSsml);

The audio data is returned ok. BUT the function also sometimes plays the speech as well through my sound device, depending on which output format is selected.

Raw24Khz16BitMonoPcm <- Automatically plays the speech audio.

Audio24Khz160KBitRateMonoMp3 <- Does not play the speech audio.

I need the automatic speech out to stop, but I also need the audio data in WAV file format.

My configuration looks like this:

`SpeechConfig speechConfig = SpeechConfig.FromSubscription(SubscriptionKey, SubscriptionRegion);`

speechConfig.OutputFormat = OutputFormat.Detailed;

speechConfig.SetSpeechSynthesisOutputFormat(Raw24Khz16BitMonoPcm);

speechConfig.SpeechSynthesisVoiceName = "en-GB-LibbyNeural";

speechConfig.SetProperty(PropertyId.Speech_LogFilename, "[FILE ON MY HARD DISK]");

Thanks for reading.

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,777 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.