1 #include <speak_lib.h>
2 
3 #ifdef PLATFORM_WINDOWS
4 #include <windows.h>
5 #define sleep(x) Sleep(1000*x)
6 #endif
7 
callback(short * wav,int num,espeak_EVENT * pEv)8 int callback(short* wav, int num, espeak_EVENT *pEv)
9 {
10   int cEv = 0;
11   while (pEv->type) {
12     cEv++;
13     pEv++;
14 	}
15   printf("callback, events: %d\n", cEv);
16   return 0;
17 }
18 
main()19 main()
20 {
21   int nRate = espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 10000, NULL, 0);
22   printf("nRate: %d\n", nRate);
23   if (nRate < 0)
24     return;
25   espeak_SetSynthCallback(callback);
26   espeak_SetParameter(espeakRATE, 175, 0);
27   int rv;
28   rv = espeak_Char('c');
29   printf("rv: %d\n", rv);
30   const char* sText = "tralalalallala";
31   rv = espeak_Synth(sText, 100, 0, POS_CHARACTER, 0, 0, 0, 0);
32   printf("rv: %d (full: %d, internal: %d)\n",
33     rv, EE_BUFFER_FULL, EE_INTERNAL_ERROR);
34   sleep(2); // 2 seconds
35   puts("slept");
36   espeak_Terminate();
37 }
38