SAPI不实现语音字母选择

时间:2019-02-02 21:23:46

标签: c# voice-recognition sapi

我正在使用内置的Windows语音API使用C#制作语音识别程序。我有这个工作,重新启动电脑后突然停止工作了。我不确定为什么,我确实尝试添加以下代码,据说有20多种不同的在线资源要添加:

gram.Culture = new System.Globalization.CultureInfo("en-GB");

(我什至尝试用““ en-US”替换"en-GB"

这是我运行代码时的控制台输出:

Better resolution https://i.stack.imgur.com/frRBF.png

这是我的代码:

public static void Main(string[] args)
{
    SpeechSynthesizer ss = new SpeechSynthesizer();

    GrammarBuilder gb = new Choices(new GrammarBuilder[] { "Hello", "Test" });

    gb.Culture = new System.Globalization.CultureInfo("en-GB");
    Grammar g = new Grammar(gb);

    SpeechRecognitionEngine engine = new SpeechRecognitionEngine();

    engine.SetInputToDefaultAudioDevice();
    engine.LoadGrammar(g);
    engine.RecognizeAsync(RecognizeMode.Multiple);
    engine.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(speechRecognized);

    ss.Speak("Enabled!");
}

public static void speechRecognized(object ob, SpeechRecognizedEventArgs e)
{
    string s = e.Result.Text;
    Console.WriteLine(s);
}

有人有什么想法吗?任何帮助,将不胜感激!谢谢...

0 个答案:

没有答案