【问题标题】:C# Speech Recognition Library not able to recognize dictation of "nonsense words"C# 语音识别库无法识别“废话”的听写
【发布时间】:2018-07-08 06:00:53
【问题描述】:

我正在使用 C# 中的“System.Speech.Recognition”和“System.Speech.Synthesis”库来创建一个小型语音合成窗口应用程序。

该应用程序可以正常使用其语法中输入的单词并识别但无法识别其他单词。 (例如“zapssss Hello zapssss”,这实际上不是一个正确的短语)。本节需要帮助。我是 C# 的新手。

代码部分如下:-

   public string[] get_data_list() 
    {
        int counter = 0;
        string line;
        string[] data_list = new string[8];
        System.IO.StreamReader file = new System.IO.StreamReader(@"C:\\Users\\usr\\Desktop\\Voice Recognition\\Voice Recognition\\data_dict.txt");
        while ((line = file.ReadLine()) != null)
        {
            data_list[counter] = line;
            System.Console.WriteLine(data_list[counter]);
            counter++;
        }

        file.Close();
        Console.WriteLine("Hello");
        Console.WriteLine(data_list);
        return data_list;
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        Choices commands = new Choices();

        string[] voice_dict = get_data_list();

        foreach (string arrItem in voice_dict)
        {
            Console.WriteLine(arrItem);
        }

        commands.Add(voice_dict);
        GrammarBuilder gBuilder = new GrammarBuilder();
        gBuilder.Append(commands);
        Grammar grammar = new Grammar(gBuilder);
        recEngine.LoadGrammarAsync(grammar);
        recEngine.SetInputToDefaultAudioDevice();
        recEngine.SpeechRecognized += recEngine_SpeechRecognized;
    }

    void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) 
    {
        System.Console.WriteLine("Entered Event");
        string[] voice_dict = get_data_list();
        string msg;
        string user_recorded_voice = e.Result.Text;
        string voice_check_flag = check_voice_available(user_recorded_voice, voice_dict);

        switch (voice_check_flag)
        {

            case "not found":
                System.Console.WriteLine("Match Not Found for " + user_recorded_voice);
                msg = ("\nText " + user_recorded_voice + " Not Recognized");
                text_box.Text += msg;
                synth.SpeakAsync(msg);
                break;
            default:
                Console.WriteLine("\nMessage recieved " + voice_check_flag);
                text_box.Text += voice_check_flag;
                synth.SpeakAsync(voice_check_flag);
                break;
        }

    }

【问题讨论】:

  • 您为什么希望语音识别能够识别无意义的单词?我希望它只会识别它可以识别的东西。

标签: c# speech-recognition speech-to-text speech-synthesis


【解决方案1】:

根据 Microsoft 的说法,您将只能从您训练系统的语音中检测到文本(使用语法)Reference

虽然它有不同的事件你可以查看

SpeechRecognitionRejected

SpeechDetected

但截至目前,您无法知道用户在您之外说了什么 经过训练的语法集。

【讨论】:

    猜你喜欢
    • 2018-02-23
    • 2021-09-12
    • 2021-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多