ShipOfTheseus
ShipOfTheseus

Reputation: 234

Speechsynthesizer (System.Speech.Synthesis.SpeechSynthesizer) - Changing the volume or rate at runtime

string TextToBeRead = "My sample text";
SpeechSynthesizer speaker = new SpeechSynthesizer();
speaker.Rate = 5;
speaker.Volume = 70;
speaker.SpeakAsync(TextToBeRead);

Is there any way to change the rate or volume, once the speaker starts talking? I have tried to change it at runtime but output still uses old rate and volume. Thanks.

Upvotes: 2

Views: 1514

Answers (2)

Eric Brown
Eric Brown

Reputation: 13932

You can do this inline using the SSML prosody element, and the rate and volume attributes.

You'll need to use the SpeakSsmlAsync method on SpeechSynthesizer to make this work.

Upvotes: 1

Guillaume
Guillaume

Reputation: 13138

No you can't change it while it's reading but you can subscribe to SpeakProgress event so you can get the CharacterPosition and restart speak with a new rate and volume at given position

Upvotes: 2

Related Questions