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.

mbrowrap.h 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * mbrowrap -- A wrapper library around the mbrola binary
  3. * providing a subset of the API from the Windows mbrola DLL.
  4. *
  5. * Copyright (C) 2010 by Nicolas Pitre <[email protected]>
  6. * Copyright (C) 2016 Reece H. Dunn
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #ifndef MBROWRAP_H
  19. #define MBROWRAP_H
  20. #ifdef __cplusplus
  21. extern "C"
  22. {
  23. #endif
  24. #if defined(_WIN32) || defined(_WIN64)
  25. typedef void (WINAPI *PROCVV)(void);
  26. typedef void (WINAPI *PROCVI)(int);
  27. typedef void (WINAPI *PROCVF)(float);
  28. typedef int (WINAPI *PROCIV)();
  29. typedef int (WINAPI *PROCIC)(char *);
  30. typedef int (WINAPI *PROCISI)(short *, int);
  31. typedef char * (WINAPI *PROCVCI)(char *, int);
  32. PROCIC init_MBR;
  33. PROCIC write_MBR;
  34. PROCIV flush_MBR;
  35. PROCISI read_MBR;
  36. PROCVV close_MBR;
  37. PROCVV reset_MBR;
  38. PROCIV lastError_MBR;
  39. PROCVCI lastErrorStr_MBR;
  40. PROCVI setNoError_MBR;
  41. PROCIV getFreq_MBR;
  42. PROCVF setVolumeRatio_MBR;
  43. BOOL load_MBR();
  44. void unload_MBR();
  45. #else
  46. /*
  47. * Initialize mbrola. The 'voice_path' argument must contain the
  48. * path and file name to the mbrola voice database to be used. Returned
  49. * value is 0 on success, or an error code otherwise (currently only -1
  50. * is returned. If not successful, lastErrorStr_MBR() will provide the
  51. * error reason. If this is successful, then close_MBR() must be called
  52. * before init_MBR() can be called again.
  53. */
  54. int init_MBR(const char *voice_path);
  55. /*
  56. * Stop mbrola and release any resources. It is necessary to call
  57. * this after a successful call to init_MBR() before init_MBR() can be
  58. * called again.
  59. */
  60. void close_MBR(void);
  61. /*
  62. * Stop any ongoing processing and flush all buffers. After this call
  63. * any synthesis request will start afresh. A non-zero value is returned
  64. * on success, or 0 on failure. If not successful, lastErrorStr_MBR() will
  65. * provide the error reason.
  66. */
  67. int reset_MBR();
  68. /*
  69. * Return at most 'nb_samples' audio samples into 'buffer'. The returned
  70. * value is the actual number of samples returned, or -1 on error.
  71. * If not successful, lastErrorStr_MBR() will provide the error reason.
  72. * Samples are always 16-bit little endian.
  73. */
  74. int read_MBR(void *buffer, int nb_samples);
  75. /*
  76. * Write a NULL terminated string of phoneme in the input buffer.
  77. * Return the number of chars actually written, or -1 on error.
  78. * If not successful, lastErrorStr_MBR() will provide the error reason.
  79. */
  80. int write_MBR(const char *data);
  81. /*
  82. * Send a flush command to the mbrola input stream.
  83. * This is currently similar to write_MBR("#\n"). Return 1 on success
  84. * or 0 on failure. If not successful, lastErrorStr_MBR() will provide
  85. * the error reason.
  86. */
  87. int flush_MBR(void);
  88. /*
  89. * Return the audio sample frequency of the used voice database.
  90. */
  91. int getFreq_MBR(void);
  92. /*
  93. * Overall volume.
  94. */
  95. void setVolumeRatio_MBR(float value);
  96. /*
  97. * Copy into 'buffer' at most 'bufsize' bytes from the latest error
  98. * message. This may also contain non-fatal errors from mbrola. The
  99. * returned value is the actual number of bytes copied. When no error
  100. * message is pending then an empty string is returned. Consecutive
  101. * calls to lastErrorStr_MBR() will return the same message unless it
  102. * is explicitly cleared with resetError_MBR().
  103. */
  104. int lastErrorStr_MBR(char *buffer, int bufsize);
  105. /*
  106. * Clear any pending error message.
  107. */
  108. void resetError_MBR(void);
  109. /*
  110. * Tolerance to missing diphones (always active so this is ignored)
  111. */
  112. static inline void setNoError_MBR(int no_error)
  113. {
  114. (void)no_error; // unused
  115. }
  116. #endif
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120. #endif