语音暂停和停止问题 [英] spvoice pause and stop problem

查看:937
本文介绍了语音暂停和停止问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我在Web应用程序中使用SAPI(5.1)时遇到了Microsoft Speech Object Library问题(asp.net4.0
和c#)

当我单击继续播放时.

当我尝试停止或暂停时,它不会停止或暂停.

它会一直播放到文本结束为止.

我该如何停止和暂停.

Hi all i have getting problem Microsoft Speech Object Library when using SAPI(5.1) in web application(asp.net4.0
and c#)

when i click play its playing continuely.

when i try to stop or pause its not stopped or pause.

it will play until text is over.

how can i stop and pause.

推荐答案

然后我应该说您使用SpVoice,但您不知道它的功能.
可以同步或异步调用 SpVoice.Speak()方法.当被同步调用时,该方法直到说出文字后才返回;当异步调用时,它将立即返回,并且语音作为后台进程讲话.
因此,使用异步方法而不是同步方法,应该可以解决您的问题.像ase一样使用 SpeechVoiceSpeakFlags.SVSFlagsAsync .
Then i should say you use SpVoice,but you don''t know about it''s features.
SpVoice.Speak() method can be called synchronously or asynchronously. When called synchronously, the method does not return until the text has been spoken; when called asynchronously, it returns immediately, and the voice speaks as a background process.
So use asynchronous method instead of synchronous,your problem should be solved.Use SpeechVoiceSpeakFlags.SVSFlagsAsync as like ase..
SpVoice voice = new SpVoice ();
 voice.Speak ("An example of SpVoice.",SpeechVoiceSpeakFlags.SVSFlagsAsync);


下面的代码是我的项目之一的一部分...
我使用 System.Speech dll的 SpeechSynthesizer 类.
创建一个实例,如..


Below code is a part of one of my project...
I use SpeechSynthesizer class of System.Speech dll.
Create an instance like..

SpeechSynthesizer synthesis=new SpeechSynthesizer();


然后用于语音转换..


Then for speech conversion i use..

synthesis.SpeakAsync(richTextBox1.Text);//speaks the text


要停止讲话,我使用..


To stop speech i use..

synthesis.Dispose();//stops the synthesizer hence the speech!


这篇关于语音暂停和停止问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆