【问题标题】:Speech recognition for voice control inside my application [duplicate]我的应用程序中语音控制的语音识别[重复]
【发布时间】:2018-12-21 01:19:50
【问题描述】:

我知道这方面有很多线索,但我仍在尝试找出 2018 年的最佳选择。

  • 是否有一种内置方法可以在我的 c# WPF 应用程序中集成语音控制?
  • 最好的解决方案是什么(免费或付费)?

我只是需要一些东西来开始,并确保我朝着正确的方向前进。 (因为许多线程和信息都不是最近的)

谢谢。

米歇尔

【问题讨论】:

    标签: java c# wpf speech-recognition voice-recognition


    【解决方案1】:

    https://docs.microsoft.com/en-us/previous-versions/office/developer/speech-technologies/hh361683(v=office.14)

    复制粘贴代码,从winform转换为WPF,然后就可以了。

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Speech.Recognition;
    
    namespace WindowsFormsApplication1
    {
      public partial class Form1 : Form
      {
        public Form1()
        {
          InitializeComponent();
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
    
          // Create a new SpeechRecognitionEngine instance.
          SpeechRecognizer recognizer = new SpeechRecognizer();
    
          // Create a simple grammar that recognizes "red", "green", or "blue".
          Choices colors = new Choices();
          colors.Add(new string[] { "red", "green", "blue" });
    
          // Create a GrammarBuilder object and append the Choices object.
          GrammarBuilder gb = new GrammarBuilder();
          gb.Append(colors);
    
          // Create the Grammar instance and load it into the speech recognition engine.
          Grammar g = new Grammar(gb);
          recognizer.LoadGrammar(g);
    
          // Register a handler for the SpeechRecognized event.
          recognizer.SpeechRecognized +=
            new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
        }
    
        // Create a simple handler for the SpeechRecognized event.
        void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
          MessageBox.Show("Speech recognized: " + e.Result.Text);
        }
      }
    }
    

    【讨论】:

    • 我建议在加载语法之前调用recognizer.RequestRecognizerUpdate();,当然,在注册SpeechRecognized 事件之后调用recognizer.SetInputToDefaultAudioDevice(); recognizer.RecognizeAsync(RecognizeMode.Multiple);
    • 谢谢它有效....由于某些原因,“红色”这个词根本不起作用。所以你确认它是可用于 WPF 应用程序的最佳语音识别?
    • 最适合这样的事情是主观的。据我们所知,您有口音;-) 鉴于它是一个 MS 框架,并且您正在使用 MS 技术编写代码,我只会选择“最容易使用”。另外我可以训练引擎以获得更好的识别,它们都不会是开箱即用的。
    • 现在有任何关于 java(非 MS)解决方案的想法吗?我想评估并尝试这两种解决方案。谢谢
    猜你喜欢
    • 1970-01-01
    • 2014-04-12
    • 1970-01-01
    • 1970-01-01
    • 2015-03-29
    • 2018-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多