I'm working on a C# TTS project, the library I use is Azure Microsoft.CognitiveServices.Speech.Synthesizer
I can see there is a method StartSpeakingTextAsync
to start a conversation, but I cannot find any method to stop or cancel a conversation. It is necessary if a conversation is long, after the user given input but the conversation still keeps going. So I have to cancel or stop it programmatically, but how?
A normal TTS processing for a conversation will be stop after its task completed by StartSpeakingTextAsync
.
If you need to cancel or stop it manually while in processing, you can create a thread to start its task and then cancel or stop it via Thread.Abort
method. I think it's the simplest way to realize your needs.
As reference, you can refer to some SO threads about cancel thread like How to Cancel a Thread? .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.