使用System.Speech将mp3文件转换为文本

我正在尝试使用.net中的语音识别来识别mp3文件中播客的语音,并将结果作为字符串。 我见过的所有例子都与使用麦克风有关但我不想使用麦克风并提供一个示例mp3文件作为我的音频源。 任何人都可以指向任何资源或发布示例。

编辑 –

我将音频文件转换为wav文件并在其上尝试此代码。 但它只提取前68个单词。

 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; } } 

尝试循环阅读。

 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(); 

如果您有Windows窗体或WPF应用程序,请在单独的线程中运行此代码,否则它会阻止UI线程。

我首先看一下这里记录的方法: http : //msdn.microsoft.com/en-us/library/system.speech.recognition.speechrecognitionengine.setinputtowavefile.aspx

你应该能够在这里解决这个问题。