本文介绍了我想将波形文件转换为文本格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想将wave文件转换为Text格式。我给它显示了一些输出的代码,但是波形文件中的单词不一样。 我的代码是: OpenFileDialog open = new OpenFileDialog(); if(open.ShowDialog()== DialogResult.OK) { SpeechRecognitionEngine sre = new SpeechRecognitionEngine(); Grammar gr = new DictationGrammar(); sre.LoadGrammar(gr); sre.SetInputToWaveFile(C:\\Users \\hanitha \\ Music \\ hello.wav); sre.BabbleTimeout = new TimeSpan(Int32 .MaxValue); sre.InitialSilenceTimeout = new TimeSpan(Int32.MaxValue); sre.EndSilenceTimeout = new TimeSpan(100000000); sre.EndSilenceTimeoutAmbiguous = new TimeSpan(100000000); St ringBuilder sb = new StringBuilder(); RecognitionResult Result = sre.Recognize(); sre.RecognizeAsync(RecognizeMode.Single); foreach(在Result.Words中识别WordUnit Word) { sb.Append(Word.Text +); } richTextBox1.AppendText(sb.ToString()); }i want to convert wave file to Text format. i treid the some code it shows some output , but the words are not the same whats on the wave file.my code is:OpenFileDialog open = new OpenFileDialog(); if (open.ShowDialog()==DialogResult.OK) { SpeechRecognitionEngine sre = new SpeechRecognitionEngine(); Grammar gr = new DictationGrammar(); sre.LoadGrammar(gr); sre.SetInputToWaveFile("C:\\Users\\hanitha\\Music\\hello.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(); RecognitionResult Result = sre.Recognize(); sre.RecognizeAsync(RecognizeMode.Single); foreach (RecognizedWordUnit Word in Result.Words) { sb.Append(Word.Text + " "); }richTextBox1.AppendText(sb.ToString()); }推荐答案var data = File.ReadAllBytes("path");var text = System.Text.Encoding.ASCII.GetString(data); 这篇关于我想将波形文件转换为文本格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-01 14:32