【问题标题】:AI in Microsoft Visual Studios 2015 that recognizes every word spoken and speak every word backMicrosoft Visual Studios 2015 中的 AI,可识别说出的每一个单词并说出每一个单词
【发布时间】:2016-09-11 00:46:14
【问题描述】:

我正在 Microsoft Visual Studios 2015 中创建 AI,并且我使用 SpeechSytheizer 对象和 SpeechRecognizer 对象而不是 SpeechRecognitionEngine 对象,这样我就可以使用 Microsoft 语音识别器而不是 SpeechRecognitionEngine 中内置的识别器所以我必须使用语法构建器并将它们加载到 SpeechRecognitionEngine 中。

话虽如此,我已经创建了一个richTextBox,它将我所说并识别的单词附加到richtextBox;但是,在我说完之后,我试图让 AI 回复:

if(e.result.text.toString().contains("whatever I said")){
s.speak("whatever i want it to say back");
}

但是由于某种原因,微软语音识别器在我说了什么之后不睡觉,而是附加了文字,但人工智能没有说回来。

如果有人知道如何让语音识别器在说完一个句子后进入睡眠状态,然后让 SpeechSythesizer 对象回话,那就太好了

谢谢, thatProgrammingGuy23

这是目前的代码:

public partial class Form1 : Form{

    public Form1()
    {
        InitializeComponent();
    }
    SpeechSynthesizer s = new SpeechSynthesizer();
    SpeechRecognizer rec = new SpeechRecognizer();
    private void Form1_Load(object sender, EventArgs e)
    {
        rec.SpeechRecognized += rec_SpeechRecognized;
    }

    private void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {

        richTextBox1.AppendText(e.Result.Text.ToString() + "");

        if (e.Result.Text.Contains("hello")){
            s.Speak("hi");

        }
    }
}

【问题讨论】:

  • Result.Text.ToString() + "" 可以简化为 Result.Text,因为 Text 是一个字符串,调用 ToString() 会返回一个相同的字符串,您还在寻找 SpeechRecognizer.PauseRecognizerOnRecognition 吗?
  • 我相信你需要一个关键字来激活,和一个计时器来控制它读取声音的时间量。然后在时间窗口关闭后,您可以使用 ppl 在答案中所说的禁用聆听并进行叙述,如果这是您的问题...
  • 你研究过微软的机器人框架吗? docs.botframework.com/en-us/bot-intelligence/speech/#navtitle

标签: c# visual-studio-2010 visual-studio-2012 artificial-intelligence voice-recognition


【解决方案1】:

如果您希望SpeechRecognizer 在一段时间内忽略语音,您可以使用SpeechRecognizer.Enabled

SpeechSynthesizer s = new SpeechSynthesizer();
SpeechRecognizer rec = new SpeechRecognizer();
private void Form1_Load(object sender, EventArgs e)
{
    rec.SpeechRecognized += rec_SpeechRecognized;
}

private void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
    richTextBox1.AppendText(e.Result.Text);

    if (e.Result.Text.Contains("hello"))
    {
        rec.Enabled = false;
        //Do stuff
        s.Speak("hi");
        rec.Enabled = true;
    }
}

【讨论】:

  • 我想做的是对 SpeechRecognizer 说些什么,然后让微软语音识别器进入睡眠状态,而我的 AI 回复我,或者做一些动作,然后重新开始听,好像就像 SpeechRecognitionEngine。
猜你喜欢
  • 1970-01-01
  • 2016-07-01
  • 1970-01-01
  • 2012-11-09
  • 1970-01-01
  • 1970-01-01
  • 2012-03-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多