Using System.Speech to convert mp3 file to text

I am trying to use speech recognition in .net to recognize podcast speech in an mp3 file and get the result as a string. All the examples that I saw related to the use of a microphone, but I do not want to use a microphone and provide a sample mp3 file as a sound source. Can someone point me to some resource or send an example.

EDIT -

I converted the audio file to a wav file and tried this code on it. But it only extracts the first 68 words.

 public class MyRecognizer { public string ReadAudio() { SpeechRecognitionEngine sre = new SpeechRecognitionEngine(); Grammar gr = new DictationGrammar(); sre.LoadGrammar(gr); sre.SetInputToWaveFile("C:\\Users\\Soham Dasgupta\\Downloads\\Podcasts\\Engadget_Podcast_353.wav"); sre.BabbleTimeout = new TimeSpan(Int32.MaxValue); sre.InitialSilenceTimeout = new TimeSpan(Int32.MaxValue); sre.EndSilenceTimeout = new TimeSpan(100000000); sre.EndSilenceTimeoutAmbiguous = new TimeSpan(100000000); RecognitionResult result = sre.Recognize(new TimeSpan(Int32.MaxValue)); return result.Text; } } 
+7
c # speech-recognition speech-to-text
source share
2 answers

Try reading it in a loop.

 SpeechRecognitionEngine sre = new SpeechRecognitionEngine(); Grammar gr = new DictationGrammar(); sre.LoadGrammar(gr); sre.SetInputToWaveFile("C:\\Users\\Soham Dasgupta\\Downloads\\Podcasts\\Engadget_Podcast_353.wav"); sre.BabbleTimeout = new TimeSpan(Int32.MaxValue); sre.InitialSilenceTimeout = new TimeSpan(Int32.MaxValue); sre.EndSilenceTimeout = new TimeSpan(100000000); sre.EndSilenceTimeoutAmbiguous = new TimeSpan(100000000); StringBuilder sb = new StringBuilder(); while (true) { try { var recText = sre.Recognize(); if (recText == null) { break; } sb.Append(recText.Text); } catch (Exception ex) { //handle exception //... break; } } return sb.ToString(); 

If you have a Windows Forms or WPF application, run this code in a separate thread, otherwise it blocks the user interface thread.

+9
source share

I would first look at the method described here: http://msdn.microsoft.com/en-us/library/system.speech.recognition.speechrecognitionengine.setinputtowavefile.aspx

You should be able to come from here, I think.

0
source share

All Articles