简体   繁体   中英

C# convert RecognizedAudio to text

I want my program to convert my RecognizedAudio to text, this is what I have tried

RecognizedAudio nameAudio = result.GetAudioForWordRange(result.Words[2], result.Words[result.Words.Count - 1]);
MessageBox.Show(nameAudio.ToString());

It outputs this message:

System.Speech.Recognition.RecognizedAudio

Would anybody be able to help me with this issue? I'd really appreciate it!

Thanks in advance

ToString() is simply the default ToString() method of the class, and calling it actually converts it to string and it is not the method you are looking for.

From SpeechRecognizer :

You must have add a handler for your class:

 static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)  
    {  
      Console.WriteLine("Speech recognized:  " + e.Result.Text);  
      Console.WriteLine();  
      Console.WriteLine("Semantic results:");  
      Console.WriteLine("  The flight origin is " + e.Result.Semantics["origin"].Value);  
      Console.WriteLine("  The flight destination is " + e.Result.Semantics["destination"].Value);  
    }  

The code above is the last lines of code in the page from Microsoft I have refereed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM