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,516 questions
Azure
Azure
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
1,068 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,574 questions
{count} votes