我遇到了麻烦,因为当我在设备(Lumia 830)上运行我的程序时,我的语音合成器冻结了一些短语..我做了很多测试,我发现问题是我初始化语音识别时......我尝试做很多事情,如separe代码synthezis并识别..但它不起作用。有人知道如何解决这个问题?例如,当我的手机说:“说一个命令”它在最后一句话中就像一个Commmaaaaaaaaaaa和...:它真的是一个头痛
这是我的代码:
sin.Voice = (SpeechSynthesizer.AllVoices.First(x => x.Gender == VoiceGender.Male));
var language = new Windows.Globalization.Language("en-EN");
SpeechRecognizer recognizer = new SpeechRecognizer(language);
List<string> dict= new List<string>();
string[] responses = { "One", "Twoo", "three", "End", "Exit", };
var listConstraint = new Windows.Media.SpeechRecognition.SpeechRecognitionListConstraint(responses, "Comandos");
recognizer.Constraints.Add(listConstraint);
await recognizer.CompileConstraintsAsync();
var recognition = recognizer.RecognizeAsync();
//await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, new DispatchedHandler(
// () => { mediaElement.Stop(); mediaElement.SetSource(stream, stream.ContentType); mediaElement.Play(); }));
texto = " " + " " + "Say a COmmand" + " " + " ";
SpeechSynthesisStream stream = await sin.SynthesizeTextToStreamAsync(texto);
if (mediaElement.CurrentState.Equals(MediaElementState.Playing))
{
mediaElement.Stop();
mediaElement.SetSource(stream, stream.ContentType);
mediaElement.Play();
}else
{
//mediaElement.Stop();
mediaElement.SetSource(stream, stream.ContentType);
mediaElement.Play();
}
recognition.Completed += this.Recognition_Completed;