Speech to Text C# Train For Better Translation

2019-08-12 04:56发布

I need to way to make the speech to text smarter as many of the words it is just getting incorrect in the translation. I cannot find much help on adding a list of words, not commands or grammar but words to help better translate audio recording.

Here is the code I found on the web, and this works, but I need to way to train, or make the engine smarter. Any ideas?

Thanks.

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("en-US")))
    {
        // Create and load a dictation grammar.
        recognizer.LoadGrammar(new  DictationGrammar());

        // Add a handler for the speech recognized event.
        recognizer.SpeechRecognized +=
              new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);

        // Configure input to the speech recognizer.
        recognizer.SetInputToWaveFile(@"c:\test2.wav");  

        // Start asynchronous, continuous speech recognition.
        recognizer.RecognizeAsync(RecognizeMode.Multiple);

        // Keep the console window open.
        while (true)
        {
            Console.ReadLine();
        }
    }
}

// Handle the SpeechRecognized event.
static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
    Console.WriteLine("Recognized text: " + e.Result.Text);

    using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\WriteLines2.txt", true))
    {
        file.WriteLine("");
    }  
}

0条回答
登录 后发表回答