예제 #1
0
bool TextToSpeech::say(string wordToSay)
{
	//convert string to wstring to use with speech function
	wstring wstr(wordToSay.begin(), wordToSay.end());

	ISpVoice * pVoice = NULL;

	if (FAILED(::CoInitialize(NULL)))
		return FALSE;

	HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
	if (SUCCEEDED(hr))
	{
		long rate = -5;
		pVoice->SetRate(rate);
		hr = pVoice->Speak(wstr.c_str(), 0, NULL);
		pVoice->Release();
		pVoice = NULL;
	}

	::CoUninitialize();
	return TRUE;
}
예제 #2
0
파일: main.cpp 프로젝트: df32/TTS
	HRESULT SetRate(long RateAdjust)	//设置语速(同上)
	{
		return VoiceObj->SetRate(RateAdjust);
	}