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.

com_google_espeakengine.cpp 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /*
  2. * Copyright (C) 2008 Google Inc.
  3. * Copyright (C) 2012 Reece H. Dunn
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /*
  18. * This file contains the TtsEngine implementation for the eSpeak
  19. * Text-to-Speech engine.
  20. *
  21. * Android Version: 2.2 (Froyo)
  22. * API Version: 8
  23. */
  24. #include <stdio.h>
  25. #include <unistd.h>
  26. #include <stdlib.h>
  27. #define LOG_TAG "eSpeak Engine"
  28. #define DEBUG true
  29. #include <speak_lib.h>
  30. #include <TtsEngine.h>
  31. #include <Log.h>
  32. /*
  33. * This is the Manager layer. It sits on top of the native eSpeak engine
  34. * and provides the interface to the defined Google TTS engine API.
  35. * The Google engine API is the boundary to allow a TTS engine to be swapped.
  36. * The Manager layer also provide the SSML tag interpretation.
  37. * The supported SSML tags are mapped to corresponding tags natively supported by eSpeak.
  38. * Native eSpeak functions always begin with espeak_XXX.
  39. *
  40. * Only a subset of SSML 1.0 tags are supported.
  41. * Some SSML tags involve significant complexity.
  42. * If the language is changed through an SSML tag, there is a latency for the load.
  43. */
  44. using namespace android;
  45. const char *ESPEAK_DIRECTORY = "espeak-data";
  46. const char *eSpeakBaseResources[] = {"intonations", "phondata", "phonindex", "phontab",
  47. "en_dict", "voices/en/en-us" };
  48. const int NUM_BASE_RESOURCES = 6;
  49. // Format is {espeak voice, iso3 code, name}
  50. const char *eSpeakSupportedVoices[][3] = {
  51. {"en-us", "eng", "English"},
  52. {"en-us", "eng-USA", "English (US)"},
  53. {"en", "eng-GBR", "English (UK)"},
  54. {"en-sc", "eng-GBR-sc", "English (Scottish)"},
  55. {"en-n", "eng-GBR-n", "English (Northern UK)"},
  56. {"en-rp", "eng-GBR-rp", "English (Received Pronunciation)"},
  57. {"en-wm", "eng-GBR-wm", "English (West Midlands)"},
  58. {"af", "afr", "Afrikaans"},
  59. {"bs", "bos", "Bosnian"},
  60. {"ca", "cat", "Catalan"},
  61. {"cs", "ces", "Czech"},
  62. {"da", "dan", "Danish"},
  63. {"de", "deu", "German"},
  64. {"el", "ell", "Greek"},
  65. {"eo", "epo", "Esperanto"},
  66. {"es", "spa", "Spanish"},
  67. {"es-la", "spa-MEX", "Spanish (Latin America)"},
  68. {"fi", "fin", "Finnish"},
  69. {"fr", "fra", "French"},
  70. {"hr", "hrv", "Croatian"},
  71. {"hu", "hun", "Hungarian"},
  72. {"it", "ita", "Italian"},
  73. {"kn", "kan", "Kannada"},
  74. {"ku", "kur", "Kurdish"},
  75. {"lv", "lav", "Latvian"},
  76. {"nl", "nld", "Dutch"},
  77. {"pl", "pol", "Polish"},
  78. {"pt", "por", "Portuguese (Brazil)"},
  79. {"pt", "por-BRA", "Portuguese (Brazil)"},
  80. {"pt-pt", "por-PRT", "Portuguese"},
  81. {"ro", "ron", "Romanian"},
  82. {"sk", "slk", "Slovak"},
  83. {"sr", "srp", "Serbian"},
  84. {"sv", "swe", "Swedish"},
  85. {"sw", "swa", "Swahili"},
  86. {"ta", "tam", "Tamil"},
  87. {"tr", "tur", "Turkish"},
  88. {"zh", "zho", "Chinese (Mandarin)"},
  89. {"cy", "cym", "Welsh"},
  90. {"hi", "hin", "Hindi"},
  91. {"hy", "hye", "Armenian"},
  92. {"id", "ind", "Indonesian"},
  93. {"is", "isl", "Icelandic"},
  94. {"ka", "kat", "Georgian"},
  95. {"la", "lat", "Latin"},
  96. {"mk", "mkd", "Macedonian"},
  97. {"no", "nor", "Norwegian"},
  98. {"ru", "rus", "Russian"},
  99. {"sq", "sqi", "Albanian"},
  100. {"vi", "vie", "Vietnamese"},
  101. {"zh-yue", "zho-HKG", "Chinese (Cantonese)"},
  102. {"grc", "grc", "Ancient Greek"},
  103. {"jbo", "jbo", "Lojban"},
  104. {"nci", "nci", "Nahuatl (Classical)"},
  105. {"pap", "pap", "Papiamento" }
  106. };
  107. const int NUM_SUPPORTED_VOICES = 55;
  108. // Callback to the TTS API
  109. synthDoneCB_t *ttsSynthDoneCBPointer;
  110. char *currentLanguage = (char *) "en-us";
  111. char *currentRate = (char *) "150";
  112. char *eSpeakDataPath = NULL;
  113. char currentLang[10];
  114. char currentCountry[10];
  115. char currentVariant[10];
  116. bool hasInitialized = false;
  117. /* Functions internal to the eSpeak engine wrapper */
  118. static void setSpeechRate(int speechRate) {
  119. espeak_ERROR err = espeak_SetParameter(espeakRATE, speechRate, 0);
  120. }
  121. /* Functions exposed to the TTS API */
  122. /* Callback from espeak. Should call back to the TTS API */
  123. static int eSpeakCallback(short *wav, int numsamples, espeak_EVENT *events) {
  124. LOGI("Callback with %d samples", numsamples);
  125. int8_t * castedWav = (int8_t *) wav;
  126. size_t bufferSize = 0;
  127. if (numsamples < 1) {
  128. int8_t silenceData[] = { 0, 0 };
  129. size_t silenceBufferSize = sizeof(silenceData)/sizeof(silenceData[0]);
  130. int8_t *silence = silenceData; // Passing in an empty buffer can cause a crash.
  131. ttsSynthDoneCBPointer(events->user_data, 22050, TTS_AUDIO_FORMAT_PCM_16_BIT, 1, silence,
  132. silenceBufferSize, TTS_SYNTH_DONE);
  133. return 1;
  134. }
  135. bufferSize = numsamples * sizeof(short);
  136. ttsSynthDoneCBPointer(events->user_data, 22050, TTS_AUDIO_FORMAT_PCM_16_BIT, 1, castedWav,
  137. bufferSize, TTS_SYNTH_PENDING);
  138. return 0; // continue synthesis (1 is to abort)
  139. }
  140. static bool fileExists(char *fileName) {
  141. if (DEBUG) LOGV("%s", __FUNCTION__);
  142. FILE *file = fopen(fileName, "r");
  143. if (file == NULL) {
  144. return false;
  145. } else {
  146. fclose(file);
  147. return true;
  148. }
  149. }
  150. static bool hasBaseResources() {
  151. if (DEBUG) LOGV("%s", __FUNCTION__);
  152. char filename[255];
  153. for (int i = 0; i < NUM_BASE_RESOURCES; i++) {
  154. sprintf(filename, "%s/%s/%s", eSpeakDataPath, ESPEAK_DIRECTORY, eSpeakBaseResources[i]);
  155. if (!fileExists(filename)) {
  156. LOGE("Missing resource: %s", filename);
  157. return false;
  158. }
  159. }
  160. return true;
  161. }
  162. /* Google Engine API function implementations */
  163. tts_result attemptInit() {
  164. if (DEBUG) LOGV("%s", __FUNCTION__);
  165. if (hasInitialized) {
  166. return TTS_SUCCESS;
  167. }
  168. if (!hasBaseResources()) {
  169. return TTS_FAILURE;
  170. }
  171. // TODO Make sure that the speech data is loaded in
  172. // the directory /sdcard/espeak-data before calling this.
  173. int sampleRate = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS, 4096, eSpeakDataPath, 0);
  174. if (sampleRate <= 0) {
  175. LOGE("eSpeak initialization failed!");
  176. return TTS_FAILURE;
  177. }
  178. espeak_SetSynthCallback(eSpeakCallback);
  179. espeak_VOICE voice;
  180. memset(&voice, 0, sizeof(espeak_VOICE)); // Zero out the voice first
  181. const char *langNativeString = "en-us"; //Default to US English
  182. voice.languages = langNativeString;
  183. voice.variant = 0;
  184. espeak_SetVoiceByProperties(&voice);
  185. hasInitialized = true;
  186. return TTS_SUCCESS;
  187. }
  188. /** init
  189. * Allocates eSpeak memory block and initializes the eSpeak system.
  190. * synthDoneCBPtr - Pointer to callback function which will receive generated samples
  191. * config - the engine configuration parameters, not used here
  192. * return tts_result
  193. */
  194. tts_result TtsEngine::init(synthDoneCB_t synthDoneCBPtr, const char *engineConfig) {
  195. if (DEBUG) LOGV("%s", __FUNCTION__);
  196. ttsSynthDoneCBPointer = synthDoneCBPtr;
  197. hasInitialized = false;
  198. if ((engineConfig != NULL) && (strlen(engineConfig) > 0)) {
  199. eSpeakDataPath = (char *) malloc(strlen(engineConfig));
  200. strcpy(eSpeakDataPath, engineConfig);
  201. } else {
  202. eSpeakDataPath = NULL;
  203. LOGE("Data path not specified!");
  204. return TTS_FAILURE;
  205. }
  206. return attemptInit();
  207. }
  208. /** shutdown
  209. * Unloads all eSpeak resources; terminates eSpeak system and frees eSpeak memory block.
  210. * return tts_result
  211. */
  212. tts_result TtsEngine::shutdown(void) {
  213. if (DEBUG) LOGV("%s", __FUNCTION__);
  214. if (eSpeakDataPath != NULL) {
  215. free(eSpeakDataPath);
  216. }
  217. espeak_Terminate();
  218. return TTS_SUCCESS;
  219. }
  220. tts_result TtsEngine::loadLanguage(const char *lang, const char *country, const char *variant) {
  221. if (DEBUG) LOGV("loadLanguage(\"%s\", \"%s\", \"%s\")", lang, country, variant);
  222. return TTS_FAILURE;
  223. }
  224. tts_support_result isLanguageSupported(const char *lang, const char *country, const char *variant,
  225. int *pindex) {
  226. if (DEBUG) LOGV("isLanguageSupported(\"%s\", \"%s\", \"%s\")", lang, country, variant);
  227. if ((lang == NULL) || (strlen(lang) == 0)) {
  228. LOGE("TtsEngine::isLanguageAvailable called with no language");
  229. return TTS_LANG_NOT_SUPPORTED;
  230. }
  231. if (pindex != NULL) {
  232. *pindex = -1;
  233. }
  234. int langIndex = -1;
  235. int countryIndex = -1;
  236. int variantIndex = -1;
  237. if (strlen(lang) == 3) {
  238. for (int i = 0; i < NUM_SUPPORTED_VOICES; i++) {
  239. if (strncmp(lang, eSpeakSupportedVoices[i][1], 3) == 0) {
  240. LOGI("Found ISO3 language at index %d", i);
  241. langIndex = i;
  242. break;
  243. }
  244. }
  245. } else if (strlen(lang) == 2) {
  246. for (int i = 0; i < NUM_SUPPORTED_VOICES; i++) {
  247. if (strncmp(lang, eSpeakSupportedVoices[i][0], 2) == 0) {
  248. LOGI("Found ISO2 language at index %d", i);
  249. langIndex = i;
  250. break;
  251. }
  252. }
  253. }
  254. if (langIndex < 0) {
  255. LOGV("TtsEngine::isLanguageAvailable called with unsupported language");
  256. return TTS_LANG_NOT_SUPPORTED;
  257. }
  258. if ((country == NULL) || (strlen(country) == 0)) {
  259. // TODO: Check whether resources are available for this language.
  260. if (pindex != NULL) {
  261. *pindex = langIndex;
  262. }
  263. LOGI("No country specified, language is available");
  264. return TTS_LANG_AVAILABLE;
  265. }
  266. char lang_country[10];
  267. sprintf(lang_country, "%s-%s", lang, country);
  268. // Find country
  269. if (strlen(country) == 3) {
  270. for (int i = langIndex; i < NUM_SUPPORTED_VOICES; i++) {
  271. if ((strcmp(lang_country, eSpeakSupportedVoices[i][1]) == 0)) {
  272. LOGI("Found ISO3 country at index %d", i);
  273. countryIndex = i;
  274. break;
  275. }
  276. }
  277. } else if (strlen(country) == 2) {
  278. for (int i = langIndex; i < NUM_SUPPORTED_VOICES; i++) {
  279. if ((strcmp(lang_country, eSpeakSupportedVoices[i][0]) == 0)) {
  280. LOGI("Found ISO2 country at index %d", i);
  281. countryIndex = i;
  282. break;
  283. }
  284. }
  285. }
  286. if (countryIndex < 0) {
  287. if (pindex != NULL) {
  288. *pindex = langIndex;
  289. }
  290. LOGI("No country found, language is available");
  291. return TTS_LANG_AVAILABLE;
  292. }
  293. if ((variant == NULL) || (strlen(variant) == 0)) {
  294. if (pindex != NULL) {
  295. *pindex = countryIndex;
  296. }
  297. LOGI("No variant specified, language and country are available");
  298. return TTS_LANG_COUNTRY_AVAILABLE;
  299. }
  300. char lang_country_variant[15];
  301. sprintf(lang_country_variant, "%s-%s-%s", lang, country, variant);
  302. // Find variant
  303. for (int i = countryIndex; i < NUM_SUPPORTED_VOICES; i++) {
  304. if ((strcmp(lang_country_variant, eSpeakSupportedVoices[i][1]) == 0)) {
  305. LOGI("Found variant at index %d", i);
  306. variantIndex = i;
  307. break;
  308. }
  309. }
  310. if (variantIndex < 0) {
  311. if (pindex != NULL) {
  312. *pindex = countryIndex;
  313. }
  314. LOGI("No variant found, language and country are available");
  315. return TTS_LANG_COUNTRY_AVAILABLE;
  316. }
  317. if (pindex != NULL) {
  318. *pindex = variantIndex;
  319. }
  320. LOGI("Language, country, and variant are available");
  321. return TTS_LANG_COUNTRY_VAR_AVAILABLE;
  322. }
  323. tts_result TtsEngine::setLanguage(const char *lang, const char *country, const char *variant) {
  324. if (DEBUG) LOGV("setLanguage(\"%s\", \"%s\", \"%s\")", lang, country, variant);
  325. // Make sure the engine is initialized!
  326. attemptInit();
  327. int index = -1;
  328. isLanguageSupported(lang, country, variant, &index);
  329. if (index < 0) {
  330. LOGE("setLanguage called with unsupported language");
  331. return TTS_FAILURE;
  332. }
  333. strcpy(currentLang, lang);
  334. strcpy(currentCountry, country);
  335. strcpy(currentVariant, variant);
  336. char espeakLangStr[7];
  337. strcpy(espeakLangStr, eSpeakSupportedVoices[index][0]);
  338. espeak_VOICE voice;
  339. memset(&voice, 0, sizeof(espeak_VOICE)); // Zero out the voice first
  340. voice.variant = 0;
  341. voice.languages = espeakLangStr;
  342. espeak_ERROR err = espeak_SetVoiceByProperties(&voice);
  343. currentLanguage = new char[strlen(lang)];
  344. strcpy(currentLanguage, lang);
  345. if (err != EE_OK) {
  346. LOGE("Error code %d when setting voice properties!", err);
  347. return TTS_FAILURE;
  348. }
  349. return TTS_SUCCESS;
  350. }
  351. tts_support_result TtsEngine::isLanguageAvailable(const char *lang, const char *country,
  352. const char *variant) {
  353. if (DEBUG) LOGV("%s", __FUNCTION__);
  354. return isLanguageSupported(lang, country, variant, NULL);
  355. }
  356. tts_result TtsEngine::getLanguage(char *language, char *country, char *variant) {
  357. if (DEBUG) LOGV("%s", __FUNCTION__);
  358. strcpy(language, currentLang);
  359. strcpy(country, currentCountry);
  360. strcpy(variant, currentVariant);
  361. return TTS_SUCCESS;
  362. }
  363. /** setAudioFormat
  364. * sets the audio format to use for synthesis, returns what is actually used.
  365. * @encoding - reference to encoding format
  366. * @rate - reference to sample rate
  367. * @channels - reference to number of channels
  368. * return tts_result
  369. * */
  370. tts_result TtsEngine::setAudioFormat(tts_audio_format& encoding, uint32_t& rate, int& channels) {
  371. LOGE("setAudioFormat(%d, %d, %d) is unsupported", encoding, rate, channels);
  372. // TODO: Fix this!
  373. return TTS_SUCCESS;
  374. }
  375. // Sets the property with the specified value
  376. tts_result TtsEngine::setProperty(const char *property, const char *value, const size_t size) {
  377. if (DEBUG) LOGV("setProperty(\"%s\", \"%s\", %d)", property, value, size);
  378. /* Set a specific property for the engine.
  379. Supported properties include: language (locale), rate, pitch, volume. */
  380. /* Sanity check */
  381. if (property == NULL) {
  382. LOGE("setProperty called with property NULL");
  383. return TTS_PROPERTY_UNSUPPORTED;
  384. }
  385. if (value == NULL) {
  386. LOGE("setProperty called with value NULL");
  387. return TTS_VALUE_INVALID;
  388. }
  389. espeak_ERROR result;
  390. if (strncmp(property, "language", 8) == 0) {
  391. // TODO: Set this property
  392. result = EE_OK;
  393. } else if (strncmp(property, "rate", 4) == 0) {
  394. int rate = atoi(value) * espeak_GetParameter(espeakRATE, 0) / 100;
  395. if (DEBUG) LOGV("setProperty rate : rate=%s, wpm=%d", value, rate);
  396. result = espeak_SetParameter(espeakRATE, rate, 0);
  397. } else if (strncmp(property, "pitch", 5) == 0) {
  398. int pitch = atoi(value);
  399. // The values of pitch from android range from 50 - 200, with 100 being normal.
  400. // The values espeak supports are from 0 - 100, with 50 being normal.
  401. // Therefore, halve the value to get the value that espeak supports:
  402. pitch = pitch / 2;
  403. if (DEBUG) LOGV("setProperty pitch : pitch=%d", pitch);
  404. result = espeak_SetParameter(espeakPITCH, pitch, 0);
  405. } else if (strncmp(property, "volume", 6) == 0) {
  406. int volume = atoi(value);
  407. result = espeak_SetParameter(espeakVOLUME, volume, 0);
  408. } else {
  409. return TTS_PROPERTY_UNSUPPORTED;
  410. }
  411. if (result == EE_OK) {
  412. return TTS_SUCCESS;
  413. } else {
  414. return TTS_FAILURE;
  415. }
  416. }
  417. // Sets the property with the specified value
  418. tts_result TtsEngine::getProperty(const char *property, char *value, size_t *iosize) {
  419. if (DEBUG) LOGV("getProperty(\"%s\", ...)", property);
  420. /* Get the property for the engine.
  421. This property was previously set by setProperty or by default. */
  422. /* sanity check */
  423. if (property == NULL) {
  424. LOGE("getProperty called with property NULL");
  425. return TTS_PROPERTY_UNSUPPORTED;
  426. }
  427. if (value == NULL) {
  428. LOGE("getProperty called with value NULL");
  429. return TTS_VALUE_INVALID;
  430. }
  431. if (strncmp(property, "language", 8) == 0) {
  432. if (currentLanguage == NULL) {
  433. strcpy(value, "");
  434. } else {
  435. if (*iosize < strlen(currentLanguage)+1) {
  436. *iosize = strlen(currentLanguage) + 1;
  437. return TTS_PROPERTY_SIZE_TOO_SMALL;
  438. }
  439. strcpy(value, currentLanguage);
  440. }
  441. return TTS_SUCCESS;
  442. } else if (strncmp(property, "rate", 4) == 0) {
  443. int rate = espeak_GetParameter(espeakRATE, 1) * 100 / espeak_GetParameter(espeakRATE, 0);
  444. char tmprate[4];
  445. sprintf(tmprate, "%d", rate);
  446. if (*iosize < strlen(tmprate)+1) {
  447. *iosize = strlen(tmprate) + 1;
  448. return TTS_PROPERTY_SIZE_TOO_SMALL;
  449. }
  450. strcpy(value, tmprate);
  451. return TTS_SUCCESS;
  452. } else if (strncmp(property, "pitch", 5) == 0) {
  453. char tmppitch[4];
  454. sprintf(tmppitch, "%d", (espeak_GetParameter(espeakPITCH, 1) * 2));
  455. if (*iosize < strlen(tmppitch)+1) {
  456. *iosize = strlen(tmppitch) + 1;
  457. return TTS_PROPERTY_SIZE_TOO_SMALL;
  458. }
  459. strcpy(value, tmppitch);
  460. return TTS_SUCCESS;
  461. } else if (strncmp(property, "volume", 6) == 0) {
  462. char tmpvolume[4];
  463. sprintf(tmpvolume, "%d", espeak_GetParameter(espeakVOLUME, 1));
  464. if (*iosize < strlen(tmpvolume)+1) {
  465. *iosize = strlen(tmpvolume) + 1;
  466. return TTS_PROPERTY_SIZE_TOO_SMALL;
  467. }
  468. strcpy(value, tmpvolume);
  469. return TTS_SUCCESS;
  470. }
  471. LOGE("Unsupported property");
  472. return TTS_PROPERTY_UNSUPPORTED;
  473. }
  474. /** synthesizeText
  475. * Synthesizes a text string.
  476. * The text string could be annotated with SSML tags.
  477. * @text - text to synthesize
  478. * @buffer - buffer which will receive generated samples
  479. * @bufferSize - size of buffer
  480. * @userdata - pointer to user data which will be passed back to callback function
  481. * return tts_result
  482. */
  483. tts_result TtsEngine::synthesizeText(const char *text, int8_t *buffer, size_t bufferSize,
  484. void *userdata) {
  485. if (DEBUG) LOGV("%s", __FUNCTION__);
  486. espeak_SetSynthCallback(eSpeakCallback);
  487. unsigned int unique_identifier;
  488. espeak_Synth(text, strlen(text), 0, // position
  489. POS_CHARACTER, 0, // end position (0 means no end position)
  490. espeakCHARS_UTF8 | espeakSSML, // use or ignore xml tags
  491. &unique_identifier, userdata);
  492. espeak_Synchronize();
  493. LOGI("Synthesis done");
  494. return TTS_SUCCESS;
  495. }
  496. /** stop
  497. * Aborts the running synthesis.
  498. * return tts_result
  499. */
  500. tts_result TtsEngine::stop() {
  501. if (DEBUG) LOGV("%s", __FUNCTION__);
  502. espeak_Cancel();
  503. return TTS_SUCCESS;
  504. }
  505. #ifdef __cplusplus
  506. extern "C" {
  507. #endif
  508. TtsEngine* getTtsEngine() {
  509. if (DEBUG) LOGV("%s", __FUNCTION__);
  510. return new TtsEngine();
  511. }
  512. #ifdef __cplusplus
  513. }
  514. #endif