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