问题描述
我使用语音消息制作了一个Lan Chat应用程序.我有问题,例如,如果在聊天框中键入文本"HELLO",则应用程序读取单词"HELLO"就可以了,但是在我的第二条消息上,例如,如果键入您好吗"?问题在于应用程序将说出第一条消息"Hello",然后说出第二条消息,即你好吗?".我希望不再讲旧消息,而只讲新消息.
这是我的代码,我将此代码放在文本框中
I make a Lan Chat Application With Spoken Message . I have problem for example if type the text " HELLO " in the chatbox the application read the word " HELLO " it is Okay but on my second message for example if I type " How are you"? the problem is the application would speak the first message " Hello " and after it would speak the second message which is " How are you?" I want it that the older message would not be speak anymore and the new message will only be speak.
Here''s My code I Put this code on a textbox
private void msg_TextChanged(object sender, EventArgs e)
{
speech.Rate = speechRate;
speech.Speak(msg.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);
}
推荐答案
speech.Speak(msg.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);
上面的代码本身表明您正在将msg.Text传递给Speak()方法,而您需要修改msg.Text字符串并传递更新的字符串.可能您会使用一些类级别的字符串变量来执行此操作,并将所有插入的字符串或更好地维护的所有字符串存储在Array中,这有助于您创建聊天记录",并且在讲话时,您可以从当前更新的Chat中删除现有的聊天.
这只是对您的问题的一种补救措施,我并不是说这是您真正需要以连击方式设计方法的最佳方法.
问候
Rushikesh Joshi
Above code itself says that you are passing msg.Text to Speak() method, instead you need to modify msg.Text string and pass the updated one. Probably you would do it using some class level string variable and store all string inserted or better maintain in an Array which help you to create Chat History and at time of speak you can remove existing chat from current updated Chat.
This is just a remedy for your issue, I am not saying this is best approach you really need to design your approach in batter way.
Regards
Rushikesh Joshi
这篇关于如何在语音中使用Tcplistner?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!