53 hr = pVoice.CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL);
57 hr = pVoice->SetInterest(SPFEI_ALL_TTS_EVENTS, SPFEI_ALL_TTS_EVENTS);
59 MMechostr(MSKDEBUG,
"Error CoCreateInstance\n");
64 MMechostr(MSKDEBUG,
"Error SetInterest\n");
68 hr = pVoice->GetRate(&m_DefaultRate);
70 MMechostr(MSKDEBUG,
"Error SetNotifyCallbackFunction\n");
73 hr = pVoice->GetVolume(&m_DefaultVolume);
75 MMechostr(MSKDEBUG,
"Error GetRate\n");
88 while (event.GetFrom(pVoice) == S_OK)
90 switch (event.eEventId)
92 case SPEI_START_INPUT_STREAM:
98 case SPEI_END_INPUT_STREAM:
110 case SPEI_WORD_BOUNDARY:
111 hr = pVoice->GetStatus(&Stat, NULL);
115 if ((Stat.ulInputWordPos + Stat.ulInputWordLen) <= m_buffer.length())
116 word = m_buffer.substr(Stat.ulInputWordPos, Stat.ulInputWordLen);
117 param =
new std::string(word);
125 case SPEI_SENTENCE_BOUNDARY:
126 hr = pVoice->GetStatus(&Stat, NULL);
130 if ((Stat.ulInputSentPos + Stat.ulInputSentLen) <= m_buffer.length())
131 word = m_buffer.substr(Stat.ulInputSentPos, Stat.ulInputSentLen);
132 param =
new std::string(word);
148 case SPEI_TTS_PRIVATE:
179 bool haveBuffer =
false;
181 if (!SUCCEEDED(pVoice->SetOutput(NULL, TRUE)))
185 if (!SUCCEEDED(pVoice->GetStatus(&Stat, NULL)))
186 haveBuffer = (Stat.ulCurrentStream == 0) ?
false :
true;
188 if (!m_bPause || !haveBuffer)
194 if (!m_buffer.empty())
197 hr = pVoice->Speak(wc, SPF_ASYNC | SPF_IS_XML | SPF_PURGEBEFORESPEAK, 0);
202 hr = pVoice->Speak(NULL, SPF_PURGEBEFORESPEAK, 0);
205 MMechostr(MSKDEBUG,
"Error : Speak\n");
315 CComPtr<ISpObjectToken> pToken;
316 CComPtr<IEnumSpObjectTokens> cpIEnum;
320 std::list <char *> lParamSp;
324 hr = SpEnumTokens(SPCAT_VOICES, NULL, NULL, &cpIEnum);
325 else if (voiceType == 1)
326 hr = SpEnumTokens(SPCAT_VOICES, L
"Gender=Male", NULL, &cpIEnum);
327 else if (voiceType == 2)
328 hr = SpEnumTokens(SPCAT_VOICES, L
"Gender=Female", NULL, &cpIEnum);
332 MMechostr(MSKDEBUG,
"getVoices -> Erreur : EnumTokens\n");
337 cpIEnum->GetCount(&sizel);
340 MMechostr(MSKDEBUG,
"getVoices -> Erreur : EnumTokens\n");
344 while (cpIEnum->Next(1, &pToken, NULL) == S_OK)
346 CSpDynamicString dstrText;
347 hr = SpGetDescription(pToken, &dstrText);
349 lParamSp.push_back(dstrText.CopyToChar());
351 MMechostr(MSKDEBUG,
"getVoices -> SpGetDescription : ERROR\n");
368 HRESULT hr = S_FALSE;
369 CComPtr<IEnumSpObjectTokens> cpIEnum;
370 CComPtr<ISpObjectToken> pToken;
371 bool testVoice =
true;
373 hr = SpEnumTokens(SPCAT_VOICES, NULL, NULL, &cpIEnum);
376 wchar_t* dstrTextTest;
377 while ((cpIEnum->Next(1, &pToken, NULL) == S_OK) && (testVoice ==
true))
379 hr = SpGetDescription(pToken, &dstrTextTest);
384 if (strcmp(textV, voice.c_str()) == 0)
386 hr = pVoice->SetVoice(pToken);
388 MMechostr(MSKDEBUG,
"SetSpeechVoice -> SetVoice : OK \n");
390 MMechostr(MSKDEBUG,
"SetSpeechVoice -> SetVoice : ERROR\n");
394 MMechostr(MSKDEBUG,
"SetSpeechVoice -> lpszVoiceId <> voice\n");
397 MMechostr(MSKDEBUG,
"SetSpeechVoice -> SpGetDescription : ERROR\n");
404 MMechostr(MSKDEBUG,
"SetSpeechVoice -> Erreur EnumTokens : \n");
413 CComPtr<ISpObjectToken> pToken;
416 if (SUCCEEDED(pVoice->GetVoice(&pToken)))
418 CSpDynamicString dstrText;
420 if (SUCCEEDED(SpGetDescription(pToken, &dstrText)))
422 token = dstrText.CopyToChar();