Logo

void run_sapi_textbased_lipsync std::wstring &  strAudioFile,
TCHAR *  strTextFile
 

This function demonstrates how to perform "Text Based Lipsync".

Given an audio file and a text file, this method will generate word timings and phoneme timings of the text file to the audio file using sapi_lipsync and helpers.

This is the best code to look at first.

The results are printed to std::out

Parameters:
strAudioFile - [in] audio file
strTextFile - [in] text file

Definition at line 154 of file sapi_lipsync_main.cpp.

00155 {
00156     // 1. [optional] declare the SAPI 5.1 estimator. 
00157     // NOTE: for different phoneme sets, create a new estimator
00158     phoneme_estimator sapi51Estimator;
00159 
00160     // 2. Load the text file into memory
00161     WCHAR * pwszCoMem = 0;
00162     ULONG cch = 0;
00163     HRESULT hr = GetTextFile(strTextFile, &pwszCoMem, &cch);
00164     if (hr == S_OK)
00165     {
00166         std::wstring strText(pwszCoMem, cch);
00167 
00168         // 3. declare the sapi lipsync object and call the lipsync method 
00169         // to start the lipsync process
00170         sapi_textbased_lipsync lsp(&sapi51Estimator);
00171         if (lsp.lipsync(strAudioFile, strText))
00172         {
00173 
00174             // 4. Run the message loop and wait till the lipsync is 
00175             // finished
00176             run_lipsync_message_loop(lsp);
00177               
00178             // 5. finalize the lipsync results for printing
00179             // this call will estimate phoneme timings 
00180             lsp.finalize_phoneme_alignment();
00181             
00182             // 6. print the results to the output stream
00183             lsp.print_results(std::cout);
00184         }
00185         else
00186         {
00187             std::wcerr << lsp.getErrorString() << std::endl;            
00188         }
00189     }
00190     else
00191     {
00192         std::wcerr << L"Can't open text transcript file" << std::endl;
00193     }
00194 }


Copyright (C) 2002-2005 Annosoft LLC. All Rights Reserved.
Visit us at www.annosoft.com