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.

api.c 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright (C) 2017 Reece H. Dunn
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write see:
  16. * <http://www.gnu.org/licenses/>.
  17. */
  18. #include "config.h"
  19. #include <assert.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #include <espeak-ng/espeak_ng.h>
  23. #include <espeak-ng/speak_lib.h>
  24. #include <espeak-ng/encoding.h>
  25. #include "speech.h"
  26. #include "phoneme.h"
  27. #include "synthesize.h"
  28. #include "translate.h"
  29. void
  30. test_espeak_terminate_without_initialize()
  31. {
  32. printf("testing espeak_Terminate without espeak_Initialize\n");
  33. assert(event_list == NULL);
  34. assert(translator == NULL);
  35. assert(espeak_Terminate() == EE_OK);
  36. assert(event_list == NULL);
  37. assert(translator == NULL);
  38. }
  39. void
  40. test_espeak_initialize()
  41. {
  42. printf("testing espeak_Initialize\n");
  43. assert(event_list == NULL);
  44. assert(translator == NULL);
  45. assert(espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 0, NULL, 0) == 22050);
  46. assert(event_list != NULL);
  47. assert(translator == NULL);
  48. assert(espeak_Terminate() == EE_OK);
  49. assert(event_list == NULL);
  50. assert(translator == NULL);
  51. }
  52. void
  53. test_espeak_synth()
  54. {
  55. printf("testing espeak_Synth\n");
  56. assert(event_list == NULL);
  57. assert(translator == NULL);
  58. assert(espeak_Initialize(AUDIO_OUTPUT_RETRIEVAL, 0, NULL, 0) == 22050);
  59. assert(event_list != NULL);
  60. assert(translator == NULL);
  61. const char *test = "One two three.";
  62. assert(espeak_Synth(test, strlen(test)+1, 0, POS_CHARACTER, 0, espeakCHARS_AUTO, NULL, NULL) == EE_OK);
  63. assert(translator != NULL);
  64. assert(espeak_Synchronize() == EE_OK);
  65. assert(translator != NULL);
  66. assert(espeak_Terminate() == EE_OK);
  67. assert(event_list == NULL);
  68. assert(translator == NULL);
  69. }
  70. int
  71. main(int argc, char **argv)
  72. {
  73. test_espeak_terminate_without_initialize();
  74. test_espeak_initialize();
  75. test_espeak_synth();
  76. test_espeak_synth(); // Check that this does not crash when run a second time.
  77. return EXIT_SUCCESS;
  78. }