我想将波形文件转换为文本格式 [英] i want to convert wave file to Text format

查看:127
本文介绍了我想将波形文件转换为文本格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将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());
}

推荐答案

Wave文件不包含我认为你的意思的歌曲的文本 - 它包含一系列频率和持续时间值,可以重新创建原始声音,这可能根本与单词无关:它可能是电锯,鲸鱼歌曲或汽车引擎的声音 - 没有一个是用文字描述的!



如果你想转换一个文件通过文本界面传输文本并从另一个文件界面重新创建原始文件nd,然后那是不同的,并且有很多方法可以做到这一点。
A Wave file does not contain the "text" of a song in the sense I think you mean - it contains a series of frequency and duration values which can recreate the original sound, which may not be related to "words" at all: it could be the sound of a chainsaw, or a whale song, or a car engine - none of which are describable in words!

If you are trying to convert a file to text to transfer it via a text interface and recreate the original file from that at the other end, then that's different, and there are a number of ways to do that.


将wav转换为text是没有任何意义的。但答案可能是这样的:< br $>


It does not make any sense to convert wav to text.but the answer could be something like this:

var data = File.ReadAllBytes("path");

var text = System.Text.Encoding.ASCII.GetString(data);


这篇关于我想将波形文件转换为文本格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆