-1

I'm trying to create a program that uses voice recogniton and makes a WAV file from the recognized voice, I used this code :

Recognizer.SetInputToWaveFile(@"C:\\Program Files\\MyProgram\\Bin\\STWAV\\Speech.wav");

but I'm getting this exception every time I start the voice recognition,

"Could not locate file C:\Program Files\MyProgram\Bin\STWAV\Speech.wav".

I think that my program don't have a permission to create the WAV file in this path.

Thanks for helping.

ORION
  • 7
  • 7

1 Answers1

1

When writing to

C:\Program Files\

you will need administrator-permission. Try to write the file the user's documents or a similar place.
Using System.Environment.SpecialFolder you can get the user's documents-folder easily.

string docs = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
docs += "\\Speech.wav";
Recognizer.SetInputToWaveFile(docs);

Alternatively, but a bad idea, would be to require the user to start the program as administrator.


EDIT

The method

Recognizer.SetInputToWaveFile

is meant to READ from a file. You cannot use it to store anything in a wav-file.

Here you find a tutorial on how to record speech in .NET.

bash.d
  • 13,029
  • 3
  • 29
  • 42
  • Sorry but I'm unable download the SDK, I'll tell you what I'm working on ,I wanna use "google speak now" service in my c# program, and what I wanted to do is turning the speech into a wav file and sending it to google's speech server and getting the recognized voice text. – ORION Aug 20 '13 at 08:10
  • So is there another way to create a wav file from recognized voice ? – ORION Aug 20 '13 at 08:18