Click here to Skip to main content
15,880,364 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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());
}
Posted
Updated 15-Apr-14 22:55pm
v2
Comments
lukeer 16-Apr-14 4:16am    
What exactly do you want to be in the resulting text file?

Is it the song/speech text?
A description of how the file sounds?
Artist/Title and so on?

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.
 
Share this answer
 
It does not make any sense to convert wav to text.but the answer could be something like this:

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

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900