Pas de dépendances
#define COBJMACROS #include <sapi.h> #include <stdio.h> #pragma comment(lib, "sapi.lib") #pragma comment(lib, "ole32.lib") ISpVoice *initvoice(unsigned short volume, long rate) { ISpVoice *pVoice = 0; if(CoCreateInstance(&CLSID_SpVoice, 0, CLSCTX_ALL, &IID_ISpVoice, (void **)&pVoice) >= 0) { ISpVoice_SetVolume(pVoice, volume); ISpVoice_SetRate(pVoice, rate); } return pVoice; } void speak(ISpVoice *pVoice, const wchar_t *text) { printf("%S\n",text); ISpVoice_Speak(pVoice, text, SPF_IS_XML, 0); } void freevoice(ISpVoice *pVoice) { if(pVoice) { ISpVoice_Release(pVoice); pVoice = 0; } } int main(void) { if(CoInitialize(0) >= 0) { ISpVoice *pVoice = initvoice(100, -4); if(pVoice) { speak(pVoice, L"I just test these functions and put it on my samplepage."); speak(pVoice, L"It seems to work, thank you magma for posting these functions of the forum siteduzero."); speak(pVoice, L"Essayons de parler français maintenant, je pense cependant que ça va être mauvais..."); freevoice(pVoice); } CoUninitialize(); } return 0; }
No explanations yet.