我得到了这个期望,但不知道如何解决它。
我尝试将文化更改为 fi-FI、en-EN、en-GB、en-US,它总是给人以这种期望。
我也尝试过不支持文化的解决方案和Go to Debug -> Options -> Debugging and tick "Enable Just My Code"
这个。
.NET Framework 4.7.2 Visual Studio 2019 参考 System.Speech
using System;
using System.Speech.Recognition;
namespace SpeechRecognition3
{
class Program
{
static void Main(string[] args)
{
// Create an in-process speech recognizer for the en-US locale.
using (SpeechRecognitionEngine recognizer =
new SpeechRecognitionEngine(
new System.Globalization.CultureInfo("fi-FI")))
{
// Create and load a dictation grammar.
recognizer.LoadGrammar(new DictationGrammar());
// Configure input to the speech recognizer.
recognizer.SetInputToDefaultAudioDevice();
// Modify the initial silence time-out value.
recognizer.InitialSilenceTimeout = TimeSpan.FromSeconds(5);
// Start synchronous speech recognition.
RecognitionResult result = recognizer.Recognize();
if (result != null)
{
Console.WriteLine("Recognized text = {0}", result.Text);
}
else
{
Console.WriteLine("No recognition result available.");
}
}
Console.WriteLine();
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
}
}