发音程序,附源代码!
各位大神求救,我是菜鸟勿喷,
软件需要实现 在命令行 输入字母或单词或文字,然后语音读出来
所以需要把把输入流保存在一个CString/TWCHAR/wchar_t里面?然后在转换为LPCWSTR?
但是我试过很多方法,有的转换编译不通过,有的编译通过了,但是我输入英文,读出来的不对
求解,能贴出你的代码,那就更好了,谢谢!
代码如下
#include "stdafx.h"#include <sapi.h>int main(int argc, char* argv[]){ ISpVoice * pVoice = NULL; if (FAILED(::CoInitialize(NULL))) return FALSE; HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice); if( SUCCEEDED( hr ) ) { TCHAR speakStr; scanf("%s",speakStr); //LPTSTR speakStr=L"hello word!"; hr = pVoice->Speak(speakStr, 0, NULL); pVoice->Release(); pVoice = NULL; } ::CoUninitialize(); return TRUE;}