将音频文件转换为c#中的文本 [英] Convert audio file to text in c#
本文介绍了将音频文件转换为c#中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友们,
我希望一切顺利。我需要一个帮助,如何将音频文件转换为c#中的文本。
Dear Friends,
I hope all are doing well. I need one help, How to convert audio file to text in c#.
推荐答案
从这里开始: https://msdn.microsoft.com/en-us/library/system.speech.recognition.speechrecognitionengine.setinputtowavefile.aspx [ ^ ]
我从这里开始,CodeProject文章 - 语音识别,语音到文本,文本到语音,以及C#中的语音合成 [ ^ ]
I'd start here, CodeProject article - Speech recognition, speech to text, text to speech, and speech synthesis in C#[^]
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();
这篇关于将音频文件转换为c#中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文