Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我的应用程序中用于语音控制的语音识别_Java_C#_Wpf_Speech Recognition_Voice Recognition - Fatal编程技术网

Java 我的应用程序中用于语音控制的语音识别

Java 我的应用程序中用于语音控制的语音识别,java,c#,wpf,speech-recognition,voice-recognition,Java,C#,Wpf,Speech Recognition,Voice Recognition,我知道这方面有很多线索,但我仍在努力找出2018年的最佳选择 在我的c#WPF应用程序中是否有一种内置的方法来集成语音控制 最好的解决方案是什么(免费还是付费) 我只是需要一些开始,并确保我走的方向是正确的。(因为许多线程和信息不是最新的) 谢谢 米歇尔 复制粘贴代码,从winform转换到WPF,就这样了 using System; using System.Collections.Generic; using System.ComponentModel; using System.Dat

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

  • 在我的c#WPF应用程序中是否有一种内置的方法来集成语音控制
  • 最好的解决方案是什么(免费还是付费)
我只是需要一些开始,并确保我走的方向是正确的。(因为许多线程和信息不是最新的)

谢谢

米歇尔

复制粘贴代码,从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);
    }
  }
}
使用系统;
使用System.Collections.Generic;
使用系统组件模型;
使用系统数据;
使用系统图;
使用System.Linq;
使用系统文本;
使用System.Windows.Forms;
使用系统语音识别;
命名空间Windows窗体应用程序1
{
公共部分类Form1:Form
{
公共表格1()
{
初始化组件();
}
私有void Form1\u加载(对象发送方、事件参数e)
{
//创建新的SpeechRecognitionEngine实例。
SpeechRecognizer recognizer=新的SpeechRecognizer();
//创建一个识别“红色”、“绿色”或“蓝色”的简单语法。
选择颜色=新选择();
添加(新字符串[]{“红色”、“绿色”、“蓝色”});
//创建GrammarBuilder对象并附加Choices对象。
GrammarBuilder gb=新的GrammarBuilder();
gb.附加(颜色);
//创建语法实例并将其加载到语音识别引擎中。
语法g=新语法(gb);
识别器。加载语法(g);
//为SpeechReceigned事件注册处理程序。
识别器+=
新事件处理程序(sre_SpeechReceigned);
}
//为SpeechRecognited事件创建一个简单的处理程序。
void sre_SpeechRecognized(对象发送方,SpeechRecognizedEventArgs e)
{
MessageBox.Show(“语音识别:+e.Result.Text”);
}
}
}

我建议调用
recognizer.RequestRecognizerUpdate()加载语法之前,然后,当然,
recognizer.setInputOdeFaultAudioDevice();识别器.RecognizeAsync(RecognizeMode.Multiple)
,在您注册了
SpeechReceigned
事件后。谢谢,它可以工作……由于某些原因,“红色”一词根本不起作用。那么,您确认这是WPF应用程序可用的最佳语音识别吗?最好是主观的。据我们所知,你有口音;-)考虑到它是一个MS框架,并且您正在使用MS技术编写代码,我将选择“最容易使用”。另外,我想你可以训练引擎以获得更好的识别,它们都不是很好的开箱即用。现在有没有关于java(非MS)解决方案的想法?我想评估并尝试这两种解决方案。谢谢