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.2KB

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