Create Simple Executable for WAV File Input with SR Engines (SAPI 5.3) - SOURCE CODE ALREADY PROVIDED BY MICROSOFT
$30-100 USD
In Progress
Posted almost 15 years ago
$30-100 USD
Paid on delivery
I need the following source code in an executable to be run on Windows Vista 64bit that will take an existing WAV file (like from c:\[login to view URL]) and access Microsoft's Speech Recognition (SR Engines (SAPI 5.3)) to convert the wav file to text (output will be a .txt file). Microsoft has already provided the code link here: [login to view URL](VS.85).aspx I just need an executable to click on for Windows Vista to take .wav file and convert to text using exist API. I think you just need a Visual Studio Compiler to create.
## Deliverables
Here is source code: [login to view URL](VS.85).aspx C-style is very similar to C++ and COM { CComPtr cpInputStream; CComPtr cpRecognizer; CComPtr cpRecoContext; CComPtr cpRecoGrammar; // Create basic SAPI stream object // NOTE: The helper SpBindToFile can be used to perform the following operations hr = [login to view URL](CLSID_SpStream); // Check hr CSpStreamFormat sInputFormat; // generate WaveFormatEx structure, assuming the wav format is 22kHz, 16-bit, Stereo hr = [login to view URL](SPSF_22kHz16BitStereo); // Check hr // setup stream object with wav file MY_WAVE_AUDIO_FILENAME // for read-only access, since it will only be access by the SR engine hr = cpInputStream->BindToFile(MY_WAVE_AUDIO_FILENAME, SPFM_OPEN_READONLY, [login to view URL](), [login to view URL](), SPFEI_ALL_EVENTS); // Check hr // Create in-process speech recognition engine hr = [login to view URL](CLSID_SpInprocRecognizer); // Check hr // connect wav input to recognizer // SAPI will negotiate mismatched engine/input audio formats using system audio codecs, so second parameter is not important - use default of TRUE hr = cpRecognizer->SetInput(cpInputStream, TRUE); // Check hr // Create recognition context to receive events hr = cpRecognizer->CreateRecoContext(&cpRecoContext;); // Check hr // Create grammar, and load dictation // ignore grammar ID for simplicity's sake // NOTE: Voice command apps would load CFG here hr = cpRecognizer->CreateGrammar(NULL, &cpRecoGrammar;); // Check hr hr = cpRecoGrammar->LoadDictation(NULL,SPLO_STATIC); // Check hr // check for recognitions and end of stream event hr = cpRecoContext->SetInterest(SPFEI(SPEI_RECOGNITION) | SPFEI(SPEI_SR_END_STREAM), SPFEI(SPEI_RECOGNITION) | SPFEI(SPEI_SR_END_STREAM)); // use Win32 events for command-line style application hr = cpRecoContext->SetNotifyWin32Event(); // Check hr // activate dictation, and begin recognition hr = cpRecoGrammar->SetDictationState(SPRS_ACTIVE); // Check hr // while events occur, continue processing // timeout should be greater than the audio stream length, or a reasonable amount of time expected to pass before no more recognitions are expected in an audio stream BOOL fEndStreamReached = FALSE; while (!fEndStreamReached && S_OK == cpRecoContext->WaitForNotifyEvent(MY_REASONABLE_TIMEOUT)) { CSpEvent spEvent; // pull all queued events from the reco context's event queue while (!fEndStreamReached && S_OK == [login to view URL](cpRecoContext)) { // Check event type switch ([login to view URL]) { // speech recognition engine recognized some audio case SPEI_RECOGNITION: // TODO: log/report recognized text break; // end of the wav file was reached by the speech recognition engine case SPEI_SR_END_STREAM: fEndStreamReached = TRUE; break; } // clear any event data/object references [login to view URL](); }// END event pulling loop - break on empty event queue OR end stream }// END event polling loop - break on event timeout OR end stream // deactivate dictation hr = cpRecoGrammar->SetDictationState(SPRS_INACTIVE); // Check hr // unload dictation topic hr = cpRecoGrammar->UnloadDictation(); // Check hr // close the input stream, since we're done with it // NOTE: smart pointer will call SpStream's destructor, and consequently ::Close, but code may want to check for errors on ::Close operation hr = cpInputStream->Close(); // Check hr }