[英]how to fix ''phrase' cannot be an empty string. Parameter name: phrase'?
whenever I start debugging this error occur on the gramList.Add(grammarFile);每当我开始调试这个错误发生在 gramList.Add(grammarFile);
System.ArgumentException: ''phrase' cannot be an empty string. System.ArgumentException: ''phrase' 不能是空字符串。 Parameter name: phrase'参数名称:短语'
public Form1()
{
//initialize grammarfile
gramList.Add(grammarFile);
Grammar grammar = new Grammar(new GrammarBuilder(gramList));
try
{
speechRecognition.RequestRecognizerUpdate();
speechRecognition.LoadGrammar(grammar);
speechRecognition.SpeechRecognized += rec_SpeechRecognized;
speechRecognition.SetInputToDefaultAudioDevice();
speechRecognition.RecognizeAsync(RecognizeMode.Multiple);
}
catch
{
return;
}
if there are some empty lines at the end of all the text or inside the text file it must be considered an empty phrase so just remove these empty lines from the file..如果所有文本的末尾或文本文件中有一些空行,则必须将其视为空短语,因此只需从文件中删除这些空行即可。
open the commands file and check if there are come yellow colored lines or open commands file in notepad and check whether there are empty lines or not.打开命令文件并检查是否有黄色线条或在记事本中打开命令文件并检查是否有空行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.