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 60KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471
  1. /***************************************************************************
  2. * Copyright (C) 2005 to 2015 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_LIGATURE 0x8000
  33. #define M_NAME 0
  34. #define M_SMALLCAP 1
  35. #define M_TURNED 2
  36. #define M_REVERSED 3
  37. #define M_CURL 4
  38. #define M_ACUTE 5
  39. #define M_BREVE 6
  40. #define M_CARON 7
  41. #define M_CEDILLA 8
  42. #define M_CIRCUMFLEX 9
  43. #define M_DIAERESIS 10
  44. #define M_DOUBLE_ACUTE 11
  45. #define M_DOT_ABOVE 12
  46. #define M_GRAVE 13
  47. #define M_MACRON 14
  48. #define M_OGONEK 15
  49. #define M_RING 16
  50. #define M_STROKE 17
  51. #define M_TILDE 18
  52. #define M_BAR 19
  53. #define M_RETROFLEX 20
  54. #define M_HOOK 21
  55. #define M_MIDDLE_DOT M_DOT_ABOVE // duplicate of M_DOT_ABOVE
  56. #define M_IMPLOSIVE M_HOOK
  57. static int n_digit_lookup;
  58. static char *digit_lookup;
  59. static int speak_missing_thousands;
  60. static int number_control;
  61. typedef struct {
  62. const char *name;
  63. int accent_flags; // bit 0, say before the letter name
  64. } ACCENTS;
  65. // these are tokens to look up in the *_list file.
  66. static ACCENTS accents_tab[] = {
  67. {"_lig", 1},
  68. {"_smc", 0}, // smallcap
  69. {"_tur", 0}, // turned
  70. {"_rev", 0}, // reversed
  71. {"_crl", 0}, // curl
  72. {"_acu", 0}, // acute
  73. {"_brv", 0}, // breve
  74. {"_hac", 0}, // caron/hacek
  75. {"_ced", 0}, // cedilla
  76. {"_cir", 0}, // circumflex
  77. {"_dia", 0}, // diaeresis
  78. {"_ac2", 0}, // double acute
  79. {"_dot", 0}, // dot
  80. {"_grv", 0}, // grave
  81. {"_mcn", 0}, // macron
  82. {"_ogo", 0}, // ogonek
  83. {"_rng", 0}, // ring
  84. {"_stk", 0}, // stroke
  85. {"_tld", 0}, // tilde
  86. {"_bar", 0}, // bar
  87. {"_rfx", 0}, // retroflex
  88. {"_hok", 0}, // hook
  89. };
  90. #define CAPITAL 0
  91. #define LETTER(ch,mod1,mod2) (ch-59)+(mod1 << 6)+(mod2 << 11)
  92. #define LIGATURE(ch1,ch2,mod1) (ch1-59)+((ch2-59) << 6)+(mod1 << 12)+M_LIGATURE
  93. #define L_ALPHA 60 // U+3B1
  94. #define L_SCHWA 61 // U+259
  95. #define L_OPEN_E 62 // U+25B
  96. #define L_GAMMA 63 // U+3B3
  97. #define L_IOTA 64 // U+3B9
  98. #define L_OE 65 // U+153
  99. #define L_OMEGA 66 // U+3C9
  100. #define L_PHI 67 // U+3C6
  101. #define L_ESH 68 // U+283
  102. #define L_UPSILON 69 // U+3C5
  103. #define L_EZH 70 // U+292
  104. #define L_GLOTTAL 71 // U+294
  105. #define L_RTAP 72 // U+27E
  106. #define L_RLONG 73 // U+27C
  107. static const short non_ascii_tab[] = {
  108. 0, 0x3b1, 0x259, 0x25b, 0x3b3, 0x3b9, 0x153, 0x3c9,
  109. 0x3c6, 0x283, 0x3c5, 0x292, 0x294, 0x27e, 0x27c
  110. };
  111. // characters U+00e0 to U+017f
  112. static const unsigned short letter_accents_0e0[] = {
  113. LETTER('a',M_GRAVE,0), // U+00e0
  114. LETTER('a',M_ACUTE,0),
  115. LETTER('a',M_CIRCUMFLEX,0),
  116. LETTER('a',M_TILDE,0),
  117. LETTER('a',M_DIAERESIS,0),
  118. LETTER('a',M_RING,0),
  119. LIGATURE('a','e',0),
  120. LETTER('c',M_CEDILLA,0),
  121. LETTER('e',M_GRAVE,0),
  122. LETTER('e',M_ACUTE,0),
  123. LETTER('e',M_CIRCUMFLEX,0),
  124. LETTER('e',M_DIAERESIS,0),
  125. LETTER('i',M_GRAVE,0),
  126. LETTER('i',M_ACUTE,0),
  127. LETTER('i',M_CIRCUMFLEX,0),
  128. LETTER('i',M_DIAERESIS,0),
  129. LETTER('d',M_NAME,0), // eth // U+00f0
  130. LETTER('n',M_TILDE,0),
  131. LETTER('o',M_GRAVE,0),
  132. LETTER('o',M_ACUTE,0),
  133. LETTER('o',M_CIRCUMFLEX,0),
  134. LETTER('o',M_TILDE,0),
  135. LETTER('o',M_DIAERESIS,0),
  136. 0, // division sign
  137. LETTER('o',M_STROKE,0),
  138. LETTER('u',M_GRAVE,0),
  139. LETTER('u',M_ACUTE,0),
  140. LETTER('u',M_CIRCUMFLEX,0),
  141. LETTER('u',M_DIAERESIS,0),
  142. LETTER('y',M_ACUTE,0),
  143. LETTER('t',M_NAME,0), // thorn
  144. LETTER('y',M_DIAERESIS,0),
  145. CAPITAL, // U+0100
  146. LETTER('a',M_MACRON,0),
  147. CAPITAL,
  148. LETTER('a',M_BREVE,0),
  149. CAPITAL,
  150. LETTER('a',M_OGONEK,0),
  151. CAPITAL,
  152. LETTER('c',M_ACUTE,0),
  153. CAPITAL,
  154. LETTER('c',M_CIRCUMFLEX,0),
  155. CAPITAL,
  156. LETTER('c',M_DOT_ABOVE,0),
  157. CAPITAL,
  158. LETTER('c',M_CARON,0),
  159. CAPITAL,
  160. LETTER('d',M_CARON,0),
  161. CAPITAL, // U+0110
  162. LETTER('d',M_STROKE,0),
  163. CAPITAL,
  164. LETTER('e',M_MACRON,0),
  165. CAPITAL,
  166. LETTER('e',M_BREVE,0),
  167. CAPITAL,
  168. LETTER('e',M_DOT_ABOVE,0),
  169. CAPITAL,
  170. LETTER('e',M_OGONEK,0),
  171. CAPITAL,
  172. LETTER('e',M_CARON,0),
  173. CAPITAL,
  174. LETTER('g',M_CIRCUMFLEX,0),
  175. CAPITAL,
  176. LETTER('g',M_BREVE,0),
  177. CAPITAL, // U+0120
  178. LETTER('g',M_DOT_ABOVE,0),
  179. CAPITAL,
  180. LETTER('g',M_CEDILLA,0),
  181. CAPITAL,
  182. LETTER('h',M_CIRCUMFLEX,0),
  183. CAPITAL,
  184. LETTER('h',M_STROKE,0),
  185. CAPITAL,
  186. LETTER('i',M_TILDE,0),
  187. CAPITAL,
  188. LETTER('i',M_MACRON,0),
  189. CAPITAL,
  190. LETTER('i',M_BREVE,0),
  191. CAPITAL,
  192. LETTER('i',M_OGONEK,0),
  193. CAPITAL, // U+0130
  194. LETTER('i',M_NAME,0), // dotless i
  195. CAPITAL,
  196. LIGATURE('i','j',0),
  197. CAPITAL,
  198. LETTER('j',M_CIRCUMFLEX,0),
  199. CAPITAL,
  200. LETTER('k',M_CEDILLA,0),
  201. LETTER('k',M_NAME,0), // kra
  202. CAPITAL,
  203. LETTER('l',M_ACUTE,0),
  204. CAPITAL,
  205. LETTER('l',M_CEDILLA,0),
  206. CAPITAL,
  207. LETTER('l',M_CARON,0),
  208. CAPITAL,
  209. LETTER('l',M_MIDDLE_DOT,0), // U+0140
  210. CAPITAL,
  211. LETTER('l',M_STROKE,0),
  212. CAPITAL,
  213. LETTER('n',M_ACUTE,0),
  214. CAPITAL,
  215. LETTER('n',M_CEDILLA,0),
  216. CAPITAL,
  217. LETTER('n',M_CARON,0),
  218. LETTER('n',M_NAME,0), // apostrophe n
  219. CAPITAL,
  220. LETTER('n',M_NAME,0), // eng
  221. CAPITAL,
  222. LETTER('o',M_MACRON,0),
  223. CAPITAL,
  224. LETTER('o',M_BREVE,0),
  225. CAPITAL, // U+0150
  226. LETTER('o',M_DOUBLE_ACUTE,0),
  227. CAPITAL,
  228. LIGATURE('o','e',0),
  229. CAPITAL,
  230. LETTER('r',M_ACUTE,0),
  231. CAPITAL,
  232. LETTER('r',M_CEDILLA,0),
  233. CAPITAL,
  234. LETTER('r',M_CARON,0),
  235. CAPITAL,
  236. LETTER('s',M_ACUTE,0),
  237. CAPITAL,
  238. LETTER('s',M_CIRCUMFLEX,0),
  239. CAPITAL,
  240. LETTER('s',M_CEDILLA,0),
  241. CAPITAL, // U+0160
  242. LETTER('s',M_CARON,0),
  243. CAPITAL,
  244. LETTER('t',M_CEDILLA,0),
  245. CAPITAL,
  246. LETTER('t',M_CARON,0),
  247. CAPITAL,
  248. LETTER('t',M_STROKE,0),
  249. CAPITAL,
  250. LETTER('u',M_TILDE,0),
  251. CAPITAL,
  252. LETTER('u',M_MACRON,0),
  253. CAPITAL,
  254. LETTER('u',M_BREVE,0),
  255. CAPITAL,
  256. LETTER('u',M_RING,0),
  257. CAPITAL, // U+0170
  258. LETTER('u',M_DOUBLE_ACUTE,0),
  259. CAPITAL,
  260. LETTER('u',M_OGONEK,0),
  261. CAPITAL,
  262. LETTER('w',M_CIRCUMFLEX,0),
  263. CAPITAL,
  264. LETTER('y',M_CIRCUMFLEX,0),
  265. CAPITAL, // Y-DIAERESIS
  266. CAPITAL,
  267. LETTER('z',M_ACUTE,0),
  268. CAPITAL,
  269. LETTER('z',M_DOT_ABOVE,0),
  270. CAPITAL,
  271. LETTER('z',M_CARON,0),
  272. LETTER('s',M_NAME,0), // long-s // U+17f
  273. // LETTER('b',M_STROKE,0),
  274. };
  275. // characters U+0250 to U+029F
  276. static const unsigned short letter_accents_250[] = {
  277. LETTER('a',M_TURNED,0), // U+250
  278. LETTER(L_ALPHA,0,0),
  279. LETTER(L_ALPHA,M_TURNED,0),
  280. LETTER('b',M_IMPLOSIVE,0),
  281. 0, // open-o
  282. LETTER('c',M_CURL,0),
  283. LETTER('d',M_RETROFLEX,0),
  284. LETTER('d',M_IMPLOSIVE,0),
  285. LETTER('e',M_REVERSED,0), // U+258
  286. 0, // schwa
  287. LETTER(L_SCHWA,M_HOOK,0),
  288. 0, // open-e
  289. LETTER(L_OPEN_E,M_REVERSED,0),
  290. LETTER(L_OPEN_E,M_HOOK,M_REVERSED),
  291. 0,//LETTER(L_OPEN_E,M_CLOSED,M_REVERSED),
  292. LETTER('j',M_BAR,0),
  293. LETTER('g',M_IMPLOSIVE,0), // U+260
  294. LETTER('g',0,0),
  295. LETTER('g',M_SMALLCAP,0),
  296. LETTER(L_GAMMA,0,0),
  297. 0, // ramshorn
  298. LETTER('h',M_TURNED,0),
  299. LETTER('h',M_HOOK,0),
  300. 0,//LETTER(L_HENG,M_HOOK,0),
  301. LETTER('i',M_BAR,0), // U+268
  302. LETTER(L_IOTA,0,0),
  303. LETTER('i',M_SMALLCAP,0),
  304. LETTER('l',M_TILDE,0),
  305. LETTER('l',M_BAR,0),
  306. LETTER('l',M_RETROFLEX,0),
  307. LIGATURE('l','z',0),
  308. LETTER('m',M_TURNED,0),
  309. 0,//LETTER('m',M_TURNED,M_LEG), // U+270
  310. LETTER('m',M_HOOK,0),
  311. 0,//LETTER('n',M_LEFTHOOK,0),
  312. LETTER('n',M_RETROFLEX,0),
  313. LETTER('n',M_SMALLCAP,0),
  314. LETTER('o',M_BAR,0),
  315. LIGATURE('o','e',M_SMALLCAP),
  316. 0,//LETTER(L_OMEGA,M_CLOSED,0),
  317. LETTER(L_PHI,0,0), // U+278
  318. LETTER('r',M_TURNED,0),
  319. LETTER(L_RLONG,M_TURNED,0),
  320. LETTER('r',M_RETROFLEX,M_TURNED),
  321. 0,//LETTER('r',M_LEG,0),
  322. LETTER('r',M_RETROFLEX,0),
  323. 0, // r-tap
  324. LETTER(L_RTAP,M_REVERSED,0),
  325. LETTER('r',M_SMALLCAP,0), // U+280
  326. LETTER('r',M_TURNED,M_SMALLCAP),
  327. LETTER('s',M_RETROFLEX,0),
  328. 0, // esh
  329. LETTER('j',M_HOOK,0), //LETTER('j',M_HOOK,M_BAR),
  330. LETTER(L_ESH,M_REVERSED,0),
  331. LETTER(L_ESH,M_CURL,0),
  332. LETTER('t',M_TURNED,0),
  333. LETTER('t',M_RETROFLEX,0), // U+288
  334. LETTER('u',M_BAR,0),
  335. LETTER(L_UPSILON,0,0),
  336. LETTER('v',M_HOOK,0),
  337. LETTER('v',M_TURNED,0),
  338. LETTER('w',M_TURNED,0),
  339. LETTER('y',M_TURNED,0),
  340. LETTER('y',M_SMALLCAP,0),
  341. LETTER('z',M_RETROFLEX,0), // U+290
  342. LETTER('z',M_CURL,0),
  343. 0, // ezh
  344. LETTER(L_EZH,M_CURL,0),
  345. 0, // glottal stop
  346. LETTER(L_GLOTTAL,M_REVERSED,0),
  347. LETTER(L_GLOTTAL,M_TURNED,0),
  348. 0,//LETTER('c',M_LONG,0),
  349. 0, // bilabial click // U+298
  350. LETTER('b',M_SMALLCAP,0),
  351. 0,//LETTER(L_OPEN_E,M_CLOSED,0),
  352. LETTER('g',M_IMPLOSIVE,M_SMALLCAP),
  353. LETTER('h',M_SMALLCAP,0),
  354. LETTER('j',M_CURL,0),
  355. LETTER('k',M_TURNED,0),
  356. LETTER('l',M_SMALLCAP,0),
  357. LETTER('q',M_HOOK,0), // U+2a0
  358. LETTER(L_GLOTTAL,M_STROKE,0),
  359. LETTER(L_GLOTTAL,M_STROKE,M_REVERSED),
  360. LIGATURE('d','z',0),
  361. 0, // dezh
  362. LIGATURE('d','z',M_CURL),
  363. LIGATURE('t','s',0),
  364. 0, // tesh
  365. LIGATURE('t','s',M_CURL),
  366. };
  367. static int LookupLetter2(Translator *tr, unsigned int letter, char *ph_buf)
  368. { //========================================================================
  369. int len;
  370. char single_letter[10];
  371. single_letter[0] = 0;
  372. single_letter[1] = '_';
  373. len = utf8_out(letter, &single_letter[2]);
  374. single_letter[len+2] = ' ';
  375. single_letter[len+3] = 0;
  376. if(Lookup(tr, &single_letter[1], ph_buf) == 0)
  377. {
  378. single_letter[1] = ' ';
  379. if(Lookup(tr, &single_letter[2], ph_buf) == 0)
  380. {
  381. TranslateRules(tr, &single_letter[2], ph_buf, 20, NULL,0,NULL);
  382. }
  383. }
  384. return(ph_buf[0]);
  385. }
  386. void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf)
  387. {//=========================================================================
  388. // lookup the character in the accents table
  389. int accent_data = 0;
  390. int accent1 = 0;
  391. int accent2 = 0;
  392. int flags1, flags2;
  393. int basic_letter;
  394. int letter2=0;
  395. char ph_letter1[30];
  396. char ph_letter2[30];
  397. char ph_accent1[30];
  398. char ph_accent2[30];
  399. ph_accent2[0] = 0;
  400. if((letter >= 0xe0) && (letter < 0x17f))
  401. {
  402. accent_data = letter_accents_0e0[letter - 0xe0];
  403. }
  404. else if((letter >= 0x250) && (letter <= 0x2a8))
  405. {
  406. accent_data = letter_accents_250[letter - 0x250];
  407. }
  408. if(accent_data != 0)
  409. {
  410. basic_letter = (accent_data & 0x3f) + 59;
  411. if(basic_letter < 'a')
  412. basic_letter = non_ascii_tab[basic_letter-59];
  413. if(accent_data & M_LIGATURE)
  414. {
  415. letter2 = (accent_data >> 6) & 0x3f;
  416. letter2 += 59;
  417. accent2 = (accent_data >> 12) & 0x7;
  418. }
  419. else
  420. {
  421. accent1 = (accent_data >> 6) & 0x1f;
  422. accent2 = (accent_data >> 11) & 0xf;
  423. }
  424. if((accent1==0) && !(accent_data & M_LIGATURE))
  425. {
  426. // just a letter name, not an accented character or ligature
  427. return;
  428. }
  429. if((flags1 = Lookup(tr, accents_tab[accent1].name, ph_accent1)) != 0)
  430. {
  431. if(LookupLetter2(tr, basic_letter, ph_letter1) != 0)
  432. {
  433. if(accent2 != 0)
  434. {
  435. if((flags2 = Lookup(tr, accents_tab[accent2].name, ph_accent2)) == 0)
  436. {
  437. // break;
  438. }
  439. if(flags2 & FLAG_ACCENT_BEFORE)
  440. {
  441. strcpy(ph_buf,ph_accent2);
  442. ph_buf += strlen(ph_buf);
  443. ph_accent2[0] = 0;
  444. }
  445. }
  446. if(letter2 != 0)
  447. {
  448. //ligature
  449. LookupLetter2(tr, letter2, ph_letter2);
  450. sprintf(ph_buf,"%s%c%s%c%s%s",ph_accent1, phonPAUSE_VSHORT, ph_letter1, phonSTRESS_P, ph_letter2, ph_accent2);
  451. }
  452. else
  453. {
  454. if(accent1 == 0)
  455. strcpy(ph_buf, ph_letter1);
  456. else if((tr->langopts.accents & 1) || (flags1 & FLAG_ACCENT_BEFORE) || (accents_tab[accent1].accent_flags & 1))
  457. sprintf(ph_buf,"%s%c%c%s", ph_accent1, phonPAUSE_VSHORT, phonSTRESS_P, ph_letter1);
  458. else
  459. sprintf(ph_buf,"%c%s%c%s%c", phonSTRESS_2, ph_letter1, phonPAUSE_VSHORT, ph_accent1, phonPAUSE_VSHORT);
  460. }
  461. }
  462. }
  463. }
  464. } // end of LookupAccentedLetter
  465. void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf1, int control)
  466. {//==============================================================================================
  467. // control, bit 0: not the first letter of a word
  468. int len;
  469. static char single_letter[10] = {0,0};
  470. unsigned int dict_flags[2];
  471. char ph_buf3[40];
  472. ph_buf1[0] = 0;
  473. len = utf8_out(letter,&single_letter[2]);
  474. single_letter[len+2] = ' ';
  475. if(next_byte == -1)
  476. {
  477. // speaking normal text, not individual characters
  478. if(Lookup(tr, &single_letter[2], ph_buf1) != 0)
  479. return;
  480. single_letter[1] = '_';
  481. if(Lookup(tr, &single_letter[1], ph_buf3) != 0)
  482. return; // the character is specified as _* so ignore it when speaking normal text
  483. // check whether this character is specified for English
  484. if(tr->translator_name == L('e','n'))
  485. return; // we are already using English
  486. SetTranslator2("en");
  487. if(Lookup(translator2, &single_letter[2], ph_buf3) != 0)
  488. {
  489. // yes, switch to English and re-translate the word
  490. sprintf(ph_buf1,"%c",phonSWITCH);
  491. }
  492. SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
  493. return;
  494. }
  495. if((letter <= 32) || iswspace(letter))
  496. {
  497. // lookup space as _&32 etc.
  498. sprintf(&single_letter[1],"_#%d ",letter);
  499. Lookup(tr, &single_letter[1], ph_buf1);
  500. return;
  501. }
  502. if(next_byte != ' ')
  503. next_byte = RULE_SPELLING;
  504. single_letter[3+len] = next_byte; // follow by space-space if the end of the word, or space-31
  505. single_letter[1] = '_';
  506. // if the $accent flag is set for this letter, use the accents table (below)
  507. dict_flags[1] = 0;
  508. if(Lookup(tr, &single_letter[1], ph_buf3) == 0)
  509. {
  510. single_letter[1] = ' ';
  511. if(Lookup(tr, &single_letter[2], ph_buf3) == 0)
  512. {
  513. TranslateRules(tr, &single_letter[2], ph_buf3, sizeof(ph_buf3), NULL,FLAG_NO_TRACE,NULL);
  514. }
  515. }
  516. if(ph_buf3[0] == 0)
  517. {
  518. LookupAccentedLetter(tr, letter, ph_buf3);
  519. }
  520. strcpy(ph_buf1, ph_buf3);
  521. if((ph_buf1[0] == 0) || (ph_buf1[0] == phonSWITCH))
  522. {
  523. return;
  524. }
  525. dict_flags[0] = 0;
  526. dict_flags[1] = 0;
  527. SetWordStress(tr, ph_buf1, dict_flags, -1, control & 1);
  528. } // end of LookupLetter
  529. // unicode ranges for non-ascii digits 0-9
  530. static const int number_ranges[] = {
  531. 0x660, 0x6f0, // arabic
  532. 0x966, 0x9e6, 0xa66, 0xae6, 0xb66, 0xbe6, 0xc66, 0xce6, 0xd66, // indic
  533. 0xe50, 0xed0, 0xf20, 0x1040, 0x1090,
  534. 0 }; // these must be in ascending order
  535. int NonAsciiNumber(int letter)
  536. {//============================
  537. // Change non-ascii digit into ascii digit '0' to '9', (or -1 if not)
  538. const int *p;
  539. int base;
  540. for(p=number_ranges; (base = *p) != 0; p++)
  541. {
  542. if(letter < base)
  543. break; // not found
  544. if(letter < (base+10))
  545. return(letter-base+'0');
  546. }
  547. return(-1);
  548. }
  549. #define L_SUB 0x4000 // subscript
  550. #define L_SUP 0x8000 // superscript
  551. static const char *modifiers[] = {NULL, "_sub", "_sup", NULL};
  552. // this list must be in ascending order
  553. static unsigned short derived_letters[] = {
  554. 0x00aa, 'a'+L_SUP,
  555. 0x00b2, '2'+L_SUP,
  556. 0x00b3, '3'+L_SUP,
  557. 0x00b9, '1'+L_SUP,
  558. 0x00ba, 'o'+L_SUP,
  559. 0x02b0, 'h'+L_SUP,
  560. 0x02b1, 0x266+L_SUP,
  561. 0x02b2, 'j'+L_SUP,
  562. 0x02b3, 'r'+L_SUP,
  563. 0x02b4, 0x279+L_SUP,
  564. 0x02b5, 0x27b+L_SUP,
  565. 0x02b6, 0x281+L_SUP,
  566. 0x02b7, 'w'+L_SUP,
  567. 0x02b8, 'y'+L_SUP,
  568. 0x02c0, 0x294+L_SUP,
  569. 0x02c1, 0x295+L_SUP,
  570. 0x02e0, 0x263+L_SUP,
  571. 0x02e1, 'l'+L_SUP,
  572. 0x02e2, 's'+L_SUP,
  573. 0x02e3, 'x'+L_SUP,
  574. 0x2070, '0'+L_SUP,
  575. 0x2071, 'i'+L_SUP,
  576. 0x2074, '4'+L_SUP,
  577. 0x2075, '5'+L_SUP,
  578. 0x2076, '6'+L_SUP,
  579. 0x2077, '7'+L_SUP,
  580. 0x2078, '8'+L_SUP,
  581. 0x2079, '9'+L_SUP,
  582. 0x207a, '+'+L_SUP,
  583. 0x207b, '-'+L_SUP,
  584. 0x207c, '='+L_SUP,
  585. 0x207d, '('+L_SUP,
  586. 0x207e, ')'+L_SUP,
  587. 0x207f, 'n'+L_SUP,
  588. 0x2080, '0'+L_SUB,
  589. 0x2081, '1'+L_SUB,
  590. 0x2082, '2'+L_SUB,
  591. 0x2083, '3'+L_SUB,
  592. 0x2084, '4'+L_SUB,
  593. 0x2085, '5'+L_SUB,
  594. 0x2086, '6'+L_SUB,
  595. 0x2087, '7'+L_SUB,
  596. 0x2088, '8'+L_SUB,
  597. 0x2089, '9'+L_SUB,
  598. 0x208a, '+'+L_SUB,
  599. 0x208b, '-'+L_SUB,
  600. 0x208c, '='+L_SUB,
  601. 0x208d, '('+L_SUB,
  602. 0x208e, ')'+L_SUB,
  603. 0x2090, 'a'+L_SUB,
  604. 0x2091, 'e'+L_SUB,
  605. 0x2092, 'o'+L_SUB,
  606. 0x2093, 'x'+L_SUB,
  607. 0x2094, 0x259+L_SUB,
  608. 0x2095, 'h'+L_SUB,
  609. 0x2096, 'k'+L_SUB,
  610. 0x2097, 'l'+L_SUB,
  611. 0x2098, 'm'+L_SUB,
  612. 0x2099, 'n'+L_SUB,
  613. 0x209a, 'p'+L_SUB,
  614. 0x209b, 's'+L_SUB,
  615. 0x209c, 't'+L_SUB,
  616. 0,0};
  617. static const char *hex_letters[] = {"'e:j","b'i:","s'i:","d'i:","'i:","'ef"}; // names, using phonemes available to all languages
  618. int IsSuperscript(int letter)
  619. {//===========================
  620. // is this a subscript or superscript letter ?
  621. int ix;
  622. int c;
  623. for(ix=0; (c = derived_letters[ix]) != 0; ix+=2)
  624. {
  625. if(c > letter)
  626. break;
  627. if(c == letter)
  628. return(derived_letters[ix+1]);
  629. }
  630. return(0);
  631. }
  632. int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
  633. {//=========================================================================
  634. // get pronunciation for an isolated letter
  635. // return number of bytes used by the letter
  636. // control bit 0: a non-initial letter in a word
  637. // bit 1: say 'capital'
  638. // bit 2: say character code for unknown letters
  639. int n_bytes;
  640. int letter;
  641. int len;
  642. int ix;
  643. int c;
  644. char *p2;
  645. char *pbuf;
  646. const char *modifier;
  647. ALPHABET *alphabet;
  648. int al_offset;
  649. int al_flags;
  650. int language;
  651. int number;
  652. int phontab_1;
  653. int speak_letter_number;
  654. char capital[30];
  655. char ph_buf[80];
  656. char ph_buf2[80];
  657. char ph_alphabet[80];
  658. char hexbuf[12];
  659. static char pause_string[] = {phonPAUSE, 0};
  660. ph_buf[0] = 0;
  661. ph_alphabet[0] = 0;
  662. capital[0] = 0;
  663. phontab_1 = translator->phoneme_tab_ix;
  664. n_bytes = utf8_in(&letter,word);
  665. if((letter & 0xfff00) == 0x0e000)
  666. {
  667. letter &= 0xff; // uncode private usage area
  668. }
  669. if(control & 2)
  670. {
  671. // include CAPITAL information
  672. if(iswupper2(letter))
  673. {
  674. Lookup(tr, "_cap", capital);
  675. }
  676. }
  677. letter = towlower2(letter);
  678. LookupLetter(tr, letter, word[n_bytes], ph_buf, control & 1);
  679. if(ph_buf[0] == 0)
  680. {
  681. // is this a subscript or superscript letter ?
  682. if((c = IsSuperscript(letter)) != 0)
  683. {
  684. letter = c & 0x3fff;
  685. if((control & 4 ) && ((modifier = modifiers[c >> 14]) != NULL))
  686. {
  687. // don't say "superscript" during normal text reading
  688. Lookup(tr, modifier, capital);
  689. if(capital[0] == 0)
  690. {
  691. capital[2] = SetTranslator2("en"); // overwrites previous contents of translator2
  692. Lookup(translator2, modifier, &capital[3]);
  693. if(capital[3] != 0)
  694. {
  695. capital[0] = phonPAUSE;
  696. capital[1] = phonSWITCH;
  697. len = strlen(&capital[3]);
  698. capital[len+3] = phonSWITCH;
  699. capital[len+4] = phontab_1;
  700. capital[len+5] = 0;
  701. }
  702. }
  703. }
  704. }
  705. LookupLetter(tr, letter, word[n_bytes], ph_buf, control & 1);
  706. }
  707. if(ph_buf[0] == phonSWITCH)
  708. {
  709. strcpy(phonemes,ph_buf);
  710. return(0);
  711. }
  712. if((ph_buf[0] == 0) && ((number = NonAsciiNumber(letter)) > 0))
  713. {
  714. // convert a non-ascii number to 0-9
  715. LookupLetter(tr, number, 0, ph_buf, control & 1);
  716. }
  717. al_offset = 0;
  718. al_flags = 0;
  719. if((alphabet = AlphabetFromChar(letter)) != NULL)
  720. {
  721. al_offset = alphabet->offset;
  722. al_flags = alphabet->flags;
  723. }
  724. if(alphabet != current_alphabet)
  725. {
  726. // speak the name of the alphabet
  727. current_alphabet = alphabet;
  728. if((alphabet != NULL) && !(al_flags & AL_DONT_NAME) && (al_offset != translator->letter_bits_offset))
  729. {
  730. if((al_flags & AL_DONT_NAME) || (al_offset == translator->langopts.alt_alphabet) || (al_offset == translator->langopts.our_alphabet))
  731. {
  732. // don't say the alphabet name
  733. }
  734. else
  735. {
  736. ph_buf2[0] = 0;
  737. if(Lookup(translator, alphabet->name, ph_alphabet) == 0) // the original language for the current voice
  738. {
  739. // Can't find the local name for this alphabet, use the English name
  740. ph_alphabet[2] = SetTranslator2("en"); // overwrites previous contents of translator2
  741. Lookup(translator2, alphabet->name, ph_buf2);
  742. }
  743. else if(translator != tr)
  744. {
  745. phontab_1 = tr->phoneme_tab_ix;
  746. strcpy(ph_buf2, ph_alphabet);
  747. ph_alphabet[2] = translator->phoneme_tab_ix;
  748. }
  749. if(ph_buf2[0] != 0)
  750. {
  751. // we used a different language for the alphabet name (now in ph_buf2)
  752. ph_alphabet[0] = phonPAUSE;
  753. ph_alphabet[1] = phonSWITCH;
  754. strcpy(&ph_alphabet[3], ph_buf2);
  755. len = strlen(ph_buf2) + 3;
  756. ph_alphabet[len] = phonSWITCH;
  757. ph_alphabet[len+1] = phontab_1;
  758. ph_alphabet[len+2] = 0;
  759. }
  760. }
  761. }
  762. }
  763. // caution: SetWordStress() etc don't expect phonSWITCH + phoneme table number
  764. if(ph_buf[0] == 0)
  765. {
  766. if((al_offset != 0) && (al_offset == translator->langopts.alt_alphabet))
  767. language = translator->langopts.alt_alphabet_lang;
  768. else
  769. if((alphabet != NULL) && (alphabet->language != 0) && !(al_flags & AL_NOT_LETTERS))
  770. language = alphabet->language;
  771. else
  772. language = L('e','n');
  773. if((language != tr->translator_name) || (language == L('k','o')))
  774. {
  775. char *p3;
  776. int initial, code;
  777. char hangul_buf[12];
  778. // speak in the language for this alphabet (or English)
  779. ph_buf[2] = SetTranslator2(WordToString2(language));
  780. if(translator2 != NULL)
  781. {
  782. if(((code = letter - 0xac00) >= 0) && (letter <= 0xd7af))
  783. {
  784. // Special case for Korean letters.
  785. // break a syllable hangul into 2 or 3 individual jamo
  786. hangul_buf[0] = ' ';
  787. p3 = &hangul_buf[1];
  788. if((initial = (code/28)/21) != 11)
  789. {
  790. p3 += utf8_out(initial + 0x1100, p3);
  791. }
  792. utf8_out(((code/28) % 21) + 0x1161, p3); // medial
  793. utf8_out((code % 28) + 0x11a7, &p3[3]); // final
  794. p3[6] = ' ';
  795. p3[7] = 0;
  796. ph_buf[3] = 0;
  797. TranslateRules(translator2, &hangul_buf[1], &ph_buf[3], sizeof(ph_buf)-3, NULL, 0, NULL);
  798. SetWordStress(translator2, &ph_buf[3], NULL, -1, 0);
  799. }
  800. else
  801. {
  802. LookupLetter(translator2, letter, word[n_bytes], &ph_buf[3], control & 1);
  803. }
  804. if(ph_buf[3] == phonSWITCH)
  805. {
  806. // another level of language change
  807. ph_buf[2] = SetTranslator2(&ph_buf[4]);
  808. LookupLetter(translator2, letter, word[n_bytes], &ph_buf[3], control & 1);
  809. }
  810. SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
  811. if(ph_buf[3] != 0)
  812. {
  813. ph_buf[0] = phonPAUSE;
  814. ph_buf[1] = phonSWITCH;
  815. len = strlen(&ph_buf[3]) + 3;
  816. ph_buf[len] = phonSWITCH; // switch back
  817. ph_buf[len+1] = tr->phoneme_tab_ix;
  818. ph_buf[len+2] = 0;
  819. }
  820. }
  821. }
  822. }
  823. if(ph_buf[0] == 0)
  824. {
  825. // character name not found
  826. if(ph_buf[0]== 0)
  827. {
  828. speak_letter_number = 1;
  829. if(!(al_flags & AL_NO_SYMBOL))
  830. {
  831. if(iswalpha2(letter))
  832. Lookup(translator, "_?A", ph_buf);
  833. if((ph_buf[0]==0) && !iswspace(letter))
  834. Lookup(translator, "_??", ph_buf);
  835. if(ph_buf[0] == 0)
  836. {
  837. EncodePhonemes("l'et@", ph_buf, NULL);
  838. }
  839. }
  840. if(!(control & 4) && (al_flags & AL_NOT_CODE))
  841. {
  842. // don't speak the character code number, unless we want full details of this character
  843. speak_letter_number = 0;
  844. }
  845. // if((ph_alphabet[0] != 0) && speak_letter_number)
  846. // ph_buf[0] = 0; // don't speak "letter" if we speak alphabet name
  847. if(speak_letter_number)
  848. {
  849. if(al_offset == 0x2800)
  850. {
  851. // braille dots symbol, list the numbered dots
  852. p2 = hexbuf;
  853. for(ix=0; ix<8; ix++)
  854. {
  855. if(letter & (1 << ix))
  856. {
  857. *p2++ = '1'+ix;
  858. }
  859. }
  860. *p2 = 0;
  861. }
  862. else
  863. {
  864. // speak the hexadecimal number of the character code
  865. sprintf(hexbuf,"%x",letter);
  866. }
  867. pbuf = ph_buf;
  868. for(p2 = hexbuf; *p2 != 0; p2++)
  869. {
  870. pbuf += strlen(pbuf);
  871. *pbuf++ = phonPAUSE_VSHORT;
  872. LookupLetter(translator, *p2, 0, pbuf, 1);
  873. if(((pbuf[0] == 0) || (pbuf[0]==phonSWITCH)) && (*p2 >= 'a'))
  874. {
  875. // This language has no translation for 'a' to 'f', speak English names using base phonemes
  876. EncodePhonemes(hex_letters[*p2 - 'a'], pbuf, NULL);
  877. }
  878. }
  879. strcat(pbuf, pause_string);
  880. }
  881. }
  882. }
  883. len = strlen(phonemes);
  884. if(tr->langopts.accents & 2) // 'capital' before or after the word ?
  885. sprintf(ph_buf2,"%c%s%s%s",0xff,ph_alphabet,ph_buf,capital);
  886. else
  887. sprintf(ph_buf2,"%c%s%s%s",0xff,ph_alphabet,capital,ph_buf); // the 0xff marker will be removed or replaced in SetSpellingStress()
  888. if((len + strlen(ph_buf2)) < N_WORD_PHONEMES)
  889. {
  890. strcpy(&phonemes[len],ph_buf2);
  891. }
  892. return(n_bytes);
  893. } // end of TranslateLetter
  894. void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars)
  895. {//=============================================================================
  896. // Individual letter names, reduce the stress of some.
  897. int ix;
  898. unsigned int c;
  899. int n_stress=0;
  900. int prev = 0;
  901. int count;
  902. unsigned char buf[N_WORD_PHONEMES];
  903. for(ix=0; (c = phonemes[ix]) != 0; ix++)
  904. {
  905. if((c == phonSTRESS_P) && (prev != phonSWITCH))
  906. {
  907. n_stress++;
  908. }
  909. buf[ix] = prev = c;
  910. }
  911. buf[ix] = 0;
  912. count = 0;
  913. prev = 0;
  914. for(ix=0; (c = buf[ix]) != 0; ix++)
  915. {
  916. if((c == phonSTRESS_P) && (n_chars > 1) && (prev != phonSWITCH))
  917. {
  918. count++;
  919. if(tr->langopts.spelling_stress == 1)
  920. {
  921. // stress on initial letter when spelling
  922. if(count > 1)
  923. c = phonSTRESS_3;
  924. }
  925. else
  926. {
  927. if(count != n_stress)
  928. {
  929. if(((count % 3) != 0) || (count == n_stress-1))
  930. c = phonSTRESS_3; // reduce to secondary stress
  931. }
  932. }
  933. }
  934. else if(c == 0xff)
  935. {
  936. if((control < 2) || (ix==0))
  937. continue; // don't insert pauses
  938. if(control == 4)
  939. c = phonPAUSE; // pause after each character
  940. if(((count % 3) == 0) || (control > 2))
  941. c = phonPAUSE_NOLINK; // pause following a primary stress
  942. else
  943. c = phonPAUSE_VSHORT;
  944. }
  945. *phonemes++ = prev = c;
  946. }
  947. if(control >= 2)
  948. *phonemes++ = phonPAUSE_NOLINK;
  949. *phonemes = 0;
  950. } // end of SetSpellingStress
  951. // Numbers
  952. static char ph_ordinal2[12];
  953. static char ph_ordinal2x[12];
  954. static int CheckDotOrdinal(Translator *tr, char *word, char *word_end, WORD_TAB *wtab, int roman)
  955. {//==============================================================================================
  956. int ordinal = 0;
  957. int c2;
  958. int nextflags;
  959. if((tr->langopts.numbers & NUM_ORDINAL_DOT) && ((word_end[0] == '.') || (wtab[0].flags & FLAG_HAS_DOT)) && !(wtab[1].flags & FLAG_NOSPACE))
  960. {
  961. if(roman || !(wtab[1].flags & FLAG_FIRST_UPPER))
  962. {
  963. if(word_end[0] == '.')
  964. utf8_in(&c2, &word_end[2]);
  965. else
  966. utf8_in(&c2, &word_end[0]);
  967. if((word_end[0] != 0) && (word_end[1] != 0) && ((c2 == 0) || (wtab[0].flags & FLAG_COMMA_AFTER) || IsAlpha(c2)))
  968. {
  969. // ordinal number is indicated by dot after the number
  970. // but not if the next word starts with an upper-case letter
  971. // (c2 == 0) is for cases such as, "2.,"
  972. ordinal = 2;
  973. if(word_end[0] == '.')
  974. word_end[0] = ' ';
  975. if((roman==0) && (tr->translator_name == L('h','u')))
  976. {
  977. // lang=hu don't treat dot as ordinal indicator if the next word is a month name ($alt). It may have a suffix.
  978. nextflags = 0;
  979. if(IsAlpha(c2))
  980. {
  981. nextflags = TranslateWord(tr, &word_end[2], 0, NULL, NULL);
  982. }
  983. if((tr->prev_dict_flags[0] & FLAG_ALT_TRANS) && ((c2 == 0) || (wtab[0].flags & FLAG_COMMA_AFTER) || iswdigit(c2)))
  984. ordinal = 0; // TEST 09.02.10
  985. if(nextflags & FLAG_ALT_TRANS)
  986. ordinal = 0;
  987. if(nextflags & FLAG_ALT3_TRANS)
  988. {
  989. if(word[-2] == '-')
  990. ordinal = 0; // eg. december 2-5. között
  991. if(tr->prev_dict_flags[0] & (FLAG_ALT_TRANS | FLAG_ALT3_TRANS))
  992. ordinal = 0x22;
  993. }
  994. }
  995. }
  996. }
  997. }
  998. return(ordinal);
  999. } // end of CheckDotOrdinal
  1000. static int hu_number_e(const char *word, int thousandplex, int value)
  1001. {//==================================================================
  1002. // lang-hu: variant form of numbers when followed by hyphen and a suffix starting with 'a' or 'e' (but not a, e, az, ez, azt, ezt, att. ett
  1003. if((word[0] == 'a') || (word[0] == 'e'))
  1004. {
  1005. if((word[1] == ' ') || (word[1] == 'z') || ((word[1] == 't') && (word[2] == 't')))
  1006. return(0);
  1007. if(((thousandplex==1) || ((value % 1000) == 0)) && (word[1] == 'l'))
  1008. return(0); // 1000-el
  1009. return(1);
  1010. }
  1011. return(0);
  1012. } // end of hu_numnber_e
  1013. int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
  1014. {//=========================================================================
  1015. int c;
  1016. char *p;
  1017. const char *p2;
  1018. int acc;
  1019. int prev;
  1020. int value;
  1021. int subtract;
  1022. int repeat = 0;
  1023. int n_digits = 0;
  1024. char *word_start;
  1025. int num_control = 0;
  1026. unsigned int flags[2];
  1027. char ph_roman[30];
  1028. char number_chars[N_WORD_BYTES];
  1029. static const char *roman_numbers = "ixcmvld";
  1030. static int roman_values[] = {1,10,100,1000,5,50,500};
  1031. acc = 0;
  1032. prev = 0;
  1033. subtract = 0x7fff;
  1034. ph_out[0] = 0;
  1035. flags[0] = 0;
  1036. flags[1] = 0;
  1037. if(((tr->langopts.numbers & NUM_ROMAN_CAPITALS) && !(wtab[0].flags & FLAG_ALL_UPPER)) || IsDigit09(word[-2]))
  1038. return(0); // not '2xx'
  1039. if(word[1] == ' ')
  1040. {
  1041. if((tr->langopts.numbers & (NUM_ROMAN_CAPITALS | NUM_ROMAN_ORDINAL | NUM_ORDINAL_DOT)) && (wtab[0].flags & FLAG_HAS_DOT))
  1042. {
  1043. // allow single letter Roman ordinal followed by dot.
  1044. }
  1045. else
  1046. return(0); // only one letter, don't speak as a Roman Number
  1047. }
  1048. word_start = word;
  1049. while((c = *word++) != ' ')
  1050. {
  1051. if((p2 = strchr(roman_numbers,c)) == NULL)
  1052. return(0);
  1053. value = roman_values[p2 - roman_numbers];
  1054. if(value == prev)
  1055. {
  1056. repeat++;
  1057. if(repeat >= 3)
  1058. return(0);
  1059. }
  1060. else
  1061. repeat = 0;
  1062. if((prev > 1) && (prev != 10) && (prev != 100))
  1063. {
  1064. if(value >= prev)
  1065. return(0);
  1066. }
  1067. if((prev != 0) && (prev < value))
  1068. {
  1069. if(((acc % 10) != 0) || ((prev*10) < value))
  1070. return(0);
  1071. subtract = prev;
  1072. value -= subtract;
  1073. }
  1074. else if(value >= subtract)
  1075. return(0);
  1076. else
  1077. acc += prev;
  1078. prev = value;
  1079. n_digits++;
  1080. }
  1081. if(IsDigit09(word[0]))
  1082. return(0); // eg. 'xx2'
  1083. acc += prev;
  1084. if(acc < tr->langopts.min_roman)
  1085. return(0);
  1086. if(acc > tr->langopts.max_roman)
  1087. return(0);
  1088. Lookup(tr, "_roman",ph_roman); // precede by "roman" if _rom is defined in *_list
  1089. p = &ph_out[0];
  1090. if((tr->langopts.numbers & NUM_ROMAN_AFTER) == 0)
  1091. {
  1092. strcpy(ph_out,ph_roman);
  1093. p = &ph_out[strlen(ph_roman)];
  1094. }
  1095. sprintf(number_chars," %d %s ",acc, tr->langopts.roman_suffix);
  1096. if(word[0] == '.')
  1097. {
  1098. // dot has not been removed. This implies that there was no space after it
  1099. return(0);
  1100. }
  1101. if(CheckDotOrdinal(tr, word_start, word, wtab, 1))
  1102. wtab[0].flags |= FLAG_ORDINAL;
  1103. if(tr->langopts.numbers & NUM_ROMAN_ORDINAL)
  1104. {
  1105. if(tr->translator_name == L('h','u'))
  1106. {
  1107. if(!(wtab[0].flags & FLAG_ORDINAL))
  1108. {
  1109. if((wtab[0].flags & FLAG_HYPHEN_AFTER) && hu_number_e(word, 0, acc))
  1110. {
  1111. // should use the 'e' form of the number
  1112. num_control |= 1;
  1113. }
  1114. else
  1115. return(0);
  1116. }
  1117. }
  1118. else
  1119. {
  1120. wtab[0].flags |= FLAG_ORDINAL;
  1121. }
  1122. }
  1123. tr->prev_dict_flags[0] = 0;
  1124. tr->prev_dict_flags[1] = 0;
  1125. TranslateNumber(tr, &number_chars[2], p, flags, wtab, num_control);
  1126. if(tr->langopts.numbers & NUM_ROMAN_AFTER)
  1127. strcat(ph_out,ph_roman);
  1128. return(1);
  1129. } // end of TranslateRoman
  1130. static const char *M_Variant(int value)
  1131. {//====================================
  1132. // returns M, or perhaps MA or MB for some cases
  1133. int teens = 0;
  1134. if(((value % 100) > 10) && ((value % 100) < 20))
  1135. teens = 1;
  1136. switch((translator->langopts.numbers2 >> 6) & 0x7)
  1137. {
  1138. case 1: // lang=ru use singular for xx1 except for x11
  1139. if((teens == 0) && ((value % 10) == 1))
  1140. return("1M");
  1141. break;
  1142. case 2: // lang=cs,sk
  1143. if((value >= 2) && (value <= 4))
  1144. return("0MA");
  1145. break;
  1146. case 3: // lang=pl
  1147. if((teens == 0) && (((value % 10) >= 2) && ((value % 10) <= 4)))
  1148. return("0MA");
  1149. break;
  1150. case 4: // lang=lt
  1151. if((teens == 1) || ((value % 10) == 0))
  1152. return("0MB");
  1153. if((value % 10) == 1)
  1154. return("0MA");
  1155. break;
  1156. case 5: // lang=bs,hr,sr
  1157. if(teens == 0)
  1158. {
  1159. if((value % 10) == 1)
  1160. return("1M");
  1161. if(((value % 10) >= 2) && ((value % 10) <= 4))
  1162. return("0MA");
  1163. }
  1164. break;
  1165. }
  1166. return("0M");
  1167. }
  1168. static int LookupThousands(Translator *tr, int value, int thousandplex, int thousands_exact, char *ph_out)
  1169. {//=======================================================================================================
  1170. // thousands_exact: bit 0 no hundreds,tens,or units, bit 1 ordinal numberr
  1171. int found;
  1172. int found_value=0;
  1173. char string[12];
  1174. char ph_of[12];
  1175. char ph_thousands[40];
  1176. char ph_buf[40];
  1177. ph_of[0] = 0;
  1178. // first look for a match with the exact value of thousands
  1179. if(value > 0)
  1180. {
  1181. if(thousands_exact & 1)
  1182. {
  1183. if(thousands_exact & 2)
  1184. {
  1185. // ordinal number
  1186. sprintf(string,"_%dM%do",value,thousandplex);
  1187. found_value = Lookup(tr, string, ph_thousands);
  1188. }
  1189. if(!found_value & (number_control & 1))
  1190. {
  1191. // look for the 'e' variant
  1192. sprintf(string,"_%dM%de",value,thousandplex);
  1193. found_value = Lookup(tr, string, ph_thousands);
  1194. }
  1195. if(!found_value)
  1196. {
  1197. // is there a different pronunciation if there are no hundreds,tens,or units ? (LANG=ta)
  1198. sprintf(string,"_%dM%dx",value,thousandplex);
  1199. found_value = Lookup(tr, string, ph_thousands);
  1200. }
  1201. }
  1202. if(found_value == 0)
  1203. {
  1204. sprintf(string,"_%dM%d",value,thousandplex);
  1205. found_value = Lookup(tr, string, ph_thousands);
  1206. }
  1207. }
  1208. if(found_value == 0)
  1209. {
  1210. if((value % 100) >= 20)
  1211. {
  1212. Lookup(tr, "_0of", ph_of);
  1213. }
  1214. found = 0;
  1215. if(thousands_exact & 1)
  1216. {
  1217. if(thousands_exact & 2)
  1218. {
  1219. // ordinal number
  1220. sprintf(string,"_%s%do",M_Variant(value), thousandplex);
  1221. found = Lookup(tr, string, ph_thousands);
  1222. }
  1223. if(!found && (number_control & 1))
  1224. {
  1225. // look for the 'e' variant
  1226. sprintf(string,"_%s%de",M_Variant(value), thousandplex);
  1227. found = Lookup(tr, string, ph_thousands);
  1228. }
  1229. if(!found)
  1230. {
  1231. // is there a different pronunciation if there are no hundreds,tens,or units ?
  1232. sprintf(string,"_%s%dx",M_Variant(value), thousandplex);
  1233. found = Lookup(tr, string, ph_thousands);
  1234. }
  1235. }
  1236. if(found == 0)
  1237. {
  1238. sprintf(string,"_%s%d",M_Variant(value), thousandplex);
  1239. if(Lookup(tr, string, ph_thousands) == 0)
  1240. {
  1241. if(thousandplex > 3)
  1242. {
  1243. sprintf(string,"_0M%d", thousandplex-1);
  1244. if(Lookup(tr, string, ph_buf) == 0)
  1245. {
  1246. // say "millions" if this name is not available and neither is the next lower
  1247. Lookup(tr, "_0M2", ph_thousands);
  1248. speak_missing_thousands = 3;
  1249. }
  1250. }
  1251. if(ph_thousands[0] == 0)
  1252. {
  1253. // repeat "thousand" if higher order names are not available
  1254. sprintf(string,"_%dM1",value);
  1255. if((found_value = Lookup(tr, string, ph_thousands)) == 0)
  1256. Lookup(tr, "_0M1", ph_thousands);
  1257. speak_missing_thousands = 2;
  1258. }
  1259. }
  1260. }
  1261. }
  1262. sprintf(ph_out,"%s%s",ph_of,ph_thousands);
  1263. if((value == 1) && (thousandplex == 1) && (tr->langopts.numbers & NUM_OMIT_1_THOUSAND))
  1264. return(1);
  1265. return(found_value);
  1266. } // end f LookupThousands
  1267. static int LookupNum2(Translator *tr, int value, int thousandplex, const int control, char *ph_out)
  1268. {//=============================================================================
  1269. // Lookup a 2 digit number
  1270. // control bit 0: ordinal number
  1271. // control bit 1: final tens and units (not number of thousands) (use special form of '1', LANG=de "eins")
  1272. // control bit 2: tens and units only, no higher digits
  1273. // control bit 3: use feminine form of '2' (for thousands
  1274. // control bit 4: speak zero tens
  1275. // control bit 5: variant of ordinal number (lang=hu)
  1276. // bit 8 followed by decimal fraction
  1277. // bit 9: use #f form for both tens and units (lang=ml)
  1278. int found;
  1279. int ix;
  1280. int units;
  1281. int tens;
  1282. int is_ordinal;
  1283. int used_and=0;
  1284. int found_ordinal = 0;
  1285. int next_phtype;
  1286. int ord_type = 'o';
  1287. char string[12]; // for looking up entries in *_list
  1288. char ph_ordinal[20];
  1289. char ph_tens[50];
  1290. char ph_digits[50];
  1291. char ph_and[12];
  1292. units = value % 10;
  1293. tens = value / 10;
  1294. found = 0;
  1295. ph_ordinal[0] = 0;
  1296. ph_tens[0] = 0;
  1297. ph_digits[0] = 0;
  1298. ph_and[0] = 0;
  1299. if(control & 0x20)
  1300. {
  1301. ord_type = 'q';
  1302. }
  1303. is_ordinal = control & 1;
  1304. if((control & 2) && (n_digit_lookup == 2))
  1305. {
  1306. // pronunciation of the final 2 digits has already been found
  1307. strcpy(ph_out, digit_lookup);
  1308. }
  1309. else
  1310. {
  1311. if(digit_lookup[0] == 0)
  1312. {
  1313. // is there a special pronunciation for this 2-digit number
  1314. if(control & 8)
  1315. {
  1316. // is there a feminine or thousands-variant form?
  1317. sprintf(string,"_%dfx",value);
  1318. if((found = Lookup(tr, string, ph_digits)) == 0)
  1319. {
  1320. sprintf(string,"_%df",value);
  1321. found = Lookup(tr, string, ph_digits);
  1322. }
  1323. }
  1324. else if(is_ordinal)
  1325. {
  1326. strcpy(ph_ordinal, ph_ordinal2);
  1327. if(control & 4)
  1328. {
  1329. sprintf(string,"_%d%cx",value,ord_type); // LANG=hu, special word for 1. 2. when there are no higher digits
  1330. if((found = Lookup(tr, string, ph_digits)) != 0)
  1331. {
  1332. if(ph_ordinal2x[0] != 0)
  1333. strcpy(ph_ordinal, ph_ordinal2x); // alternate pronunciation (lang=an)
  1334. }
  1335. }
  1336. if(found == 0)
  1337. {
  1338. sprintf(string,"_%d%c",value,ord_type);
  1339. found = Lookup(tr, string, ph_digits);
  1340. }
  1341. found_ordinal = found;
  1342. }
  1343. if(found == 0)
  1344. {
  1345. if(control & 2)
  1346. {
  1347. // the final tens and units of a number
  1348. if(number_control & 1)
  1349. {
  1350. // look for 'e' variant
  1351. sprintf(string,"_%de",value);
  1352. found = Lookup(tr, string, ph_digits);
  1353. }
  1354. }
  1355. else
  1356. {
  1357. // followed by hundreds or thousands etc
  1358. if((tr->langopts.numbers2 & NUM2_ORDINAL_AND_THOUSANDS) && (thousandplex <= 1))
  1359. sprintf(string, "_%do", value); // LANG=TA
  1360. else
  1361. sprintf(string, "_%da", value);
  1362. found = Lookup(tr, string, ph_digits);
  1363. }
  1364. if(!found)
  1365. {
  1366. if((is_ordinal) && (tr->langopts.numbers2 & NUM2_NO_TEEN_ORDINALS))
  1367. {
  1368. // don't use numbers 10-99 to make ordinals, always use _1Xo etc (lang=pt)
  1369. }
  1370. else
  1371. {
  1372. sprintf(string,"_%d",value);
  1373. found = Lookup(tr, string, ph_digits);
  1374. }
  1375. }
  1376. }
  1377. }
  1378. // no, speak as tens+units
  1379. if((value < 10) && (control & 0x10))
  1380. {
  1381. // speak leading zero
  1382. Lookup(tr, "_0", ph_tens);
  1383. }
  1384. else
  1385. {
  1386. if(found)
  1387. {
  1388. ph_tens[0] = 0;
  1389. }
  1390. else
  1391. {
  1392. if(is_ordinal)
  1393. {
  1394. sprintf(string,"_%dX%c", tens, ord_type);
  1395. if(Lookup(tr, string, ph_tens) != 0)
  1396. {
  1397. found_ordinal = 1;
  1398. if((units != 0) && (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL))
  1399. {
  1400. // Use the ordinal form of tens as well as units. Add the ordinal ending
  1401. strcat(ph_tens, ph_ordinal2);
  1402. }
  1403. }
  1404. }
  1405. if(found_ordinal == 0)
  1406. {
  1407. if(control & 0x200)
  1408. sprintf(string, "_%dXf", tens);
  1409. else
  1410. sprintf(string,"_%dX", tens);
  1411. Lookup(tr, string, ph_tens);
  1412. }
  1413. if((ph_tens[0] == 0) && (tr->langopts.numbers & NUM_VIGESIMAL))
  1414. {
  1415. // tens not found, (for example) 73 is 60+13
  1416. units = (value % 20);
  1417. sprintf(string,"_%dX", tens & 0xfe);
  1418. Lookup(tr, string, ph_tens);
  1419. }
  1420. ph_digits[0] = 0;
  1421. if(units > 0)
  1422. {
  1423. found = 0;
  1424. if((control & 2) && (digit_lookup[0] != 0))
  1425. {
  1426. // we have an entry for this digit (possibly together with the next word)
  1427. strcpy(ph_digits, digit_lookup);
  1428. found_ordinal = 1;
  1429. ph_ordinal[0] = 0;
  1430. }
  1431. else
  1432. {
  1433. if(control & 8)
  1434. {
  1435. // is there a variant form of this number?
  1436. sprintf(string,"_%df",units);
  1437. found = Lookup(tr, string, ph_digits);
  1438. }
  1439. if((is_ordinal) && ((tr->langopts.numbers & NUM_SWAP_TENS) == 0))
  1440. {
  1441. // ordinal
  1442. sprintf(string,"_%d%c",units,ord_type);
  1443. if((found = Lookup(tr, string, ph_digits)) != 0)
  1444. {
  1445. found_ordinal = 1;
  1446. }
  1447. }
  1448. if(found == 0)
  1449. {
  1450. if((number_control & 1) && (control & 2))
  1451. {
  1452. // look for 'e' variant
  1453. sprintf(string,"_%de",units);
  1454. found = Lookup(tr, string, ph_digits);
  1455. }
  1456. else if(((control & 2) == 0) || ((tr->langopts.numbers & NUM_SWAP_TENS) != 0))
  1457. {
  1458. // followed by hundreds or thousands (or tens)
  1459. if((tr->langopts.numbers2 & NUM2_ORDINAL_AND_THOUSANDS) && (thousandplex <= 1))
  1460. sprintf(string, "_%do", units); // LANG=TA, only for 100s, 1000s
  1461. else
  1462. sprintf(string, "_%da", units);
  1463. found = Lookup(tr, string, ph_digits);
  1464. }
  1465. }
  1466. if(found == 0)
  1467. {
  1468. sprintf(string,"_%d",units);
  1469. Lookup(tr, string, ph_digits);
  1470. }
  1471. }
  1472. }
  1473. }
  1474. }
  1475. if((is_ordinal) && (found_ordinal == 0) && (ph_ordinal[0] == 0))
  1476. {
  1477. if((value >= 20) && (((value % 10) == 0) || (tr->langopts.numbers & NUM_SWAP_TENS)))
  1478. Lookup(tr, "_ord20", ph_ordinal);
  1479. if(ph_ordinal[0] == 0)
  1480. Lookup(tr, "_ord", ph_ordinal);
  1481. }
  1482. if((tr->langopts.numbers & (NUM_SWAP_TENS | NUM_AND_UNITS)) && (ph_tens[0] != 0) && (ph_digits[0] != 0))
  1483. {
  1484. Lookup(tr, "_0and", ph_and);
  1485. if((is_ordinal) && (tr->langopts.numbers2 & NUM2_ORDINAL_NO_AND))
  1486. ph_and[0] = 0;
  1487. if(tr->langopts.numbers & NUM_SWAP_TENS)
  1488. sprintf(ph_out,"%s%s%s%s",ph_digits, ph_and, ph_tens, ph_ordinal);
  1489. else
  1490. sprintf(ph_out,"%s%s%s%s",ph_tens, ph_and, ph_digits, ph_ordinal);
  1491. used_and = 1;
  1492. }
  1493. else
  1494. {
  1495. if(tr->langopts.numbers & NUM_SINGLE_VOWEL)
  1496. {
  1497. // remove vowel from the end of tens if units starts with a vowel (LANG=Italian)
  1498. if(((ix = strlen(ph_tens)-1) >= 0) && (ph_digits[0] != 0))
  1499. {
  1500. if((next_phtype = phoneme_tab[(unsigned int)(ph_digits[0])]->type) == phSTRESS)
  1501. next_phtype = phoneme_tab[(unsigned int)(ph_digits[1])]->type;
  1502. if((phoneme_tab[(unsigned int)(ph_tens[ix])]->type == phVOWEL) && (next_phtype == phVOWEL))
  1503. ph_tens[ix] = 0;
  1504. }
  1505. }
  1506. if((tr->langopts.numbers2 & NUM2_ORDINAL_DROP_VOWEL) && (ph_ordinal[0] != 0))
  1507. {
  1508. ix = sprintf(ph_out,"%s%s", ph_tens, ph_digits);
  1509. if((ix > 0) && (phoneme_tab[(unsigned char)(ph_out[ix-1])]->type == phVOWEL))
  1510. ix--;
  1511. sprintf(&ph_out[ix], "%s", ph_ordinal);
  1512. }
  1513. else
  1514. {
  1515. sprintf(ph_out,"%s%s%s",ph_tens, ph_digits, ph_ordinal);
  1516. }
  1517. }
  1518. }
  1519. if(tr->langopts.numbers & NUM_SINGLE_STRESS_L)
  1520. {
  1521. // only one primary stress, on the first part (tens)
  1522. found = 0;
  1523. for(ix=0; ix < (signed)strlen(ph_out); ix++)
  1524. {
  1525. if(ph_out[ix] == phonSTRESS_P)
  1526. {
  1527. if(found)
  1528. ph_out[ix] = phonSTRESS_3;
  1529. else
  1530. found = 1;
  1531. }
  1532. }
  1533. }
  1534. else if(tr->langopts.numbers & NUM_SINGLE_STRESS)
  1535. {
  1536. // only one primary stress
  1537. found = 0;
  1538. for(ix=strlen(ph_out)-1; ix>=0; ix--)
  1539. {
  1540. if(ph_out[ix] == phonSTRESS_P)
  1541. {
  1542. if(found)
  1543. ph_out[ix] = phonSTRESS_3;
  1544. else
  1545. found = 1;
  1546. }
  1547. }
  1548. }
  1549. return(used_and);
  1550. } // end of LookupNum2
  1551. static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null, int thousandplex, int control)
  1552. {//=============================================================================================================
  1553. // Translate a 3 digit number
  1554. // control bit 0, previous thousands
  1555. // bit 1, ordinal number
  1556. // bit 5 variant form of ordinal number
  1557. // bit 8 followed by decimal fraction
  1558. int found;
  1559. int hundreds;
  1560. int tensunits;
  1561. int x;
  1562. int ix;
  1563. int exact;
  1564. int ordinal;
  1565. int tplex;
  1566. int say_zero_hundred=0;
  1567. int say_one_hundred;
  1568. char string[12]; // for looking up entries in **_list
  1569. char buf1[100];
  1570. char buf2[100];
  1571. char ph_100[20];
  1572. char ph_10T[20];
  1573. char ph_digits[50];
  1574. char ph_thousands[50];
  1575. char ph_hundred_and[12];
  1576. char ph_thousand_and[12];
  1577. ordinal = control & 0x22;
  1578. hundreds = value / 100;
  1579. tensunits = value % 100;
  1580. buf1[0] = 0;
  1581. ph_thousands[0] = 0;
  1582. ph_thousand_and[0] = 0;
  1583. if((tr->langopts.numbers & NUM_ZERO_HUNDRED) && ((control & 1) || (hundreds >= 10)))
  1584. {
  1585. say_zero_hundred = 1; // lang=vi
  1586. }
  1587. if((hundreds > 0) || say_zero_hundred)
  1588. {
  1589. found = 0;
  1590. if(ordinal && (tensunits == 0))
  1591. {
  1592. // ordinal number, with no tens or units
  1593. found = Lookup(tr, "_0Co", ph_100);
  1594. }
  1595. if(found == 0)
  1596. {
  1597. if(tensunits==0)
  1598. {
  1599. // special form for exact hundreds?
  1600. found = Lookup(tr, "_0C0", ph_100);
  1601. }
  1602. if(!found)
  1603. {
  1604. Lookup(tr, "_0C", ph_100);
  1605. }
  1606. }
  1607. if(((tr->langopts.numbers & NUM_1900) != 0) && (hundreds == 19))
  1608. {
  1609. // speak numbers such as 1984 as years: nineteen-eighty-four
  1610. // ph_100[0] = 0; // don't say "hundred", we also need to surpess "and"
  1611. }
  1612. else if(hundreds >= 10)
  1613. {
  1614. ph_digits[0] = 0;
  1615. exact = 0;
  1616. if ((value % 1000) == 0)
  1617. exact = 1;
  1618. tplex = thousandplex+1;
  1619. if(tr->langopts.numbers2 & NUM2_MYRIADS)
  1620. {
  1621. tplex = 0;
  1622. }
  1623. if(LookupThousands(tr, hundreds / 10, tplex, exact | ordinal, ph_10T) == 0)
  1624. {
  1625. x = 0;
  1626. if(tr->langopts.numbers2 & (1 << tplex))
  1627. x = 8; // use variant (feminine) for before thousands and millions
  1628. if(tr->translator_name == L('m','l'))
  1629. x = 0x208;
  1630. LookupNum2(tr, hundreds/10, thousandplex, x, ph_digits);
  1631. }
  1632. if(tr->langopts.numbers2 & 0x200)
  1633. sprintf(ph_thousands,"%s%c%s%c",ph_10T,phonEND_WORD,ph_digits,phonEND_WORD); // say "thousands" before its number, not after
  1634. else
  1635. sprintf(ph_thousands,"%s%c%s%c",ph_digits,phonEND_WORD,ph_10T,phonEND_WORD);
  1636. hundreds %= 10;
  1637. if((hundreds == 0) && (say_zero_hundred == 0))
  1638. ph_100[0] = 0;
  1639. suppress_null = 1;
  1640. control |= 1;
  1641. }
  1642. ph_digits[0] = 0;
  1643. if((hundreds > 0) || say_zero_hundred)
  1644. {
  1645. if((tr->langopts.numbers & NUM_AND_HUNDRED) && ((control & 1) || (ph_thousands[0] != 0)))
  1646. {
  1647. Lookup(tr, "_0and", ph_thousand_and);
  1648. }
  1649. suppress_null = 1;
  1650. found = 0;
  1651. if((ordinal)
  1652. && ((tensunits == 0) || (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL)))
  1653. {
  1654. // ordinal number
  1655. sprintf(string, "_%dCo", hundreds);
  1656. found = Lookup(tr, string, ph_digits);
  1657. if((tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL) && (tensunits > 0))
  1658. {
  1659. // Use ordinal form of hundreds, as well as for tens and units
  1660. // Add ordinal suffix to the hundreds
  1661. strcat(ph_digits, ph_ordinal2);
  1662. }
  1663. }
  1664. if((hundreds == 0) && say_zero_hundred)
  1665. {
  1666. Lookup(tr, "_0", ph_digits);
  1667. }
  1668. else
  1669. {
  1670. if((hundreds==1) && (tr->langopts.numbers2 & NUM2_OMIT_1_HUNDRED_ONLY) && ((control & 1)==0))
  1671. {
  1672. // only look for special 100 if there are previous thousands
  1673. }
  1674. else
  1675. {
  1676. if((!found) && (tensunits == 0))
  1677. {
  1678. // is there a special pronunciation for exactly n00 ?
  1679. sprintf(string,"_%dC0",hundreds);
  1680. found = Lookup(tr, string, ph_digits);
  1681. }
  1682. if(!found)
  1683. {
  1684. sprintf(string,"_%dC",hundreds);
  1685. found = Lookup(tr, string, ph_digits); // is there a specific pronunciation for n-hundred ?
  1686. }
  1687. }
  1688. if(found)
  1689. {
  1690. ph_100[0] = 0;
  1691. }
  1692. else
  1693. {
  1694. say_one_hundred = 1;
  1695. if(hundreds == 1)
  1696. {
  1697. if((tr->langopts.numbers & NUM_OMIT_1_HUNDRED) != 0)
  1698. say_one_hundred = 0;
  1699. }
  1700. if(say_one_hundred != 0)
  1701. {
  1702. LookupNum2(tr, hundreds, thousandplex, 0, ph_digits);
  1703. }
  1704. }
  1705. }
  1706. }
  1707. sprintf(buf1,"%s%s%s%s",ph_thousands,ph_thousand_and,ph_digits,ph_100);
  1708. }
  1709. ph_hundred_and[0] = 0;
  1710. if(tensunits > 0)
  1711. {
  1712. if((control & 2) && (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL))
  1713. {
  1714. // Don't use "and" if we apply ordinal to both hundreds and units
  1715. }
  1716. else
  1717. {
  1718. if((value > 100) || ((control & 1) && (thousandplex==0)))
  1719. {
  1720. if((tr->langopts.numbers & NUM_HUNDRED_AND) || ((tr->langopts.numbers & NUM_HUNDRED_AND_DIGIT) && (tensunits < 10)))
  1721. {
  1722. Lookup(tr, "_0and", ph_hundred_and);
  1723. }
  1724. }
  1725. if((tr->langopts.numbers & NUM_THOUSAND_AND) && (hundreds == 0) && ((control & 1) || (ph_thousands[0] != 0)))
  1726. {
  1727. Lookup(tr, "_0and", ph_hundred_and);
  1728. }
  1729. }
  1730. }
  1731. buf2[0] = 0;
  1732. if((tensunits != 0) || (suppress_null == 0))
  1733. {
  1734. x = 0;
  1735. if(thousandplex==0)
  1736. {
  1737. x = 2; // allow "eins" for 1 rather than "ein"
  1738. if(ordinal)
  1739. x = 3; // ordinal number
  1740. if((value < 100) && !(control & 1))
  1741. x |= 4; // tens and units only, no higher digits
  1742. if(ordinal & 0x20)
  1743. x |= 0x20; // variant form of ordinal number
  1744. }
  1745. else
  1746. {
  1747. if(tr->langopts.numbers2 & (1 << thousandplex))
  1748. x = 8; // use variant (feminine) for before thousands and millions
  1749. }
  1750. if((tr->translator_name == L('m','l')) && (thousandplex == 1))
  1751. {
  1752. x |= 0x208; // use #f form for both tens and units
  1753. }
  1754. if((tr->langopts.numbers2 & NUM2_ZERO_TENS) && ((control & 1) || (hundreds > 0)))
  1755. {
  1756. // LANG=zh,
  1757. x |= 0x10;
  1758. }
  1759. if(LookupNum2(tr, tensunits, thousandplex, x | (control & 0x100), buf2) != 0)
  1760. {
  1761. if(tr->langopts.numbers & NUM_SINGLE_AND)
  1762. ph_hundred_and[0] = 0; // don't put 'and' after 'hundred' if there's 'and' between tens and units
  1763. }
  1764. }
  1765. else
  1766. {
  1767. if(ph_ordinal2[0] != 0)
  1768. {
  1769. ix = strlen(buf1);
  1770. if((ix > 0) && (buf1[ix-1] == phonPAUSE_SHORT))
  1771. buf1[ix-1] = 0; // remove pause before addding ordinal suffix
  1772. strcpy(buf2, ph_ordinal2);
  1773. }
  1774. }
  1775. sprintf(ph_out,"%s%s%c%s",buf1,ph_hundred_and,phonEND_WORD,buf2);
  1776. return(0);
  1777. } // end of LookupNum3
  1778. bool CheckThousandsGroup(char *word, int group_len)
  1779. {//================================================
  1780. // Is this a group of 3 digits which looks like a thousands group?
  1781. int ix;
  1782. if(IsDigit09(word[group_len]) || IsDigit09(-1))
  1783. return(false);
  1784. for(ix=0; ix < group_len; ix++)
  1785. {
  1786. if(!IsDigit09(word[ix]))
  1787. return(false);
  1788. }
  1789. return(true);
  1790. }
  1791. static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned int *flags, WORD_TAB *wtab, int control)
  1792. {//=====================================================================================================================
  1793. // Number translation with various options
  1794. // the "word" may be up to 4 digits
  1795. // "words" of 3 digits may be preceded by another number "word" for thousands or millions
  1796. int n_digits;
  1797. int value;
  1798. int ix;
  1799. int digix;
  1800. unsigned char c;
  1801. int suppress_null = 0;
  1802. int decimal_point = 0;
  1803. int thousandplex = 0;
  1804. int thousands_exact = 1;
  1805. int thousands_inc = 0;
  1806. int prev_thousands = 0;
  1807. int ordinal = 0;
  1808. int this_value;
  1809. int decimal_count;
  1810. int max_decimal_count;
  1811. int decimal_mode;
  1812. int suffix_ix;
  1813. int skipwords = 0;
  1814. int group_len;
  1815. int len;
  1816. char *p;
  1817. char string[32]; // for looking up entries in **_list
  1818. char buf1[100];
  1819. char ph_append[50];
  1820. char ph_buf[200];
  1821. char ph_buf2[50];
  1822. char ph_zeros[50];
  1823. char suffix[30]; // string[] must be long enough for sizeof(suffix)+2
  1824. char buf_digit_lookup[50];
  1825. static const char str_pause[2] = {phonPAUSE_NOLINK,0};
  1826. *flags = 0;
  1827. n_digit_lookup = 0;
  1828. buf_digit_lookup[0] = 0;
  1829. digit_lookup = buf_digit_lookup;
  1830. number_control = control;
  1831. for(ix=0; IsDigit09(word[ix]); ix++) ;
  1832. n_digits = ix;
  1833. value = this_value = atoi(word);
  1834. group_len = 3;
  1835. if(tr->langopts.numbers2 & NUM2_MYRIADS)
  1836. group_len = 4;
  1837. // is there a previous thousands part (as a previous "word") ?
  1838. if((n_digits == group_len) && (word[-2] == tr->langopts.thousands_sep) && IsDigit09(word[-3]))
  1839. {
  1840. prev_thousands = 1;
  1841. }
  1842. else if((tr->langopts.thousands_sep == ' ') || (tr->langopts.numbers & NUM_ALLOW_SPACE))
  1843. {
  1844. // thousands groups can be separated by spaces
  1845. if((n_digits == 3) && !(wtab->flags & FLAG_MULTIPLE_SPACES) && IsDigit09(word[-2]))
  1846. {
  1847. prev_thousands = 1;
  1848. }
  1849. }
  1850. if(prev_thousands == 0)
  1851. {
  1852. speak_missing_thousands = 0;
  1853. }
  1854. ph_ordinal2[0] = 0;
  1855. ph_zeros[0] = 0;
  1856. if(prev_thousands || (word[0] != '0'))
  1857. {
  1858. // don't check for ordinal if the number has a leading zero
  1859. if((ordinal = CheckDotOrdinal(tr, word, &word[ix], wtab, 0)) != 0)
  1860. {
  1861. // dot_ordinal = 1;
  1862. }
  1863. }
  1864. if((word[ix] == '.') && !IsDigit09(word[ix+1]) && !IsDigit09(word[ix+2]) && !(wtab[1].flags & FLAG_NOSPACE))
  1865. {
  1866. // remove dot unless followed by another number
  1867. word[ix] = 0;
  1868. }
  1869. if((ordinal == 0) || (tr->translator_name == L('h','u')))
  1870. {
  1871. // NOTE lang=hu, allow both dot and ordinal suffix, eg. "december 21.-én"
  1872. // look for an ordinal number suffix after the number
  1873. ix++;
  1874. p = suffix;
  1875. if(wtab[0].flags & FLAG_HYPHEN_AFTER)
  1876. {
  1877. *p++ = '-';
  1878. ix++;
  1879. }
  1880. while((word[ix] != 0) && (word[ix] != ' ') && (ix < (int)(sizeof(suffix)-1)))
  1881. {
  1882. *p++ = word[ix++];
  1883. }
  1884. *p = 0;
  1885. if(suffix[0] != 0)
  1886. {
  1887. if((tr->langopts.ordinal_indicator != NULL) && (strcmp(suffix, tr->langopts.ordinal_indicator) == 0))
  1888. {
  1889. ordinal = 2;
  1890. }
  1891. else if(!IsDigit09(suffix[0])) // not _#9 (tab)
  1892. {
  1893. sprintf(string,"_#%s",suffix);
  1894. if(Lookup(tr, string, ph_ordinal2))
  1895. {
  1896. // this is an ordinal suffix
  1897. ordinal = 2;
  1898. flags[0] |= FLAG_SKIPWORDS;
  1899. skipwords = 1;
  1900. sprintf(string,"_x#%s",suffix);
  1901. Lookup(tr, string, ph_ordinal2x); // is there an alternate pronunciation?
  1902. }
  1903. }
  1904. }
  1905. }
  1906. if(wtab[0].flags & FLAG_ORDINAL)
  1907. ordinal = 2;
  1908. ph_append[0] = 0;
  1909. ph_buf2[0] = 0;
  1910. if((word[0] == '0') && (prev_thousands == 0) && (word[1] != ' ') && (word[1] != tr->langopts.decimal_sep))
  1911. {
  1912. if((n_digits == 2) && (word[3] == ':') && IsDigit09(word[5]) && isspace(word[7]))
  1913. {
  1914. // looks like a time 02:30, omit the leading zero
  1915. }
  1916. else
  1917. {
  1918. if(n_digits > 3)
  1919. {
  1920. flags[0] &= ~FLAG_SKIPWORDS;
  1921. return(0); // long number string with leading zero, speak as individual digits
  1922. }
  1923. // speak leading zeros
  1924. for(ix=0; (word[ix] == '0') && (ix < (n_digits-1)); ix++)
  1925. {
  1926. Lookup(tr, "_0", &ph_zeros[strlen(ph_zeros)]);
  1927. }
  1928. }
  1929. }
  1930. if((tr->langopts.numbers & NUM_ALLOW_SPACE) && (word[n_digits] == ' '))
  1931. thousands_inc = 1;
  1932. else if(word[n_digits] == tr->langopts.thousands_sep)
  1933. thousands_inc = 2;
  1934. suffix_ix = n_digits+2;
  1935. if(thousands_inc > 0)
  1936. {
  1937. // if the following "words" are three-digit groups, count them and add
  1938. // a "thousand"/"million" suffix to this one
  1939. digix = n_digits + thousands_inc;
  1940. while(((wtab[thousandplex+1].flags & FLAG_MULTIPLE_SPACES) == 0) && CheckThousandsGroup(&word[digix], group_len))
  1941. {
  1942. for(ix=0; ix<group_len; ix++)
  1943. {
  1944. if(word[digix+ix] != '0')
  1945. {
  1946. thousands_exact = 0;
  1947. break;
  1948. }
  1949. }
  1950. thousandplex++;
  1951. digix += group_len;
  1952. if((word[digix] == tr->langopts.thousands_sep) || ((tr->langopts.numbers & NUM_ALLOW_SPACE) && (word[digix] == ' ')))
  1953. {
  1954. suffix_ix = digix+2;
  1955. digix += thousands_inc;
  1956. }
  1957. else
  1958. break;
  1959. }
  1960. }
  1961. if((value == 0) && prev_thousands)
  1962. {
  1963. suppress_null = 1;
  1964. }
  1965. if(tr->translator_name == L('h','u'))
  1966. {
  1967. // variant form of numbers when followed by hyphen and a suffix starting with 'a' or 'e' (but not a, e, az, ez, azt, ezt
  1968. if((wtab[thousandplex].flags & FLAG_HYPHEN_AFTER) && (thousands_exact==1) && hu_number_e(&word[suffix_ix], thousandplex, value))
  1969. {
  1970. number_control |= 1; // use _1e variant of number
  1971. }
  1972. }
  1973. if((word[n_digits] == tr->langopts.decimal_sep) && IsDigit09(word[n_digits+1]))
  1974. {
  1975. // this "word" ends with a decimal point
  1976. Lookup(tr, "_dpt", ph_append);
  1977. decimal_point = 0x100;
  1978. }
  1979. else if(suppress_null == 0)
  1980. {
  1981. if(thousands_inc > 0)
  1982. {
  1983. if(thousandplex > 0)
  1984. // if((thousandplex > 0) && (value < 1000))
  1985. {
  1986. if((suppress_null == 0) && (LookupThousands(tr,value,thousandplex, thousands_exact, ph_append)))
  1987. {
  1988. // found an exact match for N thousand
  1989. value = 0;
  1990. suppress_null = 1;
  1991. }
  1992. }
  1993. }
  1994. }
  1995. else
  1996. if(speak_missing_thousands == 1)
  1997. {
  1998. // speak this thousandplex if there was no word for the previous thousandplex
  1999. sprintf(string,"_0M%d",thousandplex+1);
  2000. if(Lookup(tr, string, buf1)==0)
  2001. {
  2002. sprintf(string,"_0M%d",thousandplex);
  2003. Lookup(tr, string, ph_append);
  2004. }
  2005. }
  2006. if((ph_append[0] == 0) && (word[n_digits] == '.') && (thousandplex == 0))
  2007. {
  2008. Lookup(tr, "_.", ph_append);
  2009. }
  2010. if(thousandplex == 0)
  2011. {
  2012. char *p2;
  2013. // look for combinations of the number with the next word
  2014. p = word;
  2015. while(IsDigit09(p[1])) p++; // just use the last digit
  2016. if(IsDigit09(p[-1]))
  2017. {
  2018. p2 = p - 1;
  2019. if(LookupDictList(tr, &p2, buf_digit_lookup, flags, FLAG_SUFX, wtab)) // lookup 2 digits
  2020. {
  2021. n_digit_lookup = 2;
  2022. }
  2023. }
  2024. // if((buf_digit_lookup[0] == 0) && (*p != '0') && (dot_ordinal==0))
  2025. if((buf_digit_lookup[0] == 0) && (*p != '0'))
  2026. {
  2027. // LANG=hu ?
  2028. // not found, lookup only the last digit (?? but not if dot-ordinal has been found)
  2029. if(LookupDictList(tr, &p, buf_digit_lookup, flags, FLAG_SUFX, wtab)) // don't match '0', or entries with $only
  2030. {
  2031. n_digit_lookup = 1;
  2032. }
  2033. }
  2034. if(prev_thousands == 0)
  2035. {
  2036. if((decimal_point == 0) && (ordinal == 0))
  2037. {
  2038. // Look for special pronunciation for this number in isolation (LANG=kl)
  2039. sprintf(string, "_%dn", value);
  2040. if(Lookup(tr, string, ph_out))
  2041. {
  2042. return(1);
  2043. }
  2044. }
  2045. if(tr->langopts.numbers2 & NUM2_PERCENT_BEFORE)
  2046. {
  2047. // LANG=si, say "percent" before the number
  2048. p2 = word;
  2049. while((*p2 != ' ') && (*p2 != 0))
  2050. {
  2051. p2++;
  2052. }
  2053. if(p2[1] == '%')
  2054. {
  2055. Lookup(tr, "%", ph_out);
  2056. ph_out += strlen(ph_out);
  2057. p2[1] = ' ';
  2058. }
  2059. }
  2060. }
  2061. }
  2062. LookupNum3(tr, value, ph_buf, suppress_null, thousandplex, prev_thousands | ordinal | decimal_point);
  2063. if((thousandplex > 0) && (tr->langopts.numbers2 & 0x200))
  2064. sprintf(ph_out,"%s%s%c%s%s",ph_zeros,ph_append,phonEND_WORD,ph_buf2,ph_buf); // say "thousands" before its number
  2065. else
  2066. sprintf(ph_out,"%s%s%s%c%s",ph_zeros,ph_buf2,ph_buf,phonEND_WORD,ph_append);
  2067. while(decimal_point)
  2068. {
  2069. n_digits++;
  2070. decimal_count = 0;
  2071. while(IsDigit09(word[n_digits+decimal_count]))
  2072. decimal_count++;
  2073. // if(decimal_count > 1)
  2074. {
  2075. max_decimal_count = 2;
  2076. switch(decimal_mode = (tr->langopts.numbers & 0xe000))
  2077. {
  2078. case NUM_DFRACTION_4:
  2079. max_decimal_count = 5;
  2080. case NUM_DFRACTION_2:
  2081. // French/Polish decimal fraction
  2082. while(word[n_digits] == '0')
  2083. {
  2084. Lookup(tr, "_0", buf1);
  2085. strcat(ph_out,buf1);
  2086. decimal_count--;
  2087. n_digits++;
  2088. }
  2089. if((decimal_count <= max_decimal_count) && IsDigit09(word[n_digits]))
  2090. {
  2091. LookupNum3(tr, atoi(&word[n_digits]), buf1, 0,0,0);
  2092. strcat(ph_out,buf1);
  2093. n_digits += decimal_count;
  2094. }
  2095. break;
  2096. case NUM_DFRACTION_1: // italian, say "hundredths" if leading zero
  2097. case NUM_DFRACTION_5: // hungarian, always say "tenths" etc.
  2098. case NUM_DFRACTION_6: // kazakh, always say "tenths" etc, before the decimal fraction
  2099. LookupNum3(tr, atoi(&word[n_digits]), ph_buf, 0,0,0);
  2100. if((word[n_digits]=='0') || (decimal_mode != NUM_DFRACTION_1))
  2101. {
  2102. // decimal part has leading zeros, so add a "hundredths" or "thousandths" suffix
  2103. sprintf(string,"_0Z%d",decimal_count);
  2104. if(Lookup(tr, string, buf1) == 0)
  2105. break; // revert to speaking single digits
  2106. if(decimal_mode == NUM_DFRACTION_6)
  2107. strcat(ph_out, buf1);
  2108. else
  2109. strcat(ph_buf, buf1);
  2110. }
  2111. strcat(ph_out,ph_buf);
  2112. n_digits += decimal_count;
  2113. break;
  2114. case NUM_DFRACTION_3:
  2115. // Romanian decimal fractions
  2116. if((decimal_count <= 4) && (word[n_digits] != '0'))
  2117. {
  2118. LookupNum3(tr, atoi(&word[n_digits]), buf1, 0,0,0);
  2119. strcat(ph_out,buf1);
  2120. n_digits += decimal_count;
  2121. }
  2122. break;
  2123. case NUM_DFRACTION_7:
  2124. // alternative form of decimal fraction digits, except the final digit
  2125. while(decimal_count-- > 1)
  2126. {
  2127. sprintf(string,"_%cd", word[n_digits]);
  2128. if(Lookup(tr, string, buf1) == 0)
  2129. break;
  2130. n_digits++;
  2131. strcat(ph_out, buf1);
  2132. }
  2133. }
  2134. }
  2135. while(IsDigit09(c = word[n_digits]) && (strlen(ph_out) < (N_WORD_PHONEMES - 10)))
  2136. {
  2137. // speak any remaining decimal fraction digits individually
  2138. value = word[n_digits++] - '0';
  2139. LookupNum2(tr, value, 0, 2, buf1);
  2140. len = strlen(ph_out);
  2141. sprintf(&ph_out[len],"%c%s", phonEND_WORD, buf1);
  2142. }
  2143. // something after the decimal part ?
  2144. if(Lookup(tr, "_dpt2", buf1))
  2145. strcat(ph_out,buf1);
  2146. if((c == tr->langopts.decimal_sep) && IsDigit09(word[n_digits+1]))
  2147. {
  2148. Lookup(tr, "_dpt", buf1);
  2149. strcat(ph_out,buf1);
  2150. }
  2151. else
  2152. {
  2153. decimal_point = 0;
  2154. }
  2155. }
  2156. if((ph_out[0] != 0) && (ph_out[0] != phonSWITCH))
  2157. {
  2158. int next_char;
  2159. char *p;
  2160. p = &word[n_digits+1];
  2161. p += utf8_in(&next_char,p);
  2162. if((tr->langopts.numbers & NUM_NOPAUSE) && (next_char == ' '))
  2163. utf8_in(&next_char,p);
  2164. if(!iswalpha2(next_char) && (thousands_exact==0))
  2165. // if(!iswalpha2(next_char) && !((wtab[thousandplex].flags & FLAG_HYPHEN_AFTER) && (thousands_exact != 0)))
  2166. strcat(ph_out,str_pause); // don't add pause for 100s, 6th, etc.
  2167. }
  2168. *flags |= FLAG_FOUND;
  2169. speak_missing_thousands--;
  2170. if(skipwords)
  2171. dictionary_skipwords = skipwords;
  2172. return(1);
  2173. } // end of TranslateNumber_1
  2174. int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *flags, WORD_TAB *wtab, int control)
  2175. {//=============================================================================================================
  2176. if((option_sayas == SAYAS_DIGITS1) || (wtab[0].flags & FLAG_INDIVIDUAL_DIGITS))
  2177. return(0); // speak digits individually
  2178. if(tr->langopts.numbers != 0)
  2179. {
  2180. return(TranslateNumber_1(tr, word1, ph_out, flags, wtab, control));
  2181. }
  2182. return(0);
  2183. } // end of TranslateNumber