Summary of SAPI usage in c how to use SpVoice
- 2020-05-07 20:16:54
- OfStack
To use SAPI, first add a reference to DotNetSpeech, download DotNetSpeech.dll yourself.
Initialization object, SpVoice voice = new DotNetSpeech.SpVoiceClass ();
When reading aloud, use
voice.Speak(string,SpeechVoiceSpeakFlags.SVSFlagsAsync);
Pause, use
voice.Pause();
Continue the reading from the pause, use
voice.Resume();
The stop function is not written clearly in most materials, and is rarely found on the Internet, used here
voice.Speak(string.Empty, SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak);
In this way, the function of "reading aloud", "pause", "continue" and "stop" can be realized completely.
Initialization object, SpVoice voice = new DotNetSpeech.SpVoiceClass ();
When reading aloud, use
voice.Speak(string,SpeechVoiceSpeakFlags.SVSFlagsAsync);
Pause, use
voice.Pause();
Continue the reading from the pause, use
voice.Resume();
The stop function is not written clearly in most materials, and is rarely found on the Internet, used here
voice.Speak(string.Empty, SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak);
In this way, the function of "reading aloud", "pause", "continue" and "stop" can be realized completely.