eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.

voices.cpp 33KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469
  1. /***************************************************************************
  2. * Copyright (C) 2005 by Jonathan Duddington *
  3. * jonsd@users.sourceforge.net *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; either version 2 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License *
  16. * along with this program; if not, write to the *
  17. * Free Software Foundation, Inc., *
  18. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  19. ***************************************************************************/
  20. #include "StdAfx.h"
  21. #include "stdio.h"
  22. #include "ctype.h"
  23. #include "wctype.h"
  24. #include "string.h"
  25. #include "stdlib.h"
  26. #include "speech.h"
  27. #ifdef PLATFORM_WINDOWS
  28. #include "windows.h"
  29. #else
  30. #ifndef PLATFORM_RISCOS
  31. #include "dirent.h"
  32. #endif
  33. #endif
  34. #include "speak_lib.h"
  35. #include "voice.h"
  36. #include "phoneme.h"
  37. #include "synthesize.h"
  38. #include "translate.h"
  39. MNEM_TAB genders [] = {
  40. {"unknown", 0},
  41. {"male", 1},
  42. {"female", 2},
  43. {NULL, 0 }};
  44. //int tone_points[10] = {250,140, 1200,110, -1,0, -1,0, -1,0};
  45. int tone_points[10] = {600,170, 1200,135, 2000,110, 3000,110, -1,0};
  46. // limit the rate of change for each formant number
  47. //static int formant_rate_22050[9] = {50, 104, 165, 230, 220, 220, 220, 220, 220}; // values for 22kHz sample rate
  48. static int formant_rate_22050[9] = {50, 100, 160, 200, 200, 200, 200, 200, 200}; // values for 22kHz sample rate
  49. int formant_rate[9]; // values adjusted for actual sample rate
  50. #define DEFAULT_LANGUAGE_PRIORITY 5
  51. #define N_VOICES_LIST 100
  52. static int n_voices_list = 0;
  53. static espeak_VOICE *voices_list[N_VOICES_LIST];
  54. static int len_path_voices;
  55. espeak_VOICE *voice_selected = NULL;
  56. espeak_VOICE *first_voice = NULL;
  57. char voice_name[40];
  58. #define V_NAME 1
  59. #define V_LANGUAGE 2
  60. #define V_GENDER 3
  61. #define V_TRANSLATOR 4
  62. #define V_PHONEMES 5
  63. #define V_DICTIONARY 6
  64. // these affect voice quality, are independent of language
  65. #define V_FORMANT 7
  66. #define V_PITCH 8
  67. #define V_ECHO 9
  68. #define V_FLUTTER 10
  69. #define V_ROUGHNESS 11
  70. #define V_CLARITY 12
  71. #define V_TONE 13
  72. // these override defaults set by the translator
  73. #define V_WORDGAP 15
  74. #define V_INTONATION 16
  75. #define V_STRESSLENGTH 17
  76. #define V_STRESSAMP 18
  77. #define V_STRESSADD 19
  78. #define V_DICTRULES 20
  79. #define V_STRESSRULE 21
  80. #define V_CHARSET 22
  81. #define V_NUMBERS 23
  82. #define V_OPTION 24
  83. #define V_MBROLA 25
  84. // these need a phoneme table to have been specified
  85. #define V_REPLACE 26
  86. typedef struct {
  87. const char *mnem;
  88. int data;
  89. } keywtab_t;
  90. static keywtab_t keyword_tab[] = {
  91. {"name", V_NAME},
  92. {"language", V_LANGUAGE},
  93. {"gender", V_GENDER},
  94. {"formant", V_FORMANT},
  95. {"pitch", V_PITCH},
  96. {"phonemes", V_PHONEMES},
  97. {"translator", V_TRANSLATOR},
  98. {"dictionary", V_DICTIONARY},
  99. {"stressLength", V_STRESSLENGTH},
  100. {"stressAmp", V_STRESSAMP},
  101. {"stressAdd", V_STRESSADD},
  102. {"intonation", V_INTONATION},
  103. {"dictrules", V_DICTRULES},
  104. {"stressrule", V_STRESSRULE},
  105. {"charset", V_CHARSET},
  106. {"replace", V_REPLACE},
  107. {"words", V_WORDGAP},
  108. {"echo", V_ECHO},
  109. {"flutter", V_FLUTTER},
  110. {"roughness", V_ROUGHNESS},
  111. {"clarity", V_CLARITY},
  112. {"tone", V_TONE},
  113. {"numbers", V_NUMBERS},
  114. {"option", V_OPTION},
  115. {"mbrola", V_MBROLA},
  116. // these just set a value in langopts.param[]
  117. {"l_dieresis", 0x100+LOPT_DIERESES},
  118. // {"l_lengthen", 0x100+LOPT_IT_LENGTHEN},
  119. {"l_prefix", 0x100+LOPT_PREFIXES},
  120. {"l_regressive_v", 0x100+LOPT_REGRESSIVE_VOICING},
  121. {"l_unpronouncable", 0x100+LOPT_UNPRONOUNCABLE},
  122. {"l_sonorant_min", 0x100+LOPT_SONORANT_MIN},
  123. {"l_length_mods", 0x100+LOPT_LENGTH_MODS},
  124. {NULL, 0} };
  125. #define N_VOICES 100
  126. static int n_voices_tab = 0;
  127. static voice_t *voices_tab[N_VOICES];
  128. #define N_VOICE_VARIANTS 12
  129. const char variants_either[N_VOICE_VARIANTS] = {1,2,12,3,13,4,14,5,11,0};
  130. const char variants_male[N_VOICE_VARIANTS] = {1,2,3,4,5,0};
  131. const char variants_female[N_VOICE_VARIANTS] = {11,12,13,14,0};
  132. const char *variant_lists[3] = {variants_either, variants_male, variants_female};
  133. void SetToneAdjust(voice_t *voice, int *tone_pts)
  134. {//==============================================
  135. int ix;
  136. int pt;
  137. int y;
  138. int freq1=0;
  139. int freq2;
  140. int height1 = tone_pts[1];
  141. int height2;
  142. double rate;
  143. for(pt=0; pt<10; pt+=2)
  144. {
  145. if(tone_pts[pt] == -1)
  146. {
  147. tone_pts[pt] = N_TONE_ADJUST*8;
  148. if(pt > 0)
  149. tone_pts[pt+1] = tone_pts[pt-1];
  150. }
  151. freq2 = tone_pts[pt] / 8; // 8Hz steps
  152. height2 = tone_pts[pt+1];
  153. if((freq2 - freq1) > 0)
  154. {
  155. rate = double(height2-height1)/(freq2-freq1);
  156. for(ix=freq1; ix<freq2; ix++)
  157. {
  158. y = height1 + int(rate * (ix-freq1));
  159. if(y > 255)
  160. y = 255;
  161. voice->tone_adjust[ix] = y;
  162. }
  163. }
  164. freq1 = freq2;
  165. height1 = height2;
  166. }
  167. }
  168. void ReadTonePoints(char *string, int *tone_pts)
  169. {//=============================================
  170. // tone_pts[] is int[10]
  171. int ix;
  172. for(ix=0; ix<10; ix++)
  173. tone_pts[ix] = -1;
  174. sscanf(string,"%d %d %d %d %d %d %d %d",
  175. &tone_pts[0],&tone_pts[1],&tone_pts[2],&tone_pts[3],
  176. &tone_pts[4],&tone_pts[5],&tone_pts[6],&tone_pts[7]);
  177. }
  178. static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname, const char*leafname)
  179. {//===================================================================================
  180. // Read a Voice file, allocate a VOICE_DATA and set data from the
  181. // file's language, gender, name lines
  182. char linebuf[120];
  183. char vname[80];
  184. char vgender[80];
  185. char vlanguage[80];
  186. char languages[300]; // allow space for several alternate language names and priorities
  187. unsigned int len;
  188. int langix = 0;
  189. int n_languages = 0;
  190. char *p;
  191. espeak_VOICE *voice_data;
  192. int priority;
  193. int age;
  194. int n_variants = 3; // default, number of variants of this voice before using another voice
  195. int gender;
  196. #ifdef PLATFORM_WINDOWS
  197. if(memcmp(leafname,"mb-",3) == 0)
  198. {
  199. // check whether the mbrola speech data is present for this voice
  200. memcpy(vname,&leafname[3],3);
  201. vname[3] = 0;
  202. sprintf(linebuf,"%s/mbrola/%s",path_home,vname);
  203. if(GetFileLength(linebuf) <= 0)
  204. return(0);
  205. }
  206. #endif
  207. vname[0] = 0;
  208. vgender[0] = 0;
  209. age = 0;
  210. while(fgets(linebuf,sizeof(linebuf),f_in) != NULL)
  211. {
  212. linebuf[strlen(linebuf)-1] = 0;
  213. if(memcmp(linebuf,"name",4)==0)
  214. {
  215. p = &linebuf[4];
  216. while(isspace(*p)) p++;
  217. strncpy0(vname,p,sizeof(vname));
  218. }
  219. else
  220. if(memcmp(linebuf,"language",8)==0)
  221. {
  222. priority = DEFAULT_LANGUAGE_PRIORITY;
  223. vlanguage[0] = 0;
  224. sscanf(&linebuf[8],"%s %d",vlanguage,&priority);
  225. len = strlen(vlanguage) + 2;
  226. // check for space in languages[]
  227. if(len < (sizeof(languages)-langix-1))
  228. {
  229. languages[langix] = priority;
  230. strcpy(&languages[langix+1],vlanguage);
  231. langix += len;
  232. n_languages++;
  233. }
  234. }
  235. else
  236. if(memcmp(linebuf,"gender",6)==0)
  237. {
  238. sscanf(&linebuf[6],"%s %d",vgender,&age);
  239. }
  240. else
  241. if(memcmp(linebuf,"variants",8)==0)
  242. {
  243. sscanf(&linebuf[8],"%d",&n_variants);
  244. }
  245. }
  246. languages[langix++] = 0;
  247. gender = LookupMnem(genders,vgender);
  248. if(n_languages == 0)
  249. {
  250. #ifdef deleted
  251. // Read voice variant files
  252. // Don't use this, instead preset the variants_* arrays
  253. // no language is specified, this voice file only affects the voice characteristics
  254. if(memcmp(leafname,"!variant",8)==0)
  255. {
  256. if(((variant = atoi(&leafname[8])) > 0) && (strlen(variants_either) < N_VOICE_VARIANTS))
  257. {
  258. char string[2];
  259. string[0] = variant;
  260. string[1] = 0;
  261. strcat(variants_either,string);
  262. if(gender == 1)
  263. strcat(variants_male,string);
  264. if(gender == 2)
  265. strcat(variants_female,string);
  266. }
  267. }
  268. #endif
  269. return(NULL); // no language lines in the voice file
  270. }
  271. p = (char *)calloc(sizeof(espeak_VOICE) + langix + strlen(fname) + strlen(vname) + 3, 1);
  272. voice_data = (espeak_VOICE *)p;
  273. p = &p[sizeof(espeak_VOICE)];
  274. memcpy(p,languages,langix);
  275. voice_data->languages = p;
  276. strcpy(&p[langix],fname);
  277. voice_data->identifier = &p[langix];
  278. voice_data->name = &p[langix];
  279. if(vname[0] != 0)
  280. {
  281. langix += strlen(fname)+1;
  282. strcpy(&p[langix],vname);
  283. voice_data->name = &p[langix];
  284. }
  285. voice_data->age = age;
  286. voice_data->gender = gender;
  287. voice_data->variant = 0;
  288. voice_data->xx1 = n_variants;
  289. return(voice_data);
  290. } // end of ReadVoiceFile
  291. void VoiceReset(int tone_only)
  292. {//===========================
  293. // Set voice to the default values
  294. int pk;
  295. // default is: pitch 82,118
  296. voice->pitch_base = 0x49000; // default, 73 << 12;
  297. voice->pitch_range = 0x0f30; // default = 0x1000
  298. voice->echo_delay = 0;
  299. voice->echo_amp = 0;
  300. voice->flutter = 64;
  301. voice->n_harmonic_peaks = 5;
  302. voice->peak_shape = 1;
  303. #ifdef PLATFORM_RISCOS
  304. voice->roughness = 1;
  305. #else
  306. voice->roughness = 2;
  307. #endif
  308. for(pk=0; pk<N_PEAKS; pk++)
  309. {
  310. voice->freq[pk] = 256;
  311. voice->height[pk] = 256;
  312. voice->width[pk] = 256;
  313. // adjust formant smoothing depending on sample rate
  314. formant_rate[pk] = (formant_rate_22050[pk] * 22050)/samplerate;
  315. }
  316. // This table provides the opportunity for tone control.
  317. // Adjustment of harmonic amplitudes, steps of 8Hz
  318. // value of 128 means no change
  319. // memset(voice->tone_adjust,128,sizeof(voice->tone_adjust));
  320. SetToneAdjust(voice,tone_points);
  321. // default values of speed factors
  322. voice->speedf1 = 256;
  323. voice->speedf2 = 238;
  324. voice->speedf3 = 232;
  325. if(tone_only == 0)
  326. {
  327. n_replace_phonemes = 0;
  328. option_tone1 = 0;
  329. option_quiet = 0;
  330. LoadMbrolaTable(NULL,NULL);
  331. }
  332. } // end of VoiceReset
  333. static void VoiceFormant(char *p)
  334. {//==============================
  335. // Set parameters for a formant
  336. int ix;
  337. int formant;
  338. int freq = -1;
  339. int height = -1;
  340. int width = -1;
  341. ix = sscanf(p,"%d %d %d %d",&formant,&freq,&height,&width);
  342. if(ix < 2)
  343. return;
  344. if((formant < 0) || (formant > 8))
  345. return;
  346. if(freq >= 0)
  347. voice->freq[formant] = int(freq * 2.56001);
  348. if(height >= 0)
  349. voice->height[formant] = int(height * 2.56001);
  350. if(width >= 0)
  351. voice->width[formant] = int(width * 2.56001);
  352. }
  353. static voice_t *VoiceLookup(char *voicename)
  354. {//=========================================
  355. int ix;
  356. voice_t *v;
  357. for(ix=0; ix < N_VOICES; ix++)
  358. {
  359. if(ix == n_voices_tab)
  360. {
  361. // found a free slot
  362. v = (voice_t *)Alloc(sizeof(voice_t));
  363. if(v == NULL)
  364. return(NULL);
  365. voices_tab[n_voices_tab++] = v;
  366. strncpy0(v->name,voicename,sizeof(v->name));
  367. return(v);
  368. }
  369. else
  370. if(strcmp(voices_tab[ix]->name,voicename)==0)
  371. {
  372. return(voices_tab[ix]); // found the entry for the specified voice name
  373. }
  374. }
  375. return(NULL); // table is full
  376. } // end of VoiceLookup
  377. static void PhonemeReplacement(int type, char *p)
  378. {//==============================================
  379. int n;
  380. int phon;
  381. int flags = 0;
  382. char phon_string1[12];
  383. char phon_string2[12];
  384. strcpy(phon_string2,"NULL");
  385. n = sscanf(p,"%d %s %s",&flags,phon_string1,phon_string2);
  386. if((n < 2) || (n_replace_phonemes >= N_REPLACE_PHONEMES))
  387. return;
  388. if((phon = LookupPh(phon_string1)) == 0)
  389. return; // not recognised
  390. replace_phonemes[n_replace_phonemes].old_ph = phon;
  391. replace_phonemes[n_replace_phonemes].new_ph = LookupPh(phon_string2);
  392. replace_phonemes[n_replace_phonemes++].type = flags;
  393. } // end of PhonemeReplacement
  394. static int Read8Numbers(char *data_in,int *data)
  395. {//=============================================
  396. // Read 8 integer numbers
  397. return(sscanf(data_in,"%d %d %d %d %d %d %d %d",
  398. &data[0],&data[1],&data[2],&data[3],&data[4],&data[5],&data[6],&data[7]));
  399. }
  400. voice_t *LoadVoice(char *vname, int control)
  401. {//==========================================
  402. // control, bit 0 1= no_default
  403. // bit 1 1 = change tone only, not language
  404. // bit 2 1 = don't report error on LoadDictionary
  405. FILE *f_voice = NULL;
  406. keywtab_t *k;
  407. char *p;
  408. int key;
  409. int ix;
  410. int n;
  411. int value;
  412. int error = 0;
  413. int tone_only = control & 2;
  414. int language_set = 0;
  415. int phonemes_set = 0;
  416. int stress_amps_set = 0;
  417. int stress_lengths_set = 0;
  418. int stress_add_set = 0;
  419. int conditional_rules = 0;
  420. LANGUAGE_OPTIONS *langopts = NULL;
  421. voice_t *v;
  422. Translator *new_translator = NULL;
  423. char voicename[40];
  424. char language_name[40];
  425. char translator_name[40];
  426. char new_dictionary[40];
  427. char phonemes_name[40];
  428. char *language_type;
  429. char buf[200];
  430. char path_voices[140];
  431. char langname[4];
  432. int stress_amps[8];
  433. int stress_lengths[8];
  434. int stress_add[8];
  435. int pitch1;
  436. int pitch2;
  437. strcpy(voicename,vname);
  438. if(voicename[0]==0)
  439. strcpy(voicename,"default");
  440. sprintf(path_voices,"%s%cvoices%c",path_home,PATHSEP,PATHSEP);
  441. sprintf(buf,"%s%s",path_voices,voicename);
  442. if(GetFileLength(buf) <= 0)
  443. {
  444. // look for the voice in a sub-directory of the language name
  445. langname[0] = voicename[0];
  446. langname[1] = voicename[1];
  447. langname[2] = 0;
  448. sprintf(buf,"%s%s%c%s",path_voices,langname,PATHSEP,voicename);
  449. }
  450. f_voice = fopen(buf,"r");
  451. language_type = "en"; // default
  452. if(f_voice == NULL)
  453. {
  454. if(control & 3)
  455. return(NULL); // can't open file
  456. if(SelectPhonemeTableName(voicename) >= 0)
  457. language_type = voicename;
  458. }
  459. if(first_voice == NULL)
  460. {
  461. first_voice = ReadVoiceFile(f_voice,buf+strlen(path_voices),voicename);
  462. rewind(f_voice);
  463. }
  464. if(!tone_only && (translator != NULL))
  465. {
  466. delete translator;
  467. translator = NULL;
  468. }
  469. strcpy(translator_name,language_type);
  470. strcpy(new_dictionary,language_type);
  471. strcpy(phonemes_name,language_type);
  472. if(!tone_only)
  473. {
  474. if((v = VoiceLookup(voicename)) != NULL)
  475. voice = v;
  476. }
  477. VoiceReset(tone_only);
  478. if(!tone_only)
  479. SelectPhonemeTableName(phonemes_name); // set up phoneme_tab
  480. while((f_voice != NULL) && (fgets(buf,sizeof(buf),f_voice) != NULL))
  481. {
  482. if((p = strstr(buf,"//")) != NULL)
  483. *p = 0;
  484. // isolate the attribute name
  485. for(p=buf; (*p != 0) && !isspace(*p); p++);
  486. *p++ = 0;
  487. if(buf[0] == 0) continue;
  488. key = 0;
  489. for(k=keyword_tab; k->mnem != NULL; k++)
  490. {
  491. if(strcmp(buf,k->mnem)==0)
  492. {
  493. key = k->data;
  494. break;
  495. }
  496. }
  497. switch(key)
  498. {
  499. case V_LANGUAGE:
  500. // only act on the first language line
  501. if(language_set || tone_only)
  502. break;
  503. sscanf(p,"%s",language_name);
  504. language_type = strtok(language_name,"-");
  505. language_set = 1;
  506. strcpy(translator_name,language_type);
  507. strcpy(new_dictionary,language_type);
  508. strcpy(phonemes_name,language_type);
  509. SelectPhonemeTableName(phonemes_name);
  510. if(new_translator != NULL)
  511. delete new_translator;
  512. new_translator = SelectTranslator(translator_name);
  513. langopts = &new_translator->langopts;
  514. break;
  515. case V_NAME:
  516. case V_GENDER:
  517. break;
  518. case V_TRANSLATOR: // language_name
  519. if(tone_only) break;
  520. sscanf(p,"%s",translator_name);
  521. if(new_translator != NULL)
  522. delete new_translator;
  523. new_translator = SelectTranslator(translator_name);
  524. langopts = &new_translator->langopts;
  525. break;
  526. case V_DICTIONARY: // dictionary
  527. sscanf(p,"%s",new_dictionary);
  528. break;
  529. case V_PHONEMES: // phoneme table
  530. sscanf(p,"%s",phonemes_name);
  531. break;
  532. case V_FORMANT:
  533. VoiceFormant(p);
  534. break;
  535. case V_PITCH:
  536. // default is pitch 82 118
  537. n = sscanf(p,"%d %d",&pitch1,&pitch2);
  538. voice->pitch_base = (pitch1 - 9) << 12;
  539. voice->pitch_range = (pitch2 - pitch1) * 108;
  540. break;
  541. case V_STRESSLENGTH: // stressLength
  542. stress_lengths_set = Read8Numbers(p,stress_lengths);
  543. break;
  544. case V_STRESSAMP: // stressAmp
  545. stress_amps_set = Read8Numbers(p,stress_amps);
  546. break;
  547. case V_STRESSADD: // stressAdd
  548. stress_add_set = Read8Numbers(p,stress_add);
  549. break;
  550. case V_INTONATION: // intonation
  551. sscanf(p,"%d %d",&option_tone1,&option_tone2);
  552. break;
  553. case V_DICTRULES: // conditional dictionary rules and list entries
  554. while(*p != 0)
  555. {
  556. while(isspace(*p)) p++;
  557. n = -1;
  558. if((n = atoi(p)) > 0)
  559. {
  560. p++;
  561. conditional_rules |= (1 << n);
  562. }
  563. while(isalnum(*p)) p++;
  564. }
  565. break;
  566. case V_REPLACE:
  567. if(phonemes_set == 0)
  568. {
  569. // must set up a phoneme table before we can lookup phoneme mnemonics
  570. SelectPhonemeTableName(phonemes_name);
  571. phonemes_set = 1;
  572. }
  573. PhonemeReplacement(key,p);
  574. break;
  575. case V_WORDGAP: // words
  576. sscanf(p,"%d %d",&langopts->word_gap, &langopts->vowel_pause);
  577. break;
  578. case V_STRESSRULE:
  579. sscanf(p,"%d %d %d %d",&langopts->stress_rule,
  580. &langopts->stress_flags,
  581. &langopts->unstressed_wd1,
  582. &langopts->unstressed_wd2);
  583. break;
  584. case V_CHARSET:
  585. if((sscanf(p,"%d",&value)==1) && (value < N_CHARSETS))
  586. new_translator->charset_a0 = charsets[value];
  587. break;
  588. case V_NUMBERS:
  589. sscanf(p,"%d",&langopts->numbers);
  590. break;
  591. case V_OPTION:
  592. if(sscanf(p,"%d %d",&ix,&value) == 2)
  593. {
  594. if((ix >= 0) && (ix < N_LOPTS))
  595. langopts->param[ix] = value;
  596. }
  597. break;
  598. case V_ECHO:
  599. // echo. suggest: 135mS 11%
  600. value = 0;
  601. voice->echo_amp = 0;
  602. sscanf(p,"%d %d",&voice->echo_delay,&voice->echo_amp);
  603. break;
  604. case V_FLUTTER: // flutter
  605. if(sscanf(p,"%d",&value)==1)
  606. voice->flutter = value * 32;
  607. break;
  608. case V_ROUGHNESS: // roughness
  609. if(sscanf(p,"%d",&value)==1)
  610. voice->roughness = value;
  611. break;
  612. case V_CLARITY: // formantshape
  613. if(sscanf(p,"%d",&value)==1)
  614. {
  615. if(value > 4)
  616. {
  617. voice->peak_shape = 1; // squarer formant peaks
  618. value = 4;
  619. }
  620. voice->n_harmonic_peaks = 1+value;
  621. }
  622. break;
  623. case V_TONE:
  624. {
  625. int tone_data[10];
  626. ReadTonePoints(p,tone_data);
  627. SetToneAdjust(voice,tone_data);
  628. }
  629. break;
  630. case V_MBROLA:
  631. {
  632. char name[40];
  633. char phtrans[40];
  634. phtrans[0] = 0;
  635. sscanf(p,"%s %s",name,phtrans);
  636. LoadMbrolaTable(name,phtrans);
  637. }
  638. break;
  639. default:
  640. if((key & 0xff00) == 0x100)
  641. {
  642. sscanf(p,"%d",&langopts->param[key &0xff]);
  643. }
  644. else
  645. {
  646. fprintf(stderr,"Bad voice attribute: %s\n",buf);
  647. }
  648. break;
  649. }
  650. }
  651. if(f_voice != NULL)
  652. fclose(f_voice);
  653. if((new_translator == NULL) && (!tone_only))
  654. {
  655. // not set by language attribute
  656. new_translator = SelectTranslator(translator_name);
  657. }
  658. for(ix=0; ix<N_PEAKS; ix++)
  659. {
  660. voice->freq2[ix] = voice->freq[ix];
  661. voice->height2[ix] = voice->height[ix];
  662. voice->width2[ix] = voice->width[ix];
  663. }
  664. if(tone_only)
  665. {
  666. new_translator = translator;
  667. }
  668. else
  669. {
  670. if((ix = SelectPhonemeTableName(phonemes_name)) < 0)
  671. {
  672. fprintf(stderr,"Unknown phoneme table: '%s'\n",phonemes_name);
  673. }
  674. voice->phoneme_tab_ix = ix;
  675. error = new_translator->LoadDictionary(new_dictionary, control & 4);
  676. if(dictionary_name[0]==0)
  677. return(NULL); // no dictionary loaded
  678. new_translator->dict_condition = conditional_rules;
  679. }
  680. langopts = &new_translator->langopts;
  681. if((value = langopts->param[LOPT_LENGTH_MODS]) != 0)
  682. {
  683. SetLengthMods(new_translator,value);
  684. }
  685. voice->width[0] = (voice->width[0] * 105)/100;
  686. if(!tone_only)
  687. {
  688. translator = new_translator;
  689. strcpy(voice_name,voicename);
  690. }
  691. // relative lengths of different stress syllables
  692. for(ix=0; ix<stress_lengths_set; ix++)
  693. {
  694. translator->stress_lengths[ix] = stress_lengths[ix];
  695. }
  696. for(ix=0; ix<stress_add_set; ix++)
  697. {
  698. translator->stress_lengths[ix] += stress_add[ix];
  699. }
  700. for(ix=0; ix<stress_amps_set; ix++)
  701. {
  702. translator->stress_amps[ix] = stress_amps[ix];
  703. translator->stress_amps_r[ix] = stress_amps[ix] -1;
  704. }
  705. return(voice);
  706. } // end of LoadVoice
  707. voice_t *LoadVoiceVariant(const char *vname, int variant)
  708. {//======================================================
  709. voice_t *v;
  710. char *p;
  711. char buf[40];
  712. strcpy(buf,vname);
  713. if((p = strchr(buf,'+')) != NULL)
  714. {
  715. // The voice name has a +variant suffix
  716. *p = 0;
  717. variant = atoi(p+1);
  718. }
  719. v = LoadVoice(buf,0);
  720. if((v != NULL) && (variant > 0))
  721. {
  722. sprintf(buf,"!variant%d",variant);
  723. v = LoadVoice(buf,2);
  724. }
  725. return(v);
  726. }
  727. static int __cdecl VoiceNameSorter(const void *p1, const void *p2)
  728. {//=======================================================
  729. int ix;
  730. espeak_VOICE *v1 = *(espeak_VOICE **)p1;
  731. espeak_VOICE *v2 = *(espeak_VOICE **)p2;
  732. if((ix = strcmp(&v1->languages[1],&v2->languages[1])) != 0) // primary language name
  733. return(ix);
  734. if((ix = v1->languages[0] - v2->languages[0]) != 0) // priority number
  735. return(ix);
  736. return(strcmp(v1->name,v2->name));
  737. }
  738. static int __cdecl VoiceScoreSorter(const void *p1, const void *p2)
  739. {//========================================================
  740. int ix;
  741. espeak_VOICE *v1 = *(espeak_VOICE **)p1;
  742. espeak_VOICE *v2 = *(espeak_VOICE **)p2;
  743. if((ix = v2->score - v1->score) != 0)
  744. return(ix);
  745. return(strcmp(v2->name,v1->name));
  746. }
  747. static int ScoreVoice(espeak_VOICE *voice_spec, int spec_n_parts, int spec_lang_len, espeak_VOICE *voice)
  748. {//======================================================================================================
  749. int ix;
  750. char *p;
  751. int c1, c2;
  752. int language_priority;
  753. int n_parts;
  754. int matching;
  755. int matching_parts;
  756. int score = 0;
  757. int x;
  758. int ratio;
  759. int required_age;
  760. int diff;
  761. p = voice->languages; // list of languages+dialects for which this voice is suitable
  762. if(spec_n_parts == 0)
  763. {
  764. score = 100;
  765. }
  766. else
  767. {
  768. // compare the required language with each of the languages of this voice
  769. while(*p != 0)
  770. {
  771. language_priority = *p++;
  772. matching = 1;
  773. matching_parts = 0;
  774. n_parts = 1;
  775. for(ix=0; ; ix++)
  776. {
  777. if((ix >= spec_lang_len) || ((c1 = voice_spec->languages[ix]) == '-'))
  778. c1 = 0;
  779. if((c2 = p[ix]) == '-')
  780. c2 = 0;
  781. if(c1 != c2)
  782. {
  783. matching = 0;
  784. }
  785. if(p[ix] == '-')
  786. {
  787. n_parts++;
  788. if(matching)
  789. matching_parts++;
  790. }
  791. if(p[ix] == 0)
  792. break;
  793. }
  794. p += (ix+1);
  795. matching_parts += matching; // number of parts which match
  796. if(matching_parts == 0)
  797. break; // no matching parts for this language
  798. x = 5;
  799. // reduce the score if not all parts of the required language match
  800. if((diff = (spec_n_parts - matching_parts)) > 0)
  801. x -= diff;
  802. // reduce score if the language is more specific than required
  803. if((diff = (n_parts - matching_parts)) > 0)
  804. x -= diff;
  805. x = x*100 - (language_priority * 2);
  806. if(x > score)
  807. score = x;
  808. }
  809. }
  810. if(score == 0)
  811. return(0);
  812. if(voice_spec->name != NULL)
  813. {
  814. if(strcmp(voice_spec->name,voice->name)==0)
  815. {
  816. // match on voice name
  817. score += 500;
  818. }
  819. else
  820. if(strcmp(voice_spec->name,voice->identifier)==0)
  821. {
  822. score += 400;
  823. }
  824. }
  825. if(((voice_spec->gender == 1) || (voice_spec->gender == 2)) &&
  826. ((voice->gender == 1) || (voice->gender == 2)))
  827. {
  828. if(voice_spec->gender == voice->gender)
  829. score += 50;
  830. else
  831. score -= 50;
  832. }
  833. if((voice_spec->age <= 12) && (voice->gender == 2) && (voice->age > 12))
  834. {
  835. score += 5; // give some preference for non-child female voice if a child is requested
  836. }
  837. if(voice->age != 0)
  838. {
  839. if(voice_spec->age == 0)
  840. required_age = 30;
  841. else
  842. required_age = voice_spec->age;
  843. ratio = (required_age*100)/voice->age;
  844. if(ratio < 100)
  845. ratio = 10000/ratio;
  846. ratio = (ratio - 100)/10; // 0=exact match, 10=out by factor of 2
  847. x = 5 - ratio;
  848. if(x > 0) x = 0;
  849. score = score + x;
  850. if(voice_spec->age > 0)
  851. score += 10; // required age specified, favour voices with a specified age (near it)
  852. }
  853. if(score < 1)
  854. score = 1;
  855. return(score);
  856. } // end of ScoreVoice
  857. static int SetVoiceScores(espeak_VOICE *voice_select, espeak_VOICE **voices, int control)
  858. {//======================================================================================
  859. // control: bit0=1 include mbrola voices
  860. int ix;
  861. int score;
  862. int nv; // number of candidates
  863. int n_parts=0;
  864. int lang_len=0;
  865. char *p;
  866. espeak_VOICE *vp;
  867. // count number of parts in the specified language
  868. if((voice_select->languages != NULL) && (voice_select->languages[0] != 0))
  869. {
  870. n_parts = 1;
  871. lang_len = strlen(voice_select->languages);
  872. for(p = voice_select->languages; *p != 0; p++)
  873. {
  874. if(*p == '-')
  875. n_parts++;
  876. }
  877. }
  878. // select those voices which match the specified language
  879. nv = 0;
  880. for(ix=0; ix<n_voices_list; ix++)
  881. {
  882. vp = voices_list[ix];
  883. if(((control & 1) == 0) && (memcmp(vp->identifier,"mb/",3) == 0))
  884. continue;
  885. if((score = ScoreVoice(voice_select, n_parts, lang_len, voices_list[ix])) > 0)
  886. {
  887. voices[nv++] = vp;
  888. vp->score = score;
  889. }
  890. }
  891. voices[nv] = NULL; // list terminator
  892. if(nv==0)
  893. return(0);
  894. // sort the selected voices by their score
  895. qsort(voices,nv,sizeof(espeak_VOICE *),(int (__cdecl *)(const void *,const void *))VoiceScoreSorter);
  896. return(nv);
  897. } // end of SetVoiceScores
  898. static espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name)
  899. {//============================================================================
  900. int ix;
  901. int match_fname = -1;
  902. int match_fname2 = -1;
  903. int match_name = -1;
  904. char *id;
  905. int last_part_len;
  906. char last_part[41];
  907. sprintf(last_part,"%c%s",PATHSEP,name);
  908. last_part_len = strlen(last_part);
  909. for(ix=0; voices[ix] != NULL; ix++)
  910. {
  911. if(strcmp(name,voices[ix]->name)==0)
  912. {
  913. match_name = ix; // found matching voice name
  914. break;
  915. }
  916. else
  917. if(strcmp(name,id = voices[ix]->identifier)==0)
  918. {
  919. match_fname = ix; // matching identifier, use this if no matching name
  920. }
  921. else
  922. if(strcmp(last_part,&id[strlen(id)-last_part_len])==0)
  923. {
  924. match_fname2 = ix;
  925. }
  926. }
  927. if(match_name < 0)
  928. {
  929. match_name = match_fname; // no matching name, try matching filename
  930. if(match_name < 0)
  931. match_name = match_fname2; // try matching just the last part of the filename
  932. }
  933. if(match_name < 0)
  934. return(NULL);
  935. return(voices[match_name]);
  936. } // end of SelectVoiceByName
  937. espeak_VOICE *SelectVoice(espeak_VOICE *voice_select, int *variant)
  938. {//================================================================
  939. // Returns a path within espeak-voices, with a possible +variant suffix
  940. int nv; // number of candidates
  941. int ix, ix2;
  942. int j;
  943. int n_variants;
  944. int variant_number;
  945. int gender;
  946. int skip;
  947. int aged=1;
  948. const char *p, *p_start;
  949. espeak_VOICE *vp = NULL;
  950. espeak_VOICE *vp2;
  951. espeak_VOICE *voices[N_VOICES_LIST]; // list of candidates
  952. espeak_VOICE *voices2[N_VOICES_LIST+N_VOICE_VARIANTS];
  953. espeak_VOICE voice_variants[N_VOICE_VARIANTS];
  954. if(n_voices_list == 0)
  955. espeak_ListVoices(NULL); // create the voices list
  956. // select and sort voices for the required language
  957. nv = SetVoiceScores(voice_select,voices,0);
  958. if(nv == 0)
  959. {
  960. // no matching voice, choose the default
  961. if((voices[0] = SelectVoiceByName(voices_list,"default")) != NULL)
  962. nv = 1;
  963. }
  964. gender = 0;
  965. if((voice_select->gender == 2) || ((voice_select->age > 0) && (voice_select->age < 13)))
  966. gender = 2;
  967. else
  968. if(voice_select->gender == 1)
  969. gender = 1;
  970. #define AGE_OLD 60
  971. if(voice_select->age < AGE_OLD)
  972. aged = 0;
  973. p = p_start = variant_lists[gender];
  974. if(aged == 0)
  975. p++; // the first voice in the variants list is older
  976. // add variants for the top voices
  977. n_variants = 0;
  978. for(ix=0, ix2=0; ix<nv; ix++)
  979. {
  980. vp = voices[ix];
  981. // is the main voice the required gender?
  982. skip=0;
  983. if((gender != 0) && (vp->gender != gender))
  984. {
  985. skip=1;
  986. }
  987. if((ix2==0) && aged && (vp->age < AGE_OLD))
  988. {
  989. skip=1;
  990. }
  991. if(skip==0)
  992. {
  993. voices2[ix2++] = vp;
  994. }
  995. for(j=0; (j < vp->xx1) && (n_variants < N_VOICE_VARIANTS);)
  996. {
  997. if((variant_number = *p) == 0)
  998. {
  999. p = p_start;
  1000. continue;
  1001. }
  1002. vp2 = &voice_variants[n_variants++]; // allocate space for voice variant
  1003. memcpy(vp2,vp,sizeof(espeak_VOICE)); // copy from the original voice
  1004. vp2->variant = variant_number;
  1005. voices2[ix2++] = vp2;
  1006. p++;
  1007. j++;
  1008. }
  1009. }
  1010. // add any more variants to the end of the list
  1011. while((vp != NULL) && ((variant_number = *p++) != 0) && (n_variants < N_VOICE_VARIANTS))
  1012. {
  1013. vp2 = &voice_variants[n_variants++]; // allocate space for voice variant
  1014. memcpy(vp2,vp,sizeof(espeak_VOICE)); // copy from the original voice
  1015. vp2->variant = variant_number;
  1016. voices2[ix2++] = vp2;
  1017. }
  1018. // index the sorted list by the required variant number
  1019. vp = voices2[voice_select->variant % ix2];
  1020. *variant = vp->variant;
  1021. return(vp);
  1022. } // end of SelectVoice
  1023. void GetVoices(const char *path)
  1024. {//=============================
  1025. FILE *f_voice;
  1026. espeak_VOICE *voice_data;
  1027. int ftype;
  1028. char fname[140];
  1029. #ifdef PLATFORM_RISCOS
  1030. #else
  1031. #ifdef PLATFORM_WINDOWS
  1032. WIN32_FIND_DATA FindFileData;
  1033. HANDLE hFind = INVALID_HANDLE_VALUE;
  1034. DWORD dwError;
  1035. sprintf(fname,"%s\\*",path);
  1036. hFind = FindFirstFile(fname, &FindFileData);
  1037. if(hFind == INVALID_HANDLE_VALUE)
  1038. return;
  1039. do {
  1040. sprintf(fname,"%s%c%s",path,PATHSEP,FindFileData.cFileName);
  1041. ftype = GetFileLength(fname);
  1042. if((ftype == -2) && (FindFileData.cFileName[0] != '.'))
  1043. {
  1044. // a sub-sirectory
  1045. GetVoices(fname);
  1046. }
  1047. else
  1048. if(ftype > 0)
  1049. {
  1050. // a regular line, add it to the voices list
  1051. if((f_voice = fopen(fname,"r")) == NULL)
  1052. continue;
  1053. // pass voice file name within the voices directory
  1054. voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, FindFileData.cFileName);
  1055. fclose(f_voice);
  1056. if(voice_data != NULL)
  1057. {
  1058. voices_list[n_voices_list++] = voice_data;
  1059. }
  1060. }
  1061. } while(FindNextFile(hFind, &FindFileData) != 0);
  1062. FindClose(hFind);
  1063. #else
  1064. DIR *dir;
  1065. struct dirent *ent;
  1066. if((dir = opendir(path)) == NULL)
  1067. return;
  1068. while((ent = readdir(dir)) != NULL)
  1069. {
  1070. if(n_voices_list >= (N_VOICES_LIST-2))
  1071. break; // voices list is full
  1072. sprintf(fname,"%s%c%s",path,PATHSEP,ent->d_name);
  1073. ftype = GetFileLength(fname);
  1074. if((ftype == -2) && (ent->d_name[0] != '.'))
  1075. {
  1076. // a sub-sirectory
  1077. GetVoices(fname);
  1078. }
  1079. else
  1080. if(ftype > 0)
  1081. {
  1082. // a regular line, add it to the voices list
  1083. if((f_voice = fopen(fname,"r")) == NULL)
  1084. continue;
  1085. // pass voice file name within the voices directory
  1086. voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, ent->d_name);
  1087. fclose(f_voice);
  1088. if(voice_data != NULL)
  1089. {
  1090. voices_list[n_voices_list++] = voice_data;
  1091. }
  1092. }
  1093. }
  1094. closedir(dir);
  1095. #endif
  1096. #endif
  1097. } // end of GetVoices
  1098. espeak_ERROR SetVoiceByName(const char *name)
  1099. {//=========================================
  1100. espeak_VOICE *v;
  1101. int variant=0;
  1102. char *p;
  1103. char variant_name[20];
  1104. static char buf[60];
  1105. strncpy0(buf,name,sizeof(buf));
  1106. if((p = strchr(buf,'+')) != NULL)
  1107. {
  1108. // remove the voice variant suffix, from eg. en+3
  1109. *p = 0;
  1110. variant = atoi(p+1);
  1111. }
  1112. // first check for a voice with this filename
  1113. if((first_voice == NULL) && (LoadVoice(buf,1) != NULL))
  1114. {
  1115. voice_selected = first_voice;
  1116. if(variant > 0)
  1117. {
  1118. // apply a voice variant
  1119. sprintf(variant_name,"!variant%d",variant);
  1120. LoadVoice(variant_name,2);
  1121. }
  1122. WavegenSetVoice(voice);
  1123. return(EE_OK);
  1124. }
  1125. if(n_voices_list == 0)
  1126. espeak_ListVoices(NULL); // create the voices list
  1127. if((v = SelectVoiceByName(voices_list,buf)) != NULL)
  1128. {
  1129. if(LoadVoiceVariant(v->identifier,variant) != NULL)
  1130. {
  1131. voice_selected = v;
  1132. WavegenSetVoice(voice);
  1133. return(EE_OK);
  1134. }
  1135. }
  1136. return(EE_INTERNAL_ERROR); // voice name not found
  1137. } // end of espeak_SetVoiceByName
  1138. espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector)
  1139. {//============================================================
  1140. int variant;
  1141. voice_selected = SelectVoice(voice_selector,&variant);
  1142. LoadVoiceVariant(voice_selected->identifier,variant);
  1143. WavegenSetVoice(voice);
  1144. return(EE_OK);
  1145. } // end of espeak_SetVoiceByProperties
  1146. //=======================================================================
  1147. // Library Interface Functions
  1148. //=======================================================================
  1149. #pragma GCC visibility push(default)
  1150. ESPEAK_API const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec)
  1151. {//========================================================================
  1152. #ifndef PLATFORM_RISCOS
  1153. int ix;
  1154. static espeak_VOICE *voices[N_VOICES_LIST];
  1155. char selected_voice_id[80];
  1156. char path_voices[130];
  1157. // free previous voice list data
  1158. if((voice_selected != NULL) && (voice_selected->identifier != NULL))
  1159. strncpy0(selected_voice_id,voice_selected->identifier,sizeof(selected_voice_id));
  1160. else
  1161. selected_voice_id[0] = 0;
  1162. voice_selected = NULL;
  1163. for(ix=0; ix<n_voices_list; ix++)
  1164. {
  1165. if(voices_list[ix] != NULL)
  1166. free(voices_list[ix]);
  1167. }
  1168. n_voices_list = 0;
  1169. sprintf(path_voices,"%s%cvoices",path_home,PATHSEP);
  1170. len_path_voices = strlen(path_voices)+1;
  1171. GetVoices(path_voices);
  1172. voices_list[n_voices_list] = NULL; // voices list terminator
  1173. // sort the voices list
  1174. qsort(voices_list,n_voices_list,sizeof(espeak_VOICE *),
  1175. (int (__cdecl *)(const void *,const void *))VoiceNameSorter);
  1176. // restore pointer to current voice
  1177. if(selected_voice_id[0] != 0)
  1178. {
  1179. for(ix=0; ix<n_voices_list; ix++)
  1180. {
  1181. if(strcmp(selected_voice_id, voices_list[ix]->identifier)==0)
  1182. {
  1183. voice_selected = voices_list[ix];
  1184. break;
  1185. }
  1186. }
  1187. }
  1188. if(voice_spec)
  1189. {
  1190. // select the voices which match the voice_spec, and sort them by preference
  1191. SetVoiceScores(voice_spec,voices,1);
  1192. return((const espeak_VOICE **)voices);
  1193. }
  1194. #endif
  1195. return((const espeak_VOICE **)voices_list);
  1196. } // end of espeak_ListVoices
  1197. ESPEAK_API espeak_VOICE *espeak_GetCurrentVoice(void)
  1198. {//==================================================
  1199. return(voice_selected);
  1200. }
  1201. #pragma GCC visibility pop