eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

espeak_test_lib.c 860B

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