-1

I have a .wav file which contains the text "hello".

The objective is to read the .wav file and to get the text back. I am using NAudio for this purpose by using the below piece of code

using (WaveFileReader reader = new WaveFileReader("D:\\test.wav"))
{                
   byte[] buffer = new byte[reader.Length];
   int read = reader.Read(buffer, 0, buffer.Length);
   short[] sampleBuffer = new short[read / 2];
   System.Buffer.BlockCopy(buffer, 0, sampleBuffer, 0, read);
}

And while converting the array back to string, I am receiving blank text

var bytes = a.SelectMany(x => BitConverter.GetBytes(x)).ToArray();
var originalText = System.Text.Encoding.Unicode.GetString(bytes); 

What is that I am missing?

halfer
  • 19,824
  • 17
  • 99
  • 186
priyanka.sarkar
  • 25,766
  • 43
  • 127
  • 173
  • 1
    I'm voting to close this question as off-topic because it requires understanding of speech/text recognition process – Roman R. Dec 25 '15 at 08:45
  • What do you mean by "contains" text "hello"? There are 5 chars/bytes in the audio file which forms the pattern "hello"? Somebody says "hello" and you want to extract it? – Ian Dec 28 '15 at 16:31
  • Please specify what you want to do - as already asked by Ian, is there the word "hello" in some encoding (UTF-8 or something else) stored in the file (and if so - why the hell would it have the ending .wav) or is there a sound that sounds like "hello" and you want to recognize the speech of that "sound"? – Markus Safar Jan 02 '16 at 01:58
  • 1
    Respected Seniors, I actually tried to close this because as rightly told by @ Roman R, I should first understand "speech/text recognition process". But I could not do that since by that time I have already created the bounty. If there is any way to do so (close this question), please do that on my behalf. First I myself will try, and then if i have the doubt I will surely ask. Because asking something on the air regarding which I seriously don't know anything , won't help me in the long run. But thanks to all of you. – priyanka.sarkar Jan 02 '16 at 17:16
  • @priyanka.sarkar I see, so what you want is to extract the speech-word "hello" in your recorded ".wav" file. That is rather tough. – Ian Jan 03 '16 at 04:51

2 Answers2

1

Now that you have clarified your question (including what's in the comments), it is a valid question and has an answer!

Microsoft Speech Platform Use WAV File Input for Speech Recognition

The example on that page shows using the API to input a WAV file and output text like so:

The following are the contents of the grammar FlightDestination.grxml.

<?xml version="1.0" encoding="utf-8"?>
<grammar version="1.0" xml:lang="en-US" mode="voice" root="destination" xmlns="http://www.w3.org/2001/06/grammar" tag-format="semantics/1.0">
  <rule id="destination"> 
    <item> I want to fly to </item>
    <ruleref uri="#city"/> 
  </rule>

  <rule id="city">
    <one-of>
      <item> Boston </item>
      <item> Madrid </item>
      <item> London </item>
    </one-of>
  </rule>
</grammar>

This appears to be exactly what you are looking for.

Kory Gill
  • 6,993
  • 1
  • 25
  • 33
0

I got some really good pointers like

Voice/Speech to text

and then

Speech Recognition with C# – Dictation and Custom grammar

and then

Speech Recognition and the System.Speech namespace

Creating your own custom Grammar, and filtering recognition based on confidence

Speech synthesizers

Speech Recognition

which is helping me. I am understanding the concept and how they have implemented. Need to know more about Grammers and SpeechRecognitionEngine

Community
  • 1
  • 1
priyanka.sarkar
  • 25,766
  • 43
  • 127
  • 173