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.

numbers.cpp 31KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381
  1. /***************************************************************************
  2. * Copyright (C) 2005 to 2007 by Jonathan Duddington *
  3. * email: [email protected] *
  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 3 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, see: *
  17. * <http://www.gnu.org/licenses/>. *
  18. ***************************************************************************/
  19. #include "StdAfx.h"
  20. #include <stdio.h>
  21. #include <ctype.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include <wctype.h>
  25. #include <wchar.h>
  26. #include "speak_lib.h"
  27. #include "speech.h"
  28. #include "phoneme.h"
  29. #include "synthesize.h"
  30. #include "voice.h"
  31. #include "translate.h"
  32. #define M_NAME 0
  33. #define M_SMALLCAP 1
  34. #define M_TURNED 2
  35. #define M_REVERSED 3
  36. #define M_CURL 4
  37. #define M_ACUTE 5
  38. #define M_BREVE 6
  39. #define M_CARON 7
  40. #define M_CEDILLA 8
  41. #define M_CIRCUMFLEX 9
  42. #define M_DIAERESIS 10
  43. #define M_DOUBLE_ACUTE 11
  44. #define M_DOT_ABOVE 12
  45. #define M_GRAVE 13
  46. #define M_MACRON 14
  47. #define M_OGONEK 15
  48. #define M_RING 16
  49. #define M_STROKE 17
  50. #define M_TILDE 18
  51. #define M_BAR 19
  52. #define M_RETROFLEX 20
  53. #define M_HOOK 21
  54. #define M_MIDDLE_DOT M_DOT_ABOVE // duplicate of M_DOT_ABOVE
  55. #define M_IMPLOSIVE M_HOOK
  56. typedef struct {
  57. char *name;
  58. int flags;
  59. } ACCENTS;
  60. // these are tokens to look up in the *_list file.
  61. ACCENTS accents_tab[] = {
  62. {"_lig", 1},
  63. {"_smc", 1}, // smallcap
  64. {"_tur", 1}, // turned
  65. {"_rev", 1}, // reversed
  66. {"_crl", 0}, // curl
  67. {"_acu", 0}, // acute
  68. {"_brv", 0}, // breve
  69. {"_hac", 0}, // caron/hacek
  70. {"_ced", 0}, // cedilla
  71. {"_cir", 0}, // circumflex
  72. {"_dia", 0}, // diaeresis
  73. {"_ac2", 0}, // double acute
  74. {"_dot", 0}, // dot
  75. {"_grv", 0}, // grave
  76. {"_mcn", 0}, // macron
  77. {"_ogo", 0}, // ogonek
  78. {"_rng", 0}, // ring
  79. {"_stk", 0}, // stroke
  80. {"_tld", 0}, // tilde
  81. {"_bar", 0}, // bar
  82. {"_rfx", 0}, // retroflex
  83. {"_hok", 0}, // hook
  84. };
  85. #define CAPITAL 0
  86. #define LETTER(ch,mod1,mod2) (ch-59)+(mod1 << 6)+(mod2 << 11)
  87. #define LIGATURE(ch1,ch2,mod1) (ch1-59)+((ch2-59) << 6)+(mod1 << 12)+0x8000
  88. #define L_ALPHA 60 // U+3B1
  89. #define L_SCHWA 61 // U+259
  90. #define L_OPEN_E 62 // U+25B
  91. #define L_GAMMA 63 // U+3B3
  92. #define L_IOTA 64 // U+3B9
  93. #define L_OE 65 // U+153
  94. #define L_OMEGA 66 // U+3C9
  95. #define L_PHI 67 // U+3C6
  96. #define L_ESH 68 // U+283
  97. #define L_UPSILON 69 // U+3C5
  98. #define L_EZH 70 // U+292
  99. #define L_GLOTTAL 71 // U+294
  100. #define L_RTAP 72 // U+27E
  101. static const short non_ascii_tab[] = {
  102. 0, 0x3b1, 0x259, 0x25b, 0x3b3, 0x3b9, 0x153, 0x3c9,
  103. 0x3c6, 0x283, 0x3c5, 0x292, 0x294, 0x27e };
  104. // characters U+00e0 to U+017f
  105. const unsigned short letter_accents_0e0[] = {
  106. LETTER('a',M_GRAVE,0), // U+00e0
  107. LETTER('a',M_ACUTE,0),
  108. LETTER('a',M_CIRCUMFLEX,0),
  109. LETTER('a',M_TILDE,0),
  110. LETTER('a',M_DIAERESIS,0),
  111. LETTER('a',M_RING,0),
  112. LIGATURE('a','e',0),
  113. LETTER('c',M_CEDILLA,0),
  114. LETTER('e',M_GRAVE,0),
  115. LETTER('e',M_ACUTE,0),
  116. LETTER('e',M_CIRCUMFLEX,0),
  117. LETTER('e',M_DIAERESIS,0),
  118. LETTER('i',M_GRAVE,0),
  119. LETTER('i',M_ACUTE,0),
  120. LETTER('i',M_CIRCUMFLEX,0),
  121. LETTER('i',M_DIAERESIS,0),
  122. LETTER('d',M_NAME,0), // eth // U+00f0
  123. LETTER('n',M_TILDE,0),
  124. LETTER('o',M_GRAVE,0),
  125. LETTER('o',M_ACUTE,0),
  126. LETTER('o',M_CIRCUMFLEX,0),
  127. LETTER('o',M_TILDE,0),
  128. LETTER('o',M_DIAERESIS,0),
  129. 0, // division sign
  130. LETTER('o',M_STROKE,0),
  131. LETTER('u',M_GRAVE,0),
  132. LETTER('u',M_ACUTE,0),
  133. LETTER('u',M_CIRCUMFLEX,0),
  134. LETTER('u',M_DIAERESIS,0),
  135. LETTER('y',M_ACUTE,0),
  136. LETTER('t',M_NAME,0), // thorn
  137. LETTER('y',M_DIAERESIS,0),
  138. CAPITAL, // U+0100
  139. LETTER('a',M_MACRON,0),
  140. CAPITAL,
  141. LETTER('a',M_BREVE,0),
  142. CAPITAL,
  143. LETTER('a',M_OGONEK,0),
  144. CAPITAL,
  145. LETTER('c',M_ACUTE,0),
  146. CAPITAL,
  147. LETTER('c',M_CIRCUMFLEX,0),
  148. CAPITAL,
  149. LETTER('c',M_DOT_ABOVE,0),
  150. CAPITAL,
  151. LETTER('c',M_CARON,0),
  152. CAPITAL,
  153. LETTER('d',M_CARON,0),
  154. CAPITAL, // U+0110
  155. LETTER('d',M_STROKE,0),
  156. CAPITAL,
  157. LETTER('e',M_MACRON,0),
  158. CAPITAL,
  159. LETTER('e',M_BREVE,0),
  160. CAPITAL,
  161. LETTER('e',M_DOT_ABOVE,0),
  162. CAPITAL,
  163. LETTER('e',M_OGONEK,0),
  164. CAPITAL,
  165. LETTER('e',M_CARON,0),
  166. CAPITAL,
  167. LETTER('g',M_CIRCUMFLEX,0),
  168. CAPITAL,
  169. LETTER('g',M_BREVE,0),
  170. CAPITAL, // U+0120
  171. LETTER('g',M_DOT_ABOVE,0),
  172. CAPITAL,
  173. LETTER('g',M_CEDILLA,0),
  174. CAPITAL,
  175. LETTER('h',M_CIRCUMFLEX,0),
  176. CAPITAL,
  177. LETTER('h',M_STROKE,0),
  178. CAPITAL,
  179. LETTER('i',M_TILDE,0),
  180. CAPITAL,
  181. LETTER('i',M_MACRON,0),
  182. CAPITAL,
  183. LETTER('i',M_BREVE,0),
  184. CAPITAL,
  185. LETTER('i',M_OGONEK,0),
  186. CAPITAL, // U+0130
  187. LETTER('i',M_NAME,0), // dotless i
  188. CAPITAL,
  189. LIGATURE('i','j',0),
  190. CAPITAL,
  191. LETTER('j',M_CIRCUMFLEX,0),
  192. CAPITAL,
  193. LETTER('k',M_CEDILLA,0),
  194. LETTER('k',M_NAME,0), // kra
  195. CAPITAL,
  196. LETTER('l',M_ACUTE,0),
  197. CAPITAL,
  198. LETTER('l',M_CEDILLA,0),
  199. CAPITAL,
  200. LETTER('l',M_CARON,0),
  201. CAPITAL,
  202. LETTER('l',M_MIDDLE_DOT,0), // U+0140
  203. CAPITAL,
  204. LETTER('l',M_STROKE,0),
  205. CAPITAL,
  206. LETTER('n',M_ACUTE,0),
  207. CAPITAL,
  208. LETTER('n',M_CEDILLA,0),
  209. CAPITAL,
  210. LETTER('n',M_CARON,0),
  211. LETTER('n',M_NAME,0), // apostrophe n
  212. CAPITAL,
  213. LETTER('n',M_NAME,0), // eng
  214. CAPITAL,
  215. LETTER('o',M_MACRON,0),
  216. CAPITAL,
  217. LETTER('o',M_BREVE,0),
  218. CAPITAL, // U+0150
  219. LETTER('o',M_DOUBLE_ACUTE,0),
  220. CAPITAL,
  221. LIGATURE('o','e',0),
  222. CAPITAL,
  223. LETTER('r',M_ACUTE,0),
  224. CAPITAL,
  225. LETTER('r',M_CEDILLA,0),
  226. CAPITAL,
  227. LETTER('r',M_CARON,0),
  228. CAPITAL,
  229. LETTER('s',M_ACUTE,0),
  230. CAPITAL,
  231. LETTER('s',M_CIRCUMFLEX,0),
  232. CAPITAL,
  233. LETTER('s',M_CEDILLA,0),
  234. CAPITAL, // U+0160
  235. LETTER('s',M_CARON,0),
  236. CAPITAL,
  237. LETTER('t',M_CEDILLA,0),
  238. CAPITAL,
  239. LETTER('t',M_CARON,0),
  240. CAPITAL,
  241. LETTER('t',M_STROKE,0),
  242. CAPITAL,
  243. LETTER('u',M_TILDE,0),
  244. CAPITAL,
  245. LETTER('u',M_MACRON,0),
  246. CAPITAL,
  247. LETTER('u',M_BREVE,0),
  248. CAPITAL,
  249. LETTER('u',M_RING,0),
  250. CAPITAL, // U+0170
  251. LETTER('u',M_DOUBLE_ACUTE,0),
  252. CAPITAL,
  253. LETTER('u',M_OGONEK,0),
  254. CAPITAL,
  255. LETTER('w',M_CIRCUMFLEX,0),
  256. CAPITAL,
  257. LETTER('y',M_CIRCUMFLEX,0),
  258. CAPITAL, // Y-DIAERESIS
  259. CAPITAL,
  260. LETTER('z',M_ACUTE,0),
  261. CAPITAL,
  262. LETTER('z',M_DOT_ABOVE,0),
  263. CAPITAL,
  264. LETTER('z',M_CARON,0),
  265. LETTER('s',M_NAME,0), // long-s // U+17f
  266. };
  267. // characters U+0250 to U+029F
  268. const unsigned short letter_accents_250[] = {
  269. LETTER('a',M_TURNED,0), // U+250
  270. LETTER(L_ALPHA,0,0),
  271. LETTER(L_ALPHA,M_TURNED,0),
  272. LETTER('b',M_IMPLOSIVE,0),
  273. 0, // open-o
  274. LETTER('c',M_CURL,0),
  275. LETTER('d',M_RETROFLEX,0),
  276. LETTER('d',M_IMPLOSIVE,0),
  277. LETTER('e',M_REVERSED,0), // U+258
  278. 0, // schwa
  279. LETTER(L_SCHWA,M_HOOK,0),
  280. 0, // open-e
  281. LETTER(L_OPEN_E,M_REVERSED,0),
  282. LETTER(L_OPEN_E,M_HOOK,M_REVERSED),
  283. 0,//LETTER(L_OPEN_E,M_CLOSED,M_REVERSED),
  284. LETTER('j',M_BAR,0),
  285. LETTER('g',M_IMPLOSIVE,0), // U+260
  286. LETTER('g',0,0),
  287. LETTER('g',M_SMALLCAP,0),
  288. LETTER(L_GAMMA,0,0),
  289. 0, // ramshorn
  290. LETTER('h',M_TURNED,0),
  291. LETTER('h',M_HOOK,0),
  292. 0,//LETTER(L_HENG,M_HOOK,0),
  293. LETTER('i',M_BAR,0), // U+268
  294. LETTER(L_IOTA,0,0),
  295. LETTER('i',M_SMALLCAP,0),
  296. LETTER('l',M_TILDE,0),
  297. LETTER('l',M_BAR,0),
  298. LETTER('l',M_RETROFLEX,0),
  299. LIGATURE('l','z',0),
  300. LETTER('m',M_TURNED,0),
  301. 0,//LETTER('m',M_TURNED,M_LEG), // U+270
  302. LETTER('m',M_HOOK,0),
  303. 0,//LETTER('n',M_LEFTHOOK,0),
  304. LETTER('n',M_RETROFLEX,0),
  305. LETTER('n',M_SMALLCAP,0),
  306. LETTER('o',M_BAR,0),
  307. LIGATURE('o','e',M_SMALLCAP),
  308. 0,//LETTER(L_OMEGA,M_CLOSED,0),
  309. LETTER(L_PHI,0,0), // U+278
  310. LETTER('r',M_TURNED,0),
  311. 0,//LETTER('r',M_TURNED,M_LEG),
  312. LETTER('r',M_RETROFLEX,M_TURNED),
  313. 0,//LETTER('r',M_LEG,0),
  314. LETTER('r',M_RETROFLEX,0),
  315. 0, // r-tap
  316. LETTER(L_RTAP,M_REVERSED,0),
  317. LETTER('r',M_SMALLCAP,0), // U+280
  318. LETTER('r',M_TURNED,M_SMALLCAP),
  319. LETTER('s',M_RETROFLEX,0),
  320. 0, // esh
  321. 0,//LETTER('j',M_BAR,L_IMPLOSIVE),
  322. LETTER(L_ESH,M_REVERSED,0),
  323. LETTER(L_ESH,M_CURL,0),
  324. LETTER('t',M_TURNED,0),
  325. LETTER('t',M_RETROFLEX,0), // U+288
  326. LETTER('u',M_BAR,0),
  327. LETTER(L_UPSILON,0,0),
  328. LETTER('v',M_HOOK,0),
  329. LETTER('v',M_TURNED,0),
  330. LETTER('w',M_TURNED,0),
  331. LETTER('y',M_TURNED,0),
  332. LETTER('y',M_SMALLCAP,0),
  333. LETTER('z',M_RETROFLEX,0), // U+290
  334. LETTER('z',M_CURL,0),
  335. 0, // ezh
  336. LETTER(L_EZH,M_CURL,0),
  337. 0, // glottal stop
  338. LETTER(L_GLOTTAL,M_REVERSED,0),
  339. LETTER(L_GLOTTAL,M_TURNED,0),
  340. 0,//LETTER('c',M_LONG,0),
  341. 0, // bilabial click // U+298
  342. LETTER('b',M_SMALLCAP,0),
  343. 0,//LETTER(L_OPEN_E,M_CLOSED,0),
  344. LETTER('g',M_IMPLOSIVE,M_SMALLCAP),
  345. LETTER('h',M_SMALLCAP,0),
  346. LETTER('j',M_CURL,0),
  347. LETTER('k',M_TURNED,0),
  348. LETTER('l',M_SMALLCAP,0),
  349. LETTER('q',M_HOOK,0), // U+2a0
  350. LETTER(L_GLOTTAL,M_STROKE,0),
  351. LETTER(L_GLOTTAL,M_STROKE,M_REVERSED),
  352. LIGATURE('d','z',0),
  353. 0, // dezh
  354. LIGATURE('d','z',M_CURL),
  355. LIGATURE('t','s',0),
  356. 0, // tesh
  357. LIGATURE('t','s',M_CURL),
  358. };
  359. int Translator::LookupLetter2(unsigned int letter, char *ph_buf)
  360. {//=============================================================
  361. int len;
  362. char single_letter[10];
  363. single_letter[0] = 0;
  364. single_letter[1] = '_';
  365. len = utf8_out(letter, &single_letter[2]);
  366. single_letter[len+2] = ' ';
  367. single_letter[len+3] = 0;
  368. if(Lookup(&single_letter[1],ph_buf) == 0)
  369. {
  370. single_letter[1] = ' ';
  371. if(Lookup(&single_letter[2],ph_buf) == 0)
  372. {
  373. TranslateRules(&single_letter[2], ph_buf, 20, NULL,0,NULL);
  374. }
  375. }
  376. return(ph_buf[0]);
  377. }
  378. void Translator::LookupAccentedLetter(unsigned int letter, char *ph_buf)
  379. {//=====================================================================
  380. // lookup the character in the accents table
  381. int accent_data = 0;
  382. int accent1 = 0;
  383. int accent2 = 0;
  384. int basic_letter;
  385. int letter2=0;
  386. char ph_letter1[30];
  387. char ph_letter2[30];
  388. char ph_accent1[30];
  389. char ph_accent2[30];
  390. if((letter >= 0xe0) && (letter < 0x17f))
  391. {
  392. accent_data = letter_accents_0e0[letter - 0xe0];
  393. }
  394. else
  395. if((letter >= 0x250) && (letter <= 0x2a8))
  396. {
  397. accent_data = letter_accents_250[letter - 0x250];
  398. }
  399. if(accent_data != 0)
  400. {
  401. basic_letter = (accent_data & 0x3f) + 59;
  402. if(basic_letter < 'a')
  403. basic_letter = non_ascii_tab[basic_letter-59];
  404. if(accent_data & 0x8000)
  405. {
  406. letter2 = (accent_data >> 6) & 0x3f;
  407. letter2 += 59;
  408. accent2 = (accent_data >> 12) & 0x7;
  409. }
  410. else
  411. {
  412. accent1 = (accent_data >> 6) & 0x1f;
  413. accent2 = (accent_data >> 11) & 0xf;
  414. }
  415. if(Lookup(accents_tab[accent1].name, ph_accent1) != 0)
  416. {
  417. if(LookupLetter2(basic_letter, ph_letter1) != 0)
  418. {
  419. if(accent2 != 0)
  420. {
  421. if(Lookup(accents_tab[accent2].name, ph_accent2) == 0)
  422. {
  423. // break;
  424. }
  425. if(accents_tab[accent2].flags & 1)
  426. {
  427. strcpy(ph_buf,ph_accent2);
  428. ph_buf += strlen(ph_buf);
  429. ph_accent2[0] = 0;
  430. }
  431. }
  432. if(letter2 != 0)
  433. {
  434. //ligature
  435. LookupLetter2(letter2, ph_letter2);
  436. sprintf(ph_buf,"%s%c%s%c%s%s",ph_accent1, phonPAUSE_VSHORT, ph_letter1, phonSTRESS_P, ph_letter2, ph_accent2);
  437. }
  438. else
  439. {
  440. if(accent1 == 0)
  441. strcpy(ph_buf, ph_letter1);
  442. else
  443. if((langopts.accents & 1) || (accents_tab[accent1].flags & 1))
  444. sprintf(ph_buf,"%s%c%c%s", ph_accent1, phonPAUSE_VSHORT, phonSTRESS_P, ph_letter1);
  445. else
  446. sprintf(ph_buf,"%s%c%s%c", ph_letter1, phonPAUSE_VSHORT, ph_accent1, phonPAUSE_VSHORT);
  447. }
  448. }
  449. }
  450. }
  451. } // end of LookupAccentedLetter
  452. void Translator::LookupLetter(unsigned int letter, int next_byte, char *ph_buf1)
  453. {//=============================================================================
  454. int len;
  455. unsigned char *p;
  456. static char single_letter[10] = {0,0};
  457. char ph_stress[2];
  458. unsigned int dict_flags[2];
  459. char ph_buf3[40];
  460. char *ptr;
  461. ph_buf1[0] = 0;
  462. len = utf8_out(letter,&single_letter[2]);
  463. single_letter[len+2] = ' ';
  464. if(next_byte == -1)
  465. {
  466. // speaking normal text, not individual characters
  467. if(Lookup(&single_letter[2],ph_buf1) != 0)
  468. return;
  469. single_letter[1] = '_';
  470. if(Lookup(&single_letter[1],ph_buf3) != 0)
  471. return; // the character is specified as _* so ignore it when speaking normal text
  472. // check whether this character is specified for English
  473. SetTranslator2("en");
  474. if(translator2->Lookup(&single_letter[2], ph_buf3) != 0)
  475. {
  476. // yes, switch to English and re-translate the word
  477. sprintf(ph_buf1,"%c",phonSWITCH);
  478. }
  479. SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
  480. return;
  481. }
  482. if((letter <= 32) || iswspace(letter))
  483. {
  484. // lookup space as _&32 etc.
  485. sprintf(&single_letter[1],"_#%d ",letter);
  486. Lookup(&single_letter[1],ph_buf1);
  487. return;
  488. }
  489. if(next_byte != ' ')
  490. next_byte = RULE_SPELLING;
  491. single_letter[3+len] = next_byte; // follow by space-space if the end of the word, or space-0x31
  492. single_letter[1] = '_';
  493. // if the $accent flag is set for this letter, use the accents table (below)
  494. dict_flags[1] = 0;
  495. ptr = &single_letter[1];
  496. if(Lookup(&single_letter[1],ph_buf3) == 0)
  497. {
  498. single_letter[1] = ' ';
  499. if(Lookup(&single_letter[2],ph_buf3) == 0)
  500. {
  501. TranslateRules(&single_letter[2], ph_buf3, sizeof(ph_buf3), NULL,0,NULL);
  502. }
  503. }
  504. if(ph_buf3[0] == 0)
  505. {
  506. LookupAccentedLetter(letter, ph_buf3);
  507. }
  508. if(ph_buf3[0] == 0)
  509. {
  510. ph_buf1[0] = 0;
  511. return;
  512. }
  513. if(ph_buf3[0] == phonSWITCH)
  514. {
  515. strcpy(ph_buf1,ph_buf3);
  516. return;
  517. }
  518. // at a stress marker at the start of the letter name, unless one is already marked
  519. ph_stress[0] = phonSTRESS_P;
  520. ph_stress[1] = 0;
  521. for(p=(unsigned char *)ph_buf3; *p != 0; p++)
  522. {
  523. if(phoneme_tab[*p]->type == phSTRESS)
  524. ph_stress[0] = 0; // stress is already marked
  525. }
  526. sprintf(ph_buf1,"%s%s",ph_stress,ph_buf3);
  527. }
  528. int Translator::TranslateLetter(char *word, char *phonemes, int control, int word_length)
  529. {//======================================================================================
  530. // get pronunciation for an isolated letter
  531. // return number of bytes used by the letter
  532. // control 2=say-as glyphs, 3-say-as chars
  533. int n_bytes;
  534. int letter;
  535. int len;
  536. char *p2;
  537. char *pbuf;
  538. char capital[20];
  539. char ph_buf[60];
  540. char ph_buf2[60];
  541. char hexbuf[6];
  542. ph_buf[0] = 0;
  543. capital[0] = 0;
  544. n_bytes = utf8_in(&letter,word,0);
  545. if((letter & 0xfff00) == 0x0e000)
  546. {
  547. letter &= 0xff; // uncode private usage area
  548. }
  549. if(control > 2)
  550. {
  551. // include CAPITAL information
  552. if(iswupper(letter))
  553. {
  554. Lookup("_cap",capital);
  555. }
  556. }
  557. letter = towlower2(letter);
  558. LookupLetter(letter, word[n_bytes], ph_buf);
  559. if(ph_buf[0] == phonSWITCH)
  560. {
  561. strcpy(phonemes,ph_buf);
  562. return(0);
  563. }
  564. if((ph_buf[0] == 0) && (translator_name != L('e','n')))
  565. // if((ph_buf[0] == 0) && (word_length == 1) && (translator_name != L('e','n')))
  566. {
  567. // speak as English, check whether there is a translation for this character
  568. SetTranslator2("en");
  569. translator2->LookupLetter(letter, word[n_bytes], ph_buf);
  570. SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
  571. if(ph_buf[0] != 0)
  572. {
  573. sprintf(phonemes,"%cen",phonSWITCH);
  574. return(0);
  575. }
  576. }
  577. if(ph_buf[0] == 0)
  578. {
  579. // character name not found
  580. if(iswalpha(letter))
  581. Lookup("_?A",ph_buf);
  582. if((ph_buf[0]==0) && !iswspace(letter))
  583. Lookup("_??",ph_buf);
  584. if(ph_buf[0] != 0)
  585. {
  586. // speak the hexadecimal number of the character code
  587. sprintf(hexbuf,"%x",letter);
  588. pbuf = ph_buf;
  589. for(p2 = hexbuf; *p2 != 0; p2++)
  590. {
  591. pbuf += strlen(pbuf);
  592. *pbuf++ = phonPAUSE_VSHORT;
  593. LookupLetter(*p2, 0, pbuf);
  594. }
  595. }
  596. }
  597. len = strlen(phonemes);
  598. sprintf(ph_buf2,"%c%s%s",0xff,capital,ph_buf); // the 0xff marker will be removed or replaced in SetSpellingStress()
  599. if((len + strlen(ph_buf2)) < N_WORD_PHONEMES)
  600. {
  601. strcpy(&phonemes[len],ph_buf2);
  602. }
  603. return(n_bytes);
  604. } // end of TranslateLetter
  605. void Translator::SetSpellingStress(char *phonemes, int control, int n_chars)
  606. {//=========================================================================
  607. // Individual letter names, reduce the stress of some.
  608. int ix;
  609. unsigned int c;
  610. int n_stress=0;
  611. int count;
  612. unsigned char buf[N_WORD_PHONEMES];
  613. for(ix=0; (c = phonemes[ix]) != 0; ix++)
  614. {
  615. if(c == phonSTRESS_P)
  616. {
  617. n_stress++;
  618. }
  619. buf[ix] = c;
  620. }
  621. buf[ix] = 0;
  622. count = 0;
  623. for(ix=0; (c = buf[ix]) != 0; ix++)
  624. {
  625. if((c == phonSTRESS_P) && (n_chars > 1))
  626. {
  627. count++;
  628. if(langopts.spelling_stress == 1)
  629. {
  630. // stress on initial letter when spelling
  631. if(count > 1)
  632. c = phonSTRESS_3;
  633. }
  634. else
  635. {
  636. if(count != n_stress)
  637. {
  638. if(((count % 3) != 0) || (count == n_stress-1))
  639. c = phonSTRESS_3; // reduce to secondary stress
  640. }
  641. }
  642. }
  643. else
  644. if(c == 0xff)
  645. {
  646. if((control < 2) || (ix==0))
  647. continue; // don't insert pauses
  648. if(control == 4)
  649. c = phonPAUSE; // pause after each character
  650. if(((count % 3) == 0) || (control == 4))
  651. c = phonPAUSE_SHORT; // pause following a primary stress
  652. else
  653. continue; // remove marker
  654. }
  655. *phonemes++ = c;
  656. }
  657. if(control >= 2)
  658. *phonemes++ = phonPAUSE_NOLINK;
  659. *phonemes = 0;
  660. } // end of SetSpellingStress
  661. int Translator::TranslateRoman(char *word, char *ph_out)
  662. {//=====================================================
  663. int c;
  664. char *p;
  665. const char *p2;
  666. int acc;
  667. int prev;
  668. int value;
  669. int subtract;
  670. int repeat = 0;
  671. unsigned int flags;
  672. char number_chars[N_WORD_BYTES];
  673. static const char *roman_numbers = "ixcmvld";
  674. static int roman_values[] = {1,10,100,1000,5,50,500};
  675. acc = 0;
  676. prev = 0;
  677. subtract = 0x7fff;
  678. while((c = *word++) != ' ')
  679. {
  680. if((p2 = strchr(roman_numbers,c)) == NULL)
  681. return(0);
  682. value = roman_values[p2 - roman_numbers];
  683. if(value == prev)
  684. {
  685. repeat++;
  686. if(repeat >= 3)
  687. return(0);
  688. }
  689. else
  690. repeat = 0;
  691. if((prev==5) || (prev==50) || (prev==500))
  692. {
  693. if(value >= prev)
  694. return(0);
  695. }
  696. if((prev != 0) && (prev < value))
  697. {
  698. if(((acc % 10) != 0) || ((prev*10) < value))
  699. return(0);
  700. subtract = prev;
  701. value -= subtract;
  702. }
  703. else
  704. if(value >= subtract)
  705. return(0);
  706. else
  707. acc += prev;
  708. prev = value;
  709. }
  710. acc += prev;
  711. if(acc < 2)
  712. return(0);
  713. if(acc > langopts.max_roman)
  714. return(0);
  715. Lookup("_roman",ph_out); // precede by "roman" if _rom is defined in *_list
  716. p = &ph_out[strlen(ph_out)];
  717. sprintf(number_chars," %d ",acc);
  718. TranslateNumber(&number_chars[1],p,&flags,0);
  719. return(1);
  720. } // end of TranslateRoman
  721. int Translator::LookupNum2(int value, int control, char *ph_out)
  722. {//=============================================================
  723. // Lookup a 2 digit number
  724. // control bit 0: use special form of '1'
  725. // control bit 2: use feminine form of '2'
  726. int found;
  727. int ix;
  728. int units;
  729. int used_and=0;
  730. int next_phtype;
  731. char string[12]; // for looking up entries in de_list
  732. char ph_tens[50];
  733. char ph_digits[50];
  734. char ph_and[12];
  735. if((value == 1) && (control & 1))
  736. {
  737. if(Lookup("_1a",ph_out) != 0)
  738. return(0);
  739. }
  740. // is there a special pronunciation for this 2-digit number
  741. found = 0;
  742. if(control & 4)
  743. {
  744. sprintf(string,"_%df",value);
  745. found = Lookup(string,ph_digits);
  746. }
  747. if(found == 0)
  748. {
  749. sprintf(string,"_%d",value);
  750. found = Lookup(string,ph_digits);
  751. }
  752. // no, speak as tens+units
  753. if((control & 2) && (value < 10))
  754. {
  755. // speak leading zero
  756. Lookup("_0",ph_tens);
  757. }
  758. else
  759. {
  760. if(found)
  761. {
  762. strcpy(ph_out,ph_digits);
  763. return(0);
  764. }
  765. if((value % 10) == 0)
  766. {
  767. sprintf(string,"_%d0",value / 10);
  768. found = Lookup(string,ph_tens);
  769. }
  770. if(!found)
  771. {
  772. sprintf(string,"_%dX",value / 10);
  773. Lookup(string,ph_tens);
  774. }
  775. if((value % 10) == 0)
  776. {
  777. strcpy(ph_out,ph_tens);
  778. return(0);
  779. }
  780. found = 0;
  781. units = (value % 10);
  782. if(control & 4)
  783. {
  784. // is there a variant form of this number?
  785. sprintf(string,"_%df",units);
  786. found = Lookup(string,ph_digits);
  787. }
  788. if(found == 0)
  789. {
  790. sprintf(string,"_%d",units);
  791. Lookup(string,ph_digits);
  792. }
  793. }
  794. if(langopts.numbers & 0x30)
  795. {
  796. Lookup("_0and",ph_and);
  797. if(langopts.numbers & 0x10)
  798. sprintf(ph_out,"%s%s%s",ph_digits,ph_and,ph_tens);
  799. else
  800. sprintf(ph_out,"%s%s%s",ph_tens,ph_and,ph_digits);
  801. used_and = 1;
  802. }
  803. else
  804. {
  805. if(langopts.numbers & 0x200)
  806. {
  807. // remove vowel from the end of tens if units starts with a vowel (LANG=Italian)
  808. if((ix = strlen(ph_tens)-1) >= 0)
  809. {
  810. if((next_phtype = phoneme_tab[(unsigned int)(ph_digits[0])]->type) == phSTRESS)
  811. next_phtype = phoneme_tab[(unsigned int)(ph_digits[1])]->type;
  812. if((phoneme_tab[(unsigned int)(ph_tens[ix])]->type == phVOWEL) && (next_phtype == phVOWEL))
  813. ph_tens[ix] = 0;
  814. }
  815. }
  816. sprintf(ph_out,"%s%s",ph_tens,ph_digits);
  817. }
  818. if(langopts.numbers & 0x100)
  819. {
  820. // only one primary stress
  821. found = 0;
  822. for(ix=strlen(ph_out)-1; ix>=0; ix--)
  823. {
  824. if(ph_out[ix] == phonSTRESS_P)
  825. {
  826. if(found)
  827. ph_out[ix] = phonSTRESS_3;
  828. else
  829. found = 1;
  830. }
  831. }
  832. }
  833. return(used_and);
  834. } // end of LookupNum2
  835. int Translator::LookupNum3(int value, char *ph_out, int suppress_null, int thousandplex, int prev_thousands)
  836. {//=========================================================================================================
  837. // Translate a 3 digit number
  838. int found;
  839. int hundreds;
  840. int x;
  841. char string[12]; // for looking up entries in **_list
  842. char buf1[100];
  843. char buf2[100];
  844. char ph_100[20];
  845. char ph_10T[20];
  846. char ph_digits[50];
  847. char ph_thousands[50];
  848. char ph_hundred_and[12];
  849. char ph_thousand_and[12];
  850. hundreds = value / 100;
  851. buf1[0] = 0;
  852. if(hundreds > 0)
  853. {
  854. ph_thousands[0] = 0;
  855. ph_thousand_and[0] = 0;
  856. Lookup("_0C",ph_100);
  857. if((hundreds >= 10) && (((langopts.numbers & 0x0800) == 0) || (hundreds != 19)))
  858. {
  859. ph_digits[0] = 0;
  860. if(LookupThousands(hundreds / 10, thousandplex+1, ph_10T) == 0)
  861. {
  862. x = 0;
  863. if(langopts.numbers2 & (1 << (thousandplex+1)))
  864. x = 4;
  865. LookupNum2(hundreds/10, x, ph_digits);
  866. }
  867. sprintf(ph_thousands,"%s%s%c",ph_digits,ph_10T,phonPAUSE_NOLINK);
  868. hundreds %= 10;
  869. if(hundreds == 0)
  870. ph_100[0] = 0;
  871. suppress_null = 1;
  872. }
  873. ph_digits[0] = 0;
  874. if(hundreds > 0)
  875. {
  876. if((langopts.numbers & 0x100000) && (prev_thousands || (ph_thousands[0] != 0)))
  877. {
  878. Lookup("_0and",ph_thousand_and);
  879. }
  880. suppress_null = 1;
  881. found = 0;
  882. if((value % 1000) == 100)
  883. {
  884. // is there a special pronunciation for exactly 100 ?
  885. found = Lookup("_1C0",ph_digits);
  886. }
  887. if(!found)
  888. {
  889. sprintf(string,"_%dC",hundreds);
  890. found = Lookup(string,ph_digits); // is there a specific pronunciation for n-hundred ?
  891. }
  892. if(found)
  893. {
  894. ph_100[0] = 0;
  895. }
  896. else
  897. {
  898. if((hundreds > 1) || ((langopts.numbers & 0x400) == 0))
  899. {
  900. LookupNum2(hundreds,0,ph_digits);
  901. }
  902. }
  903. }
  904. sprintf(buf1,"%s%s%s%s",ph_thousands,ph_thousand_and,ph_digits,ph_100);
  905. }
  906. ph_hundred_and[0] = 0;
  907. if((langopts.numbers & 0x40) && ((value % 100) != 0))
  908. {
  909. if((value > 100) || (prev_thousands && (thousandplex==0)))
  910. {
  911. Lookup("_0and",ph_hundred_and);
  912. }
  913. }
  914. buf2[0] = 0;
  915. value = value % 100;
  916. if(value == 0)
  917. {
  918. if(suppress_null == 0)
  919. Lookup("_0",buf2);
  920. }
  921. else
  922. {
  923. x = 0;
  924. if(thousandplex==0)
  925. x = 1; // allow "eins" for 1 rather than "ein"
  926. else
  927. {
  928. if(langopts.numbers2 & (1 << thousandplex))
  929. x = 4; // use variant (feminine) for before thousands and millions
  930. }
  931. if(LookupNum2(value,x,buf2) != 0)
  932. {
  933. if(langopts.numbers & 0x80)
  934. ph_hundred_and[0] = 0; // don't put 'and' after 'hundred' if there's 'and' between tens and units
  935. }
  936. }
  937. sprintf(ph_out,"%s%s%s",buf1,ph_hundred_and,buf2);
  938. return(0);
  939. } // end of LookupNum3
  940. static const char *M_Variant(int value)
  941. {//====================================
  942. // returns M, or perhaps MA for some cases
  943. if(((value % 100)>20) || ((value % 100)<10)) // but not teens, 10 to 19
  944. {
  945. if ((translator->langopts.numbers2 & 0x40) &&
  946. ((value % 10)>=2) &&
  947. ((value % 10)<=4))
  948. {
  949. // for Polish language - two forms of plural!
  950. return("0MA");
  951. }
  952. if((translator->langopts.numbers2 & 0x80) &&
  953. ((value % 10)==1))
  954. {
  955. return("1MA");
  956. }
  957. }
  958. return("0M");
  959. }
  960. int Translator::LookupThousands(int value, int thousandplex, char *ph_out)
  961. {//=======================================================================
  962. int found;
  963. char string[12];
  964. char ph_of[12];
  965. char ph_thousands[40];
  966. ph_of[0] = 0;
  967. // first look fora match with the exact value of thousands
  968. sprintf(string,"_%dM%d",value,thousandplex);
  969. if((found = Lookup(string,ph_thousands)) == 0)
  970. {
  971. if((value % 100) >= 20)
  972. {
  973. Lookup("_0of",ph_of);
  974. }
  975. sprintf(string,"_%s%d",M_Variant(value),thousandplex);
  976. if(Lookup(string,ph_thousands) == 0)
  977. {
  978. // repeat "thousand" if higher order names are not available
  979. sprintf(string,"_%dM1",value);
  980. if((found = Lookup(string,ph_thousands)) == 0)
  981. Lookup("_0M1",ph_thousands);
  982. }
  983. }
  984. sprintf(ph_out,"%s%s",ph_of,ph_thousands);
  985. return(found);
  986. }
  987. int Translator::TranslateNumber_1(char *word, char *ph_out, unsigned int *flags, int wflags)
  988. {//=========================================================================================
  989. // Number translation with various options
  990. // the "word" may be up to 4 digits
  991. // "words" of 3 digits may be preceded by another number "word" for thousands or millions
  992. int n_digits;
  993. int value;
  994. int ix;
  995. unsigned char c;
  996. int suppress_null = 0;
  997. int decimal_point = 0;
  998. int thousandplex = 0;
  999. int thousands_inc = 0;
  1000. int prev_thousands = 0;
  1001. int this_value;
  1002. static int prev_value;
  1003. int decimal_count;
  1004. int max_decimal_count;
  1005. char string[12]; // for looking up entries in de_list
  1006. char buf1[100];
  1007. char ph_append[50];
  1008. char ph_buf[200];
  1009. char ph_buf2[50];
  1010. static const char str_pause[2] = {phonPAUSE_NOLINK,0};
  1011. for(ix=0; isdigit(word[ix]); ix++) ;
  1012. n_digits = ix;
  1013. value = this_value = atoi(word);
  1014. ph_append[0] = 0;
  1015. ph_buf2[0] = 0;
  1016. // is there a previous thousands part (as a previous "word") ?
  1017. if((n_digits == 3) && (word[-2] == langopts.thousands_sep) && isdigit(word[-3]))
  1018. {
  1019. prev_thousands = 1;
  1020. }
  1021. else
  1022. if((langopts.thousands_sep == ' ') || (langopts.numbers & 0x1000))
  1023. {
  1024. // thousands groups can be separated by spaces
  1025. if((n_digits == 3) && isdigit(word[-2]))
  1026. {
  1027. prev_thousands = 1;
  1028. }
  1029. }
  1030. if((word[0] == '0') && (prev_thousands == 0) && (word[1] != langopts.decimal_sep))
  1031. {
  1032. if((n_digits == 2) && (word[3] == ':') && isdigit(word[5]) && isspace(word[7]))
  1033. {
  1034. // looks like a time 02:30, omit the leading zero
  1035. }
  1036. else
  1037. {
  1038. return(0); // number string with leading zero, speak as individual digits
  1039. }
  1040. }
  1041. if((langopts.numbers & 0x1000) && (word[n_digits] == ' '))
  1042. thousands_inc = 1;
  1043. else
  1044. if(word[n_digits] == langopts.thousands_sep)
  1045. thousands_inc = 2;
  1046. if(thousands_inc > 0)
  1047. {
  1048. // if the following "words" are three-digit groups, count them and add
  1049. // a "thousand"/"million" suffix to this one
  1050. ix = n_digits + thousands_inc;
  1051. while(isdigit(word[ix]) && isdigit(word[ix+1]) && isdigit(word[ix+2]))
  1052. {
  1053. thousandplex++;
  1054. if(word[ix+3] == langopts.thousands_sep)
  1055. ix += (3 + thousands_inc);
  1056. else
  1057. break;
  1058. }
  1059. }
  1060. if((value == 0) && prev_thousands)
  1061. {
  1062. suppress_null = 1;
  1063. }
  1064. if((word[n_digits] == langopts.decimal_sep) && isdigit(word[n_digits+1]))
  1065. {
  1066. // this "word" ends with a decimal point
  1067. Lookup("_dpt",ph_append);
  1068. decimal_point = 1;
  1069. }
  1070. else
  1071. if(suppress_null == 0)
  1072. {
  1073. if(thousands_inc > 0)
  1074. {
  1075. if((thousandplex > 0) && (value < 1000))
  1076. {
  1077. if(langopts.numbers2 & 0x100)
  1078. {
  1079. if((thousandplex == 1) && (value >= 100))
  1080. {
  1081. // special word for 100,000's
  1082. char ph_buf3[20];
  1083. sprintf(string,"_%dL",value / 100);
  1084. if(Lookup(string,ph_buf2) == 0)
  1085. {
  1086. LookupNum2(value/100,0,ph_buf2);
  1087. Lookup("_0L",ph_buf3);
  1088. strcat(ph_buf2,ph_buf3);
  1089. }
  1090. value %= 100;
  1091. if(value == 0)
  1092. suppress_null = 1;
  1093. }
  1094. }
  1095. if((suppress_null == 0) && (LookupThousands(value,thousandplex,ph_append)))
  1096. {
  1097. // found an exact match for N thousand
  1098. value = 0;
  1099. suppress_null = 1;
  1100. }
  1101. }
  1102. }
  1103. }
  1104. else
  1105. if((thousandplex > 1) && prev_thousands && (prev_value > 0))
  1106. {
  1107. sprintf(string,"_%s%d",M_Variant(value),thousandplex+1);
  1108. if(Lookup(string,buf1)==0)
  1109. {
  1110. // speak this thousandplex if there was no word for the previous thousandplex
  1111. sprintf(string,"_0M%d",thousandplex);
  1112. Lookup(string,ph_append);
  1113. }
  1114. }
  1115. if((ph_append[0] == 0) && (word[n_digits] == '.') && (thousandplex == 0))
  1116. {
  1117. Lookup("_.",ph_append);
  1118. }
  1119. LookupNum3(value, ph_buf, suppress_null, thousandplex, prev_thousands);
  1120. sprintf(ph_out,"%s%s%s",ph_buf2,ph_buf,ph_append);
  1121. while(decimal_point)
  1122. {
  1123. n_digits++;
  1124. decimal_count = 0;
  1125. while(isdigit(word[n_digits+decimal_count]))
  1126. decimal_count++;
  1127. if(decimal_count > 1)
  1128. {
  1129. max_decimal_count = 2;
  1130. switch(langopts.numbers & 0xe000)
  1131. {
  1132. case 0x8000:
  1133. max_decimal_count = 5;
  1134. case 0x4000:
  1135. // French/Polish decimal fraction
  1136. while(word[n_digits] == '0')
  1137. {
  1138. Lookup("_0",buf1);
  1139. strcat(ph_out,buf1);
  1140. decimal_count--;
  1141. n_digits++;
  1142. }
  1143. if(decimal_count <= max_decimal_count)
  1144. {
  1145. LookupNum3(atoi(&word[n_digits]),buf1,0,0,0);
  1146. strcat(ph_out,buf1);
  1147. n_digits += decimal_count;
  1148. }
  1149. break;
  1150. case 0x2000:
  1151. // Italian decimal fractions
  1152. if((decimal_count < 4) || ((decimal_count==4) && (word[n_digits] != '0')))
  1153. {
  1154. LookupNum3(atoi(&word[n_digits]),buf1,0,0,0);
  1155. strcat(ph_out,buf1);
  1156. if(word[n_digits]=='0')
  1157. {
  1158. // decimal part has leading zeros, so add a "hundredths" or "thousandths" suffix
  1159. sprintf(string,"_0Z%d",decimal_count);
  1160. Lookup(string,buf1);
  1161. strcat(ph_out,buf1);
  1162. }
  1163. n_digits += decimal_count;
  1164. }
  1165. break;
  1166. case 0x6000:
  1167. // Romanian decimal fractions
  1168. if((decimal_count <= 4) && (word[n_digits] != '0'))
  1169. {
  1170. LookupNum3(atoi(&word[n_digits]),buf1,0,0,0);
  1171. strcat(ph_out,buf1);
  1172. n_digits += decimal_count;
  1173. }
  1174. break;
  1175. }
  1176. }
  1177. while(isdigit(c = word[n_digits]) && (strlen(ph_out) < (N_WORD_PHONEMES - 10)))
  1178. {
  1179. value = word[n_digits++] - '0';
  1180. LookupNum2(value, 1, buf1);
  1181. strcat(ph_out,buf1);
  1182. }
  1183. // something after the decimal part ?
  1184. if(Lookup("_dpt2",buf1))
  1185. strcat(ph_out,buf1);
  1186. if(c == langopts.decimal_sep)
  1187. {
  1188. Lookup("_dpt",buf1);
  1189. strcat(ph_out,buf1);
  1190. }
  1191. else
  1192. {
  1193. decimal_point = 0;
  1194. }
  1195. }
  1196. if((ph_out[0] != 0) && (ph_out[0] != phonSWITCH))
  1197. {
  1198. int next_char;
  1199. char *p;
  1200. p = &word[n_digits+1];
  1201. p += utf8_in(&next_char,p,0);
  1202. if((langopts.numbers & NUM_NOPAUSE) && (next_char == ' '))
  1203. utf8_in(&next_char,p,0);
  1204. if(!iswalpha(next_char))
  1205. strcat(ph_out,str_pause); // don't add pause for 100s, 6th, etc.
  1206. }
  1207. *flags = FLAG_FOUND;
  1208. prev_value = this_value;
  1209. return(1);
  1210. } // end of TranslateNumber_1
  1211. int Translator::TranslateNumber(char *word1, char *ph_out, unsigned int *flags, int wflags)
  1212. {//=======================================================================================
  1213. if(option_sayas == SAYAS_DIGITS1)
  1214. return(0); // speak digits individually
  1215. if((langopts.numbers & 0x3) == 1)
  1216. return(TranslateNumber_1(word1,ph_out,flags,wflags));
  1217. return(0);
  1218. } // end of TranslateNumber