0
我正在使用Windows.Speech API 我想要做的是讓系統識別短語的一部分,而不是尋找整個事情。 例如,如果我加載字符串:「你好嗎」,它要求用戶準確地說,你好嗎。最終,我希望Windows.Speech也能認識到這樣的事情:「嘿,今天好嗎?」c#語音識別部分的短語 - windows.speech
這是我目前有:
//This is used for Building the recognizer engine.
Choices commands = new Choices();
commands.Add(new string[] { Question5,
Question1,Question3,Question2,Question4});
GrammarBuilder gBuilder = new GrammarBuilder();
gBuilder.Append(commands);
Grammar grammar = new Grammar(gBuilder);
//Loading the Grammar engine
recEngine.LoadGrammarAsync(grammar);
recEngine.SetInputToDefaultAudioDevice();
recEngine.SpeechRecognized += recEngine_SpeechRecognized;
然後顯示:
void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result.Text == Question1)
{
richTextBox1.Text += "\nYou have Asked Question 1";
chkBoxQ1.Checked = true;
agentScore = agentScore + 1;
stopCussing = Response1;
Form2 responseForm = new Form2();
responseForm.Show();
Question1Answer = "Question Asked";
txtBoxAnswer1.Enabled = true;
}
else if (e.Result.Text == Question2)
{
richTextBox1.Text += "\nYou have now asked Question 2";
chkQuestion2.Checked = true;
stopCussing = Response2;
Form2 responseForm = new Form2();
responseForm.Show();
agentScore = agentScore + 1;
Question2Answer = "Question Asked";
txtAnswer2.Enabled = true;
}
else if (e.Result.Text == Question3)
{
richTextBox1.Text += "\nYou have now asked Question 3";
chkQuestion3.Checked = true;
stopCussing = Response3;
Form2 responseForm = new Form2();
responseForm.Show();
agentScore = agentScore + 1;
Question3Answer = "Question Asked";
txtAnswer3.Enabled = true;
}
else if (e.Result.Text == Question4)
{
richTextBox1.Text += "\nYou have now asked Question 4";
chkQuestion4.Checked = true;
stopCussing = Response4;
Form2 responseForm = new Form2();
responseForm.Show();
agentScore = agentScore + 1;
Question4Answer = "Question Asked";
txtAnswer4.Enabled = true;
}
else if (e.Result.Text == Question5)
{
richTextBox1.Text += "\nYou have now asked Question 5";
chkQuestion5.Checked = true;
stopCussing = Response5;
Form2 responseForm = new Form2();
responseForm.Show();
agentScore = agentScore + 1;
Question5Answer = "Question Asked";
txtAnswer5.Enabled = true;
}
任何這裏洞察將是巨大的!僅供參考,我曾考慮過使用認知服務 - 但是如果我可以讓windows.speech做我需要的,我寧願不重寫。
有一個數據庫或文件可能的短語的列表,然後搜索他們的短語說... –
嘿約翰尼 - 我怎麼能它放到我的模型?基本上我有一個「經理」來更新問題,並根據這些問題將他們加載到構建器中,並提交給「代理人」詢問。有沒有辦法提出一些本質的東西:他們可以問這個問題,但它可以附加在這些詞語之前或之前? –
我不明白你的問題。你可以看看這個短語是否包含他們說的每個標記(單詞),找到包含他們所說的最多單詞的單詞,然後用發現的短語替換它。 –