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.

speak_lib.h 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. #ifndef SPEAK_LIB_H
  2. #define SPEAK_LIB_H
  3. /***************************************************************************
  4. * Copyright (C) 2005 to 2012 by Jonathan Duddington *
  5. * email: [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. * You should have received a copy of the GNU General Public License *
  18. * along with this program; if not, see: *
  19. * <http://www.gnu.org/licenses/>. *
  20. ***************************************************************************/
  21. /*************************************************************/
  22. /* This is the header file for the library version of espeak */
  23. /* */
  24. /*************************************************************/
  25. #include <stdio.h>
  26. #include <stddef.h>
  27. #if defined(_WIN32) || defined(_WIN64)
  28. #ifdef LIBESPEAK_NG_EXPORT
  29. #define ESPEAK_API __declspec(dllexport)
  30. #else
  31. #define ESPEAK_API __declspec(dllimport)
  32. #endif
  33. #else
  34. #define ESPEAK_API
  35. #endif
  36. #define ESPEAK_API_REVISION 12
  37. /*
  38. Revision 2
  39. Added parameter "options" to eSpeakInitialize()
  40. Revision 3
  41. Added espeakWORDGAP to espeak_PARAMETER
  42. Revision 4
  43. Added flags parameter to espeak_CompileDictionary()
  44. Revision 5
  45. Added espeakCHARS_16BIT
  46. Revision 6
  47. Added macros: espeakRATE_MINIMUM, espeakRATE_MAXIMUM, espeakRATE_NORMAL
  48. Revision 7 24.Dec.2011
  49. Changed espeak_EVENT structure to add id.string[] for phoneme mnemonics.
  50. Added espeakINITIALIZE_PHONEME_IPA option for espeak_Initialize() to report phonemes as IPA names.
  51. Revision 8 26.Apr.2013
  52. Added function espeak_TextToPhonemes().
  53. Revision 9 30.May.2013
  54. Changed function espeak_TextToPhonemes().
  55. Revision 10 29.Aug.2014
  56. Changed phonememode parameter to espeak_TextToPhonemes() and espeak_SetPhonemeTrace
  57. Revision 11 (espeak-ng)
  58. Made ESPEAK_API import/export symbols correctly on Windows.
  59. Revision 12 (espeak-ng)
  60. Exposed espeak_SetPhonemeCallback. This is available in eSpeak, but was not exposed in this header.
  61. */
  62. /********************/
  63. /* Initialization */
  64. /********************/
  65. // values for 'value' in espeak_SetParameter(espeakRATE, value, 0), nominally in words-per-minute
  66. #define espeakRATE_MINIMUM 80
  67. #define espeakRATE_MAXIMUM 450
  68. #define espeakRATE_NORMAL 175
  69. typedef enum {
  70. espeakEVENT_LIST_TERMINATED = 0, // Retrieval mode: terminates the event list.
  71. espeakEVENT_WORD = 1, // Start of word
  72. espeakEVENT_SENTENCE = 2, // Start of sentence
  73. espeakEVENT_MARK = 3, // Mark
  74. espeakEVENT_PLAY = 4, // Audio element
  75. espeakEVENT_END = 5, // End of sentence or clause
  76. espeakEVENT_MSG_TERMINATED = 6, // End of message
  77. espeakEVENT_PHONEME = 7, // Phoneme, if enabled in espeak_Initialize()
  78. espeakEVENT_SAMPLERATE = 8 // internal use, set sample rate
  79. } espeak_EVENT_TYPE;
  80. typedef struct {
  81. espeak_EVENT_TYPE type;
  82. unsigned int unique_identifier; // message identifier (or 0 for key or character)
  83. int text_position; // the number of characters from the start of the text
  84. int length; // word length, in characters (for espeakEVENT_WORD)
  85. int audio_position; // the time in mS within the generated speech output data
  86. int sample; // sample id (internal use)
  87. void* user_data; // pointer supplied by the calling program
  88. union {
  89. int number; // used for WORD and SENTENCE events.
  90. const char *name; // used for MARK and PLAY events. UTF8 string
  91. char string[8]; // used for phoneme names (UTF8). Terminated by a zero byte unless the name needs the full 8 bytes.
  92. } id;
  93. } espeak_EVENT;
  94. /*
  95. When a message is supplied to espeak_synth, the request is buffered and espeak_synth returns. When the message is really processed, the callback function will be repetedly called.
  96. In RETRIEVAL mode, the callback function supplies to the calling program the audio data and an event list terminated by 0 (LIST_TERMINATED).
  97. In PLAYBACK mode, the callback function is called as soon as an event happens.
  98. For example suppose that the following message is supplied to espeak_Synth:
  99. "hello, hello."
  100. * Once processed in RETRIEVAL mode, it could lead to 3 calls of the callback function :
  101. ** Block 1:
  102. <audio data> +
  103. List of events: SENTENCE + WORD + LIST_TERMINATED
  104. ** Block 2:
  105. <audio data> +
  106. List of events: WORD + END + LIST_TERMINATED
  107. ** Block 3:
  108. no audio data
  109. List of events: MSG_TERMINATED + LIST_TERMINATED
  110. * Once processed in PLAYBACK mode, it could lead to 5 calls of the callback function:
  111. ** SENTENCE
  112. ** WORD (call when the sounds are actually played)
  113. ** WORD
  114. ** END (call when the end of sentence is actually played.)
  115. ** MSG_TERMINATED
  116. The MSG_TERMINATED event is the last event. It can inform the calling program to clear the user data related to the message.
  117. So if the synthesis must be stopped, the callback function is called for each pending message with the MSG_TERMINATED event.
  118. A MARK event indicates a <mark> element in the text.
  119. A PLAY event indicates an <audio> element in the text, for which the calling program should play the named sound file.
  120. */
  121. typedef enum {
  122. POS_CHARACTER = 1,
  123. POS_WORD,
  124. POS_SENTENCE
  125. } espeak_POSITION_TYPE;
  126. typedef enum {
  127. /* PLAYBACK mode: plays the audio data, supplies events to the calling program*/
  128. AUDIO_OUTPUT_PLAYBACK,
  129. /* RETRIEVAL mode: supplies audio data and events to the calling program */
  130. AUDIO_OUTPUT_RETRIEVAL,
  131. /* SYNCHRONOUS mode: as RETRIEVAL but doesn't return until synthesis is completed */
  132. AUDIO_OUTPUT_SYNCHRONOUS,
  133. /* Synchronous playback */
  134. AUDIO_OUTPUT_SYNCH_PLAYBACK
  135. } espeak_AUDIO_OUTPUT;
  136. typedef enum {
  137. EE_OK=0,
  138. EE_INTERNAL_ERROR=-1,
  139. EE_BUFFER_FULL=1,
  140. EE_NOT_FOUND=2
  141. } espeak_ERROR;
  142. #define espeakINITIALIZE_PHONEME_EVENTS 0x0001
  143. #define espeakINITIALIZE_PHONEME_IPA 0x0002
  144. #define espeakINITIALIZE_DONT_EXIT 0x8000
  145. #ifdef __cplusplus
  146. extern "C"
  147. #endif
  148. ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output, int buflength, const char *path, int options);
  149. /* Must be called before any synthesis functions are called.
  150. output: the audio data can either be played by eSpeak or passed back by the SynthCallback function.
  151. buflength: The length in mS of sound buffers passed to the SynthCallback function.
  152. Value=0 gives a default of 60mS.
  153. This paramater is only used for AUDIO_OUTPUT_RETRIEVAL and AUDIO_OUTPUT_SYNCHRONOUS modes.
  154. path: The directory which contains the espeak-ng-data directory, or NULL for the default location.
  155. options: bit 0: 1=allow espeakEVENT_PHONEME events.
  156. bit 1: 1= espeakEVENT_PHONEME events give IPA phoneme names, not eSpeak phoneme names
  157. bit 15: 1=don't exit if espeak_data is not found (used for --help)
  158. Returns: sample rate in Hz, or -1 (EE_INTERNAL_ERROR).
  159. */
  160. typedef int (t_espeak_callback)(short*, int, espeak_EVENT*);
  161. #ifdef __cplusplus
  162. extern "C"
  163. #endif
  164. ESPEAK_API void espeak_SetSynthCallback(t_espeak_callback* SynthCallback);
  165. /* Must be called before any synthesis functions are called.
  166. This specifies a function in the calling program which is called when a buffer of
  167. speech sound data has been produced.
  168. The callback function is of the form:
  169. int SynthCallback(short *wav, int numsamples, espeak_EVENT *events);
  170. wav: is the speech sound data which has been produced.
  171. NULL indicates that the synthesis has been completed.
  172. numsamples: is the number of entries in wav. This number may vary, may be less than
  173. the value implied by the buflength parameter given in espeak_Initialize, and may
  174. sometimes be zero (which does NOT indicate end of synthesis).
  175. events: an array of espeak_EVENT items which indicate word and sentence events, and
  176. also the occurance if <mark> and <audio> elements within the text. The list of
  177. events is terminated by an event of type = 0.
  178. Callback returns: 0=continue synthesis, 1=abort synthesis.
  179. */
  180. #ifdef __cplusplus
  181. extern "C"
  182. #endif
  183. ESPEAK_API void espeak_SetUriCallback(int (*UriCallback)(int, const char*, const char*));
  184. /* This function may be called before synthesis functions are used, in order to deal with
  185. <audio> tags. It specifies a callback function which is called when an <audio> element is
  186. encountered and allows the calling program to indicate whether the sound file which
  187. is specified in the <audio> element is available and is to be played.
  188. The callback function is of the form:
  189. int UriCallback(int type, const char *uri, const char *base);
  190. type: type of callback event. Currently only 1= <audio> element
  191. uri: the "src" attribute from the <audio> element
  192. base: the "xml:base" attribute (if any) from the <speak> element
  193. Return: 1=don't play the sound, but speak the text alternative.
  194. 0=place a PLAY event in the event list at the point where the <audio> element
  195. occurs. The calling program can then play the sound at that point.
  196. */
  197. #ifdef __cplusplus
  198. extern "C"
  199. #endif
  200. ESPEAK_API void espeak_SetPhonemeCallback(int (*PhonemeCallback)(const char *));
  201. /********************/
  202. /* Synthesis */
  203. /********************/
  204. #define espeakCHARS_AUTO 0
  205. #define espeakCHARS_UTF8 1
  206. #define espeakCHARS_8BIT 2
  207. #define espeakCHARS_WCHAR 3
  208. #define espeakCHARS_16BIT 4
  209. #define espeakSSML 0x10
  210. #define espeakPHONEMES 0x100
  211. #define espeakENDPAUSE 0x1000
  212. #define espeakKEEP_NAMEDATA 0x2000
  213. #ifdef __cplusplus
  214. extern "C"
  215. #endif
  216. ESPEAK_API espeak_ERROR espeak_Synth(const void *text,
  217. size_t size,
  218. unsigned int position,
  219. espeak_POSITION_TYPE position_type,
  220. unsigned int end_position,
  221. unsigned int flags,
  222. unsigned int* unique_identifier,
  223. void* user_data);
  224. /* Synthesize speech for the specified text. The speech sound data is passed to the calling
  225. program in buffers by means of the callback function specified by espeak_SetSynthCallback(). The command is asynchronous: it is internally buffered and returns as soon as possible. If espeak_Initialize was previously called with AUDIO_OUTPUT_PLAYBACK as argument, the sound data are played by eSpeak.
  226. text: The text to be spoken, terminated by a zero character. It may be either 8-bit characters,
  227. wide characters (wchar_t), or UTF8 encoding. Which of these is determined by the "flags"
  228. parameter.
  229. size: Equal to (or greatrer than) the size of the text data, in bytes. This is used in order
  230. to allocate internal storage space for the text. This value is not used for
  231. AUDIO_OUTPUT_SYNCHRONOUS mode.
  232. position: The position in the text where speaking starts. Zero indicates speak from the
  233. start of the text.
  234. position_type: Determines whether "position" is a number of characters, words, or sentences.
  235. Values:
  236. end_position: If set, this gives a character position at which speaking will stop. A value
  237. of zero indicates no end position.
  238. flags: These may be OR'd together:
  239. Type of character codes, one of:
  240. espeakCHARS_UTF8 UTF8 encoding
  241. espeakCHARS_8BIT The 8 bit ISO-8859 character set for the particular language.
  242. espeakCHARS_AUTO 8 bit or UTF8 (this is the default)
  243. espeakCHARS_WCHAR Wide characters (wchar_t)
  244. espeakCHARS_16BIT 16 bit characters.
  245. espeakSSML Elements within < > are treated as SSML elements, or if not recognised are ignored.
  246. espeakPHONEMES Text within [[ ]] is treated as phonemes codes (in espeak's Kirshenbaum encoding).
  247. espeakENDPAUSE If set then a sentence pause is added at the end of the text. If not set then
  248. this pause is suppressed.
  249. unique_identifier: This must be either NULL, or point to an integer variable to
  250. which eSpeak writes a message identifier number.
  251. eSpeak includes this number in espeak_EVENT messages which are the result of
  252. this call of espeak_Synth().
  253. user_data: a pointer (or NULL) which will be passed to the callback function in
  254. espeak_EVENT messages.
  255. Return: EE_OK: operation achieved
  256. EE_BUFFER_FULL: the command can not be buffered;
  257. you may try after a while to call the function again.
  258. EE_INTERNAL_ERROR.
  259. */
  260. #ifdef __cplusplus
  261. extern "C"
  262. #endif
  263. ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text,
  264. size_t size,
  265. const char *index_mark,
  266. unsigned int end_position,
  267. unsigned int flags,
  268. unsigned int* unique_identifier,
  269. void* user_data);
  270. /* Synthesize speech for the specified text. Similar to espeak_Synth() but the start position is
  271. specified by the name of a <mark> element in the text.
  272. index_mark: The "name" attribute of a <mark> element within the text which specified the
  273. point at which synthesis starts. UTF8 string.
  274. For the other parameters, see espeak_Synth()
  275. Return: EE_OK: operation achieved
  276. EE_BUFFER_FULL: the command can not be buffered;
  277. you may try after a while to call the function again.
  278. EE_INTERNAL_ERROR.
  279. */
  280. #ifdef __cplusplus
  281. extern "C"
  282. #endif
  283. ESPEAK_API espeak_ERROR espeak_Key(const char *key_name);
  284. /* Speak the name of a keyboard key.
  285. If key_name is a single character, it speaks the name of the character.
  286. Otherwise, it speaks key_name as a text string.
  287. Return: EE_OK: operation achieved
  288. EE_BUFFER_FULL: the command can not be buffered;
  289. you may try after a while to call the function again.
  290. EE_INTERNAL_ERROR.
  291. */
  292. #ifdef __cplusplus
  293. extern "C"
  294. #endif
  295. ESPEAK_API espeak_ERROR espeak_Char(wchar_t character);
  296. /* Speak the name of the given character
  297. Return: EE_OK: operation achieved
  298. EE_BUFFER_FULL: the command can not be buffered;
  299. you may try after a while to call the function again.
  300. EE_INTERNAL_ERROR.
  301. */
  302. /***********************/
  303. /* Speech Parameters */
  304. /***********************/
  305. typedef enum {
  306. espeakSILENCE=0, /* internal use */
  307. espeakRATE=1,
  308. espeakVOLUME=2,
  309. espeakPITCH=3,
  310. espeakRANGE=4,
  311. espeakPUNCTUATION=5,
  312. espeakCAPITALS=6,
  313. espeakWORDGAP=7,
  314. espeakOPTIONS=8, // reserved for misc. options. not yet used
  315. espeakINTONATION=9,
  316. espeakRESERVED1=10,
  317. espeakRESERVED2=11,
  318. espeakEMPHASIS, /* internal use */
  319. espeakLINELENGTH, /* internal use */
  320. espeakVOICETYPE, // internal, 1=mbrola
  321. N_SPEECH_PARAM /* last enum */
  322. } espeak_PARAMETER;
  323. typedef enum {
  324. espeakPUNCT_NONE=0,
  325. espeakPUNCT_ALL=1,
  326. espeakPUNCT_SOME=2
  327. } espeak_PUNCT_TYPE;
  328. #ifdef __cplusplus
  329. extern "C"
  330. #endif
  331. ESPEAK_API espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int value, int relative);
  332. /* Sets the value of the specified parameter.
  333. relative=0 Sets the absolute value of the parameter.
  334. relative=1 Sets a relative value of the parameter.
  335. parameter:
  336. espeakRATE: speaking speed in word per minute. Values 80 to 450.
  337. espeakVOLUME: volume in range 0-200 or more.
  338. 0=silence, 100=normal full volume, greater values may produce amplitude compression or distortion
  339. espeakPITCH: base pitch, range 0-100. 50=normal
  340. espeakRANGE: pitch range, range 0-100. 0-monotone, 50=normal
  341. espeakPUNCTUATION: which punctuation characters to announce:
  342. value in espeak_PUNCT_TYPE (none, all, some),
  343. see espeak_GetParameter() to specify which characters are announced.
  344. espeakCAPITALS: announce capital letters by:
  345. 0=none,
  346. 1=sound icon,
  347. 2=spelling,
  348. 3 or higher, by raising pitch. This values gives the amount in Hz by which the pitch
  349. of a word raised to indicate it has a capital letter.
  350. espeakWORDGAP: pause between words, units of 10mS (at the default speed)
  351. Return: EE_OK: operation achieved
  352. EE_BUFFER_FULL: the command can not be buffered;
  353. you may try after a while to call the function again.
  354. EE_INTERNAL_ERROR.
  355. */
  356. #ifdef __cplusplus
  357. extern "C"
  358. #endif
  359. ESPEAK_API int espeak_GetParameter(espeak_PARAMETER parameter, int current);
  360. /* current=0 Returns the default value of the specified parameter.
  361. current=1 Returns the current value of the specified parameter, as set by SetParameter()
  362. */
  363. #ifdef __cplusplus
  364. extern "C"
  365. #endif
  366. ESPEAK_API espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist);
  367. /* Specified a list of punctuation characters whose names are to be spoken when the
  368. value of the Punctuation parameter is set to "some".
  369. punctlist: A list of character codes, terminated by a zero character.
  370. Return: EE_OK: operation achieved
  371. EE_BUFFER_FULL: the command can not be buffered;
  372. you may try after a while to call the function again.
  373. EE_INTERNAL_ERROR.
  374. */
  375. #define espeakPHONEMES_SHOW 0x01
  376. #define espeakPHONEMES_IPA 0x02
  377. #define espeakPHONEMES_TRACE 0x08
  378. #define espeakPHONEMES_MBROLA 0x10
  379. #define espeakPHONEMES_TIE 0x80
  380. #ifdef __cplusplus
  381. extern "C"
  382. #endif
  383. ESPEAK_API void espeak_SetPhonemeTrace(int phonememode, FILE *stream);
  384. /* phonememode: Controls the output of phoneme symbols for the text
  385. bits 0-2:
  386. value=0 No phoneme output (default)
  387. value=1 Output the translated phoneme symbols for the text
  388. value=2 as (1), but produces IPA phoneme names rather than ascii
  389. bit 3: output a trace of how the translation was done (showing the matching rules and list entries)
  390. bit 4: produce pho data for mbrola
  391. bit 7: use (bits 8-23) as a tie within multi-letter phonemes names
  392. bits 8-23: separator character, between phoneme names
  393. stream output stream for the phoneme symbols (and trace). If stream=NULL then it uses stdout.
  394. */
  395. #ifdef __cplusplus
  396. extern "C"
  397. #endif
  398. ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode, int phonememode);
  399. /* Translates text into phonemes. Call espeak_SetVoiceByName() first, to select a language.
  400. It returns a pointer to a character string which contains the phonemes for the text up to
  401. end of a sentence, or comma, semicolon, colon, or similar punctuation.
  402. textptr: The address of a pointer to the input text which is terminated by a zero character.
  403. On return, the pointer has been advanced past the text which has been translated, or else set
  404. to NULL to indicate that the end of the text has been reached.
  405. textmode: Type of character codes, one of:
  406. espeakCHARS_UTF8 UTF8 encoding
  407. espeakCHARS_8BIT The 8 bit ISO-8859 character set for the particular language.
  408. espeakCHARS_AUTO 8 bit or UTF8 (this is the default)
  409. espeakCHARS_WCHAR Wide characters (wchar_t)
  410. espeakCHARS_16BIT 16 bit characters.
  411. phoneme_mode
  412. bit 1: 0=eSpeak's ascii phoneme names, 1= International Phonetic Alphabet (as UTF-8 characters).
  413. bit 7: use (bits 8-23) as a tie within multi-letter phonemes names
  414. bits 8-23: separator character, between phoneme names
  415. */
  416. #ifdef __cplusplus
  417. extern "C"
  418. #endif
  419. ESPEAK_API void espeak_CompileDictionary(const char *path, FILE *log, int flags);
  420. /* Compile pronunciation dictionary for a language which corresponds to the currently
  421. selected voice. The required voice should be selected before calling this function.
  422. path: The directory which contains the language's '_rules' and '_list' files.
  423. 'path' should end with a path separator character ('/').
  424. log: Stream for error reports and statistics information. If log=NULL then stderr will be used.
  425. flags: Bit 0: include source line information for debug purposes (This is displayed with the
  426. -X command line option).
  427. */
  428. /***********************/
  429. /* Voice Selection */
  430. /***********************/
  431. // voice table
  432. typedef struct {
  433. const char *name; // a given name for this voice. UTF8 string.
  434. const char *languages; // list of pairs of (byte) priority + (string) language (and dialect qualifier)
  435. const char *identifier; // the filename for this voice within espeak-ng-data/voices
  436. unsigned char gender; // 0=none 1=male, 2=female,
  437. unsigned char age; // 0=not specified, or age in years
  438. unsigned char variant; // only used when passed as a parameter to espeak_SetVoiceByProperties
  439. unsigned char xx1; // for internal use
  440. int score; // for internal use
  441. void *spare; // for internal use
  442. } espeak_VOICE;
  443. /* Note: The espeak_VOICE structure is used for two purposes:
  444. 1. To return the details of the available voices.
  445. 2. As a parameter to espeak_SetVoiceByProperties() in order to specify selection criteria.
  446. In (1), the "languages" field consists of a list of (UTF8) language names for which this voice
  447. may be used, each language name in the list is terminated by a zero byte and is also preceded by
  448. a single byte which gives a "priority" number. The list of languages is terminated by an
  449. additional zero byte.
  450. A language name consists of a language code, optionally followed by one or more qualifier (dialect)
  451. names separated by hyphens (eg. "en-uk"). A voice might, for example, have languages "en-uk" and
  452. "en". Even without "en" listed, voice would still be selected for the "en" language (because
  453. "en-uk" is related) but at a lower priority.
  454. The priority byte indicates how the voice is preferred for the language. A low number indicates a
  455. more preferred voice, a higher number indicates a less preferred voice.
  456. In (2), the "languages" field consists simply of a single (UTF8) language name, with no preceding
  457. priority byte.
  458. */
  459. #ifdef __cplusplus
  460. extern "C"
  461. #endif
  462. ESPEAK_API const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec);
  463. /* Reads the voice files from espeak-ng-data/voices and creates an array of espeak_VOICE pointers.
  464. The list is terminated by a NULL pointer
  465. If voice_spec is NULL then all voices are listed.
  466. If voice spec is given, then only the voices which are compatible with the voice_spec
  467. are listed, and they are listed in preference order.
  468. */
  469. #ifdef __cplusplus
  470. extern "C"
  471. #endif
  472. ESPEAK_API espeak_ERROR espeak_SetVoiceByFile(const char *filename);
  473. /* Loads a voice given the file path. Language is not considered.
  474. "filename" is a UTF8 string.
  475. Return: EE_OK: operation achieved
  476. EE_BUFFER_FULL: the command can not be buffered;
  477. you may try after a while to call the function again.
  478. EE_INTERNAL_ERROR.
  479. */
  480. #ifdef __cplusplus
  481. extern "C"
  482. #endif
  483. ESPEAK_API espeak_ERROR espeak_SetVoiceByName(const char *name);
  484. /* Searches for a voice with a matching "name" field. Language is not considered.
  485. "name" is a UTF8 string.
  486. Return: EE_OK: operation achieved
  487. EE_BUFFER_FULL: the command can not be buffered;
  488. you may try after a while to call the function again.
  489. EE_INTERNAL_ERROR.
  490. */
  491. #ifdef __cplusplus
  492. extern "C"
  493. #endif
  494. ESPEAK_API espeak_ERROR espeak_SetVoiceByProperties(espeak_VOICE *voice_spec);
  495. /* An espeak_VOICE structure is used to pass criteria to select a voice. Any of the following
  496. fields may be set:
  497. name NULL, or a voice name
  498. languages NULL, or a single language string (with optional dialect), eg. "en-uk", or "en"
  499. gender 0=not specified, 1=male, 2=female
  500. age 0=not specified, or an age in years
  501. variant After a list of candidates is produced, scored and sorted, "variant" is used to index
  502. that list and choose a voice.
  503. variant=0 takes the top voice (i.e. best match). variant=1 takes the next voice, etc
  504. */
  505. #ifdef __cplusplus
  506. extern "C"
  507. #endif
  508. ESPEAK_API espeak_VOICE *espeak_GetCurrentVoice(void);
  509. /* Returns the espeak_VOICE data for the currently selected voice.
  510. This is not affected by temporary voice changes caused by SSML elements such as <voice> and <s>
  511. */
  512. #ifdef __cplusplus
  513. extern "C"
  514. #endif
  515. ESPEAK_API espeak_ERROR espeak_Cancel(void);
  516. /* Stop immediately synthesis and audio output of the current text. When this
  517. function returns, the audio output is fully stopped and the synthesizer is ready to
  518. synthesize a new message.
  519. Return: EE_OK: operation achieved
  520. EE_INTERNAL_ERROR.
  521. */
  522. #ifdef __cplusplus
  523. extern "C"
  524. #endif
  525. ESPEAK_API int espeak_IsPlaying(void);
  526. /* Returns 1 if audio is played, 0 otherwise.
  527. */
  528. #ifdef __cplusplus
  529. extern "C"
  530. #endif
  531. ESPEAK_API espeak_ERROR espeak_Synchronize(void);
  532. /* This function returns when all data have been spoken.
  533. Return: EE_OK: operation achieved
  534. EE_INTERNAL_ERROR.
  535. */
  536. #ifdef __cplusplus
  537. extern "C"
  538. #endif
  539. ESPEAK_API espeak_ERROR espeak_Terminate(void);
  540. /* last function to be called.
  541. Return: EE_OK: operation achieved
  542. EE_INTERNAL_ERROR.
  543. */
  544. #ifdef __cplusplus
  545. extern "C"
  546. #endif
  547. ESPEAK_API const char *espeak_Info(const char **path_data);
  548. /* Returns the version number string.
  549. path_data returns the path to espeak_data
  550. */
  551. #endif