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.

tr_languages.c 69KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617
  1. /*
  2. * Copyright (C) 2005 to 2015 by Jonathan Duddington
  3. * email: [email protected]
  4. * Copyright (C) 2015-2016, 2020 Reece H. Dunn
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, see: <http://www.gnu.org/licenses/>.
  18. */
  19. #include "config.h"
  20. #include <ctype.h>
  21. #include <locale.h>
  22. #include <stdint.h>
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <string.h>
  26. #include <espeak-ng/espeak_ng.h>
  27. #include <espeak-ng/speak_lib.h>
  28. #include <espeak-ng/encoding.h>
  29. #include "phoneme.h"
  30. #include "voice.h"
  31. #include "synthesize.h"
  32. #include "translate.h"
  33. // start of unicode pages for character sets
  34. #define OFFSET_GREEK 0x380
  35. #define OFFSET_CYRILLIC 0x420
  36. #define OFFSET_ARMENIAN 0x530
  37. #define OFFSET_HEBREW 0x590
  38. #define OFFSET_ARABIC 0x600
  39. #define OFFSET_SYRIAC 0x700
  40. #define OFFSET_THAANA 0x780 // Divehi/Maldives
  41. #define OFFSET_DEVANAGARI 0x900
  42. #define OFFSET_BENGALI 0x980
  43. #define OFFSET_GURMUKHI 0xa00
  44. #define OFFSET_GUJARATI 0xa80
  45. #define OFFSET_ORIYA 0xb00
  46. #define OFFSET_TAMIL 0xb80
  47. #define OFFSET_TELUGU 0xc00
  48. #define OFFSET_KANNADA 0xc80
  49. #define OFFSET_MALAYALAM 0xd00
  50. #define OFFSET_SINHALA 0x0d80
  51. #define OFFSET_THAI 0x0e00
  52. #define OFFSET_LAO 0x0e80
  53. #define OFFSET_TIBET 0x0f00
  54. #define OFFSET_MYANMAR 0x1000
  55. #define OFFSET_GEORGIAN 0x10a0
  56. #define OFFSET_KOREAN 0x1100
  57. #define OFFSET_ETHIOPIC 0x1200
  58. // character ranges must be listed in ascending unicode order
  59. ALPHABET alphabets[] = {
  60. { "_el", OFFSET_GREEK, 0x380, 0x3ff, L('e', 'l'), AL_DONT_NAME | AL_NOT_LETTERS | AL_WORDS },
  61. { "_cyr", OFFSET_CYRILLIC, 0x400, 0x52f, 0, 0 },
  62. { "_hy", OFFSET_ARMENIAN, 0x530, 0x58f, L('h', 'y'), AL_WORDS },
  63. { "_he", OFFSET_HEBREW, 0x590, 0x5ff, 0, 0 },
  64. { "_ar", OFFSET_ARABIC, 0x600, 0x6ff, 0, 0 },
  65. { "_syc", OFFSET_SYRIAC, 0x700, 0x74f, 0, 0 },
  66. { "_dv", OFFSET_THAANA, 0x780, 0x7bf, 0, 0 },
  67. { "_hi", OFFSET_DEVANAGARI, 0x900, 0x97f, L('h', 'i'), AL_WORDS },
  68. { "_bn", OFFSET_BENGALI, 0x0980, 0x9ff, L('b', 'n'), AL_WORDS },
  69. { "_gur", OFFSET_GURMUKHI, 0xa00, 0xa7f, L('p', 'a'), AL_WORDS },
  70. { "_gu", OFFSET_GUJARATI, 0xa80, 0xaff, L('g', 'u'), AL_WORDS },
  71. { "_or", OFFSET_ORIYA, 0xb00, 0xb7f, 0, 0 },
  72. { "_ta", OFFSET_TAMIL, 0xb80, 0xbff, L('t', 'a'), AL_WORDS },
  73. { "_te", OFFSET_TELUGU, 0xc00, 0xc7f, L('t', 'e'), 0 },
  74. { "_kn", OFFSET_KANNADA, 0xc80, 0xcff, L('k', 'n'), AL_WORDS },
  75. { "_ml", OFFSET_MALAYALAM, 0xd00, 0xd7f, L('m', 'l'), AL_WORDS },
  76. { "_si", OFFSET_SINHALA, 0xd80, 0xdff, L('s', 'i'), AL_WORDS },
  77. { "_th", OFFSET_THAI, 0xe00, 0xe7f, 0, 0 },
  78. { "_lo", OFFSET_LAO, 0xe80, 0xeff, 0, 0 },
  79. { "_ti", OFFSET_TIBET, 0xf00, 0xfff, 0, 0 },
  80. { "_my", OFFSET_MYANMAR, 0x1000, 0x109f, 0, 0 },
  81. { "_ka", OFFSET_GEORGIAN, 0x10a0, 0x10ff, L('k', 'a'), AL_WORDS },
  82. { "_ko", OFFSET_KOREAN, 0x1100, 0x11ff, L('k', 'o'), AL_WORDS },
  83. { "_eth", OFFSET_ETHIOPIC, 0x1200, 0x139f, 0, 0 },
  84. { "_braille", 0x2800, 0x2800, 0x28ff, 0, AL_NO_SYMBOL },
  85. { "_ja", 0x3040, 0x3040, 0x30ff, 0, AL_NOT_CODE },
  86. { "_zh", 0x3100, 0x3100, 0x9fff, 0, AL_NOT_CODE },
  87. { "_ko", 0xa700, 0xa700, 0xd7ff, L('k', 'o'), AL_NOT_CODE | AL_WORDS },
  88. { NULL, 0, 0, 0, 0, 0 }
  89. };
  90. ALPHABET *AlphabetFromChar(int c)
  91. {
  92. // Find the alphabet from a character.
  93. ALPHABET *alphabet = alphabets;
  94. while (alphabet->name != NULL) {
  95. if (c <= alphabet->range_max) {
  96. if (c >= alphabet->range_min)
  97. return alphabet;
  98. else
  99. break;
  100. }
  101. alphabet++;
  102. }
  103. return NULL;
  104. }
  105. static void Translator_Russian(Translator *tr);
  106. static void SetLetterVowel(Translator *tr, int c)
  107. {
  108. tr->letter_bits[c] = (tr->letter_bits[c] & 0x40) | 0x81; // keep value for group 6 (front vowels e,i,y)
  109. }
  110. static void ResetLetterBits(Translator *tr, int groups)
  111. {
  112. // Clear all the specified groups
  113. unsigned int ix;
  114. unsigned int mask;
  115. mask = ~groups;
  116. for (ix = 0; ix < sizeof(tr->letter_bits); ix++)
  117. tr->letter_bits[ix] &= mask;
  118. }
  119. static void SetLetterBits(Translator *tr, int group, const char *string)
  120. {
  121. int bits;
  122. unsigned char c;
  123. bits = (1L << group);
  124. while ((c = *string++) != 0)
  125. tr->letter_bits[c] |= bits;
  126. }
  127. static void SetLetterBitsRange(Translator *tr, int group, int first, int last)
  128. {
  129. int bits;
  130. int ix;
  131. bits = (1L << group);
  132. for (ix = first; ix <= last; ix++)
  133. tr->letter_bits[ix] |= bits;
  134. }
  135. static void SetLetterBitsUTF8(Translator *tr, int group, const char *letters, int offset)
  136. {
  137. // Add the letters to the specified letter group.
  138. const char *p = letters;
  139. int code = -1;
  140. while (code != 0) {
  141. int bytes = utf8_in(&code, p);
  142. if (code > 0x20)
  143. tr->letter_bits[code - offset] |= (1L << group);
  144. p += bytes;
  145. }
  146. }
  147. // ignore these characters
  148. static const unsigned short chars_ignore_default[] = {
  149. // U+00AD SOFT HYPHEN
  150. // Used to mark hyphenation points in words for where to split a
  151. // word at the end of a line to provide readable justified text.
  152. 0xad, 1,
  153. // U+200C ZERO WIDTH NON-JOINER
  154. // Used to prevent combined ligatures being displayed in their
  155. // combined form.
  156. 0x200c, 1,
  157. // U+200D ZERO WIDTH JOINER
  158. // Used to indicate an alternative connected form made up of the
  159. // characters surrounding the ZWJ in Devanagari, Kannada, Malayalam
  160. // and Emoji.
  161. // 0x200d, 1, // Not ignored.
  162. // End of the ignored character list.
  163. 0, 0
  164. };
  165. // alternatively, ignore characters but allow zero-width-non-joiner (lang-fa)
  166. static const unsigned short chars_ignore_zwnj_hyphen[] = {
  167. // U+00AD SOFT HYPHEN
  168. // Used to mark hyphenation points in words for where to split a
  169. // word at the end of a line to provide readable justified text.
  170. 0xad, 1,
  171. // U+0640 TATWEEL (KASHIDA)
  172. // Used in Arabic scripts to stretch characters for justifying
  173. // the text.
  174. 0x640, 1,
  175. // U+200C ZERO WIDTH NON-JOINER
  176. // Used to prevent combined ligatures being displayed in their
  177. // combined form.
  178. 0x200c, '-',
  179. // U+200D ZERO WIDTH JOINER
  180. // Used to indicate an alternative connected form made up of the
  181. // characters surrounding the ZWJ in Devanagari, Kannada, Malayalam
  182. // and Emoji.
  183. // 0x200d, 1, // Not ignored.
  184. // End of the ignored character list.
  185. 0, 0
  186. };
  187. const unsigned char utf8_ordinal[] = { 0xc2, 0xba, 0 }; // masculine ordinal character, UTF-8
  188. const unsigned char utf8_null[] = { 0 }; // null string, UTF-8
  189. static Translator *NewTranslator(void)
  190. {
  191. Translator *tr;
  192. int ix;
  193. static const unsigned char stress_amps2[] = { 18, 18, 20, 20, 20, 22, 22, 20 };
  194. static const short stress_lengths2[8] = { 182, 140, 220, 220, 220, 240, 260, 280 };
  195. static const wchar_t empty_wstring[1] = { 0 };
  196. static const wchar_t punct_in_word[2] = { '\'', 0 }; // allow hyphen within words
  197. static const unsigned char default_tunes[6] = { 0, 1, 2, 3, 0, 0 };
  198. // Translates character codes in the range transpose_min to transpose_max to
  199. // a number in the range 1 to 63. 0 indicates there is no translation.
  200. // Used up to 57 (max of 63)
  201. static const char transpose_map_latin[] = {
  202. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0x60
  203. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, // 0x70
  204. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80
  205. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x90
  206. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0
  207. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0
  208. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0
  209. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0
  210. 27, 28, 29, 0, 0, 30, 31, 32, 33, 34, 35, 36, 0, 37, 38, 0, // 0xe0
  211. 0, 0, 0, 39, 0, 0, 40, 0, 41, 0, 42, 0, 43, 0, 0, 0, // 0xf0
  212. 0, 0, 0, 44, 0, 45, 0, 46, 0, 0, 0, 0, 0, 47, 0, 0, // 0x100
  213. 0, 48, 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, // 0x110
  214. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x120
  215. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x130
  216. 0, 0, 50, 0, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x140
  217. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, // 0x150
  218. 0, 53, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x160
  219. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 56, 0, 57, 0, // 0x170
  220. };
  221. if ((tr = (Translator *)malloc(sizeof(Translator))) == NULL)
  222. return NULL;
  223. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_1;
  224. dictionary_name[0] = 0;
  225. tr->dictionary_name[0] = 0;
  226. tr->dict_condition = 0;
  227. tr->dict_min_size = 0;
  228. tr->data_dictrules = NULL; // language_1 translation rules file
  229. tr->data_dictlist = NULL; // language_2 dictionary lookup file
  230. tr->transpose_min = 0x60;
  231. tr->transpose_max = 0x17f;
  232. tr->transpose_map = transpose_map_latin;
  233. tr->frequent_pairs = NULL;
  234. // only need lower case
  235. tr->letter_bits_offset = 0;
  236. memset(tr->letter_bits, 0, sizeof(tr->letter_bits));
  237. memset(tr->letter_groups, 0, sizeof(tr->letter_groups));
  238. // 0-6 sets of characters matched by A B C H F G Y in pronunciation rules
  239. // these may be set differently for different languages
  240. SetLetterBits(tr, 0, "aeiou"); // A vowels, except y
  241. SetLetterBits(tr, 1, "bcdfgjklmnpqstvxz"); // B hard consonants, excluding h,r,w
  242. SetLetterBits(tr, 2, "bcdfghjklmnpqrstvwxz"); // C all consonants
  243. SetLetterBits(tr, 3, "hlmnr"); // H 'soft' consonants
  244. SetLetterBits(tr, 4, "cfhkpqstx"); // F voiceless consonants
  245. SetLetterBits(tr, 5, "bdgjlmnrvwyz"); // G voiced
  246. SetLetterBits(tr, 6, "eiy"); // Letter group Y, front vowels
  247. SetLetterBits(tr, 7, "aeiouy"); // vowels, including y
  248. tr->char_plus_apostrophe = empty_wstring;
  249. tr->punct_within_word = punct_in_word;
  250. tr->chars_ignore = chars_ignore_default;
  251. for (ix = 0; ix < 8; ix++) {
  252. tr->stress_amps[ix] = stress_amps2[ix];
  253. tr->stress_amps_r[ix] = stress_amps2[ix] - 1;
  254. tr->stress_lengths[ix] = stress_lengths2[ix];
  255. }
  256. memset(&(tr->langopts), 0, sizeof(tr->langopts));
  257. tr->langopts.max_lengthmod = 500;
  258. tr->langopts.lengthen_tonic = 20;
  259. tr->langopts.stress_rule = STRESSPOSN_2R;
  260. tr->langopts.unstressed_wd1 = 1;
  261. tr->langopts.unstressed_wd2 = 3;
  262. tr->langopts.param[LOPT_SONORANT_MIN] = 95;
  263. tr->langopts.param[LOPT_LONG_VOWEL_THRESHOLD] = 190/2;
  264. tr->langopts.param[LOPT_MAXAMP_EOC] = 19;
  265. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 's'; // don't count this character at start of word
  266. tr->langopts.param[LOPT_BRACKET_PAUSE] = 4; // pause at bracket
  267. tr->langopts.param2[LOPT_BRACKET_PAUSE] = 2; // pauses when announcing bracket names
  268. tr->langopts.max_initial_consonants = 3;
  269. tr->langopts.replace_chars = NULL;
  270. tr->langopts.alt_alphabet_lang = L('e', 'n');
  271. tr->langopts.roman_suffix = utf8_null;
  272. SetLengthMods(tr, 201);
  273. tr->langopts.long_stop = 100;
  274. tr->langopts.max_roman = 49;
  275. tr->langopts.min_roman = 2;
  276. tr->langopts.thousands_sep = ',';
  277. tr->langopts.decimal_sep = '.';
  278. tr->langopts.break_numbers = BREAK_THOUSANDS;
  279. tr->langopts.max_digits = 14;
  280. // index by 0=. 1=, 2=?, 3=! 4=none, 5=emphasized
  281. unsigned char punctuation_to_tone[INTONATION_TYPES][PUNCT_INTONATIONS] = {
  282. { 0, 1, 2, 3, 0, 4 },
  283. { 0, 1, 2, 3, 0, 4 },
  284. { 5, 6, 2, 3, 0, 4 },
  285. { 5, 7, 1, 3, 0, 4 },
  286. { 8, 9, 10, 3, 0, 0 },
  287. { 8, 8, 10, 3, 0, 0 },
  288. { 11, 11, 11, 11, 0, 0 }, // 6 test
  289. { 12, 12, 12, 12, 0, 0 }
  290. };
  291. memcpy(tr->punct_to_tone, punctuation_to_tone, sizeof(tr->punct_to_tone));
  292. memcpy(tr->langopts.tunes, default_tunes, sizeof(tr->langopts.tunes));
  293. return tr;
  294. }
  295. // common letter pairs, encode these as a single byte
  296. // 2 bytes, using the transposed character codes
  297. static const short pairs_ru[] = {
  298. 0x010c, // ла 21052 0x23
  299. 0x010e, // на 18400
  300. 0x0113, // та 14254
  301. 0x0301, // ав 31083
  302. 0x030f, // ов 13420
  303. 0x060e, // не 21798
  304. 0x0611, // ре 19458
  305. 0x0903, // ви 16226
  306. 0x0b01, // ак 14456
  307. 0x0b0f, // ок 17836
  308. 0x0c01, // ал 13324
  309. 0x0c09, // ил 16877
  310. 0x0e01, // ан 15359
  311. 0x0e06, // ен 13543 0x30
  312. 0x0e09, // ин 17168
  313. 0x0e0e, // нн 15973
  314. 0x0e0f, // он 22373
  315. 0x0e1c, // ын 15052
  316. 0x0f03, // во 24947
  317. 0x0f11, // ро 13552
  318. 0x0f12, // со 16368
  319. 0x100f, // оп 19054
  320. 0x1011, // рп 17067
  321. 0x1101, // ар 23967
  322. 0x1106, // ер 18795
  323. 0x1109, // ир 13797
  324. 0x110f, // ор 21737
  325. 0x1213, // тс 25076
  326. 0x1220, // яс 14310
  327. 0x7fff
  328. };
  329. static const unsigned char ru_vowels[] = { // (also kazakh) offset by 0x420 -- а е ё и о у ы э ю я ә ө ұ ү і
  330. 0x10, 0x15, 0x31, 0x18, 0x1e, 0x23, 0x2b, 0x2d, 0x2e, 0x2f, 0xb9, 0xc9, 0x91, 0x8f, 0x36, 0
  331. };
  332. static const unsigned char ru_consonants[] = { // б в г д ж з й к л м н п р с т ф х ц ч ш щ ъ ь қ ң һ
  333. 0x11, 0x12, 0x13, 0x14, 0x16, 0x17, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1f, 0x20, 0x21, 0x22, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2c, 0x73, 0x7b, 0x83, 0x9b, 0
  334. };
  335. static void SetArabicLetters(Translator *tr)
  336. {
  337. const char *arab_vowel_letters = "َ ُ ِ";
  338. const char *arab_consonant_vowel_letters = "ا و ي";
  339. const char *arab_consonant_letters = "ب پ ت ة ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ف ق ك ل م ن ئ ؤ ء أ آ إ ه";
  340. const char *arab_thick_letters = "ص ض ط ظ";
  341. const char *arab_shadda_letter = " ّ ";
  342. const char *arab_hamza_letter = " ّ ";
  343. const char *arab_sukun_letter = " ّ ";
  344. SetLetterBitsUTF8(tr, LETTERGP_A, arab_vowel_letters, OFFSET_ARABIC);
  345. SetLetterBitsUTF8(tr, LETTERGP_B, arab_consonant_vowel_letters, OFFSET_ARABIC);
  346. SetLetterBitsUTF8(tr, LETTERGP_C, arab_consonant_letters, OFFSET_ARABIC);
  347. SetLetterBitsUTF8(tr, LETTERGP_F, arab_thick_letters, OFFSET_ARABIC);
  348. SetLetterBitsUTF8(tr, LETTERGP_G, arab_shadda_letter, OFFSET_ARABIC);
  349. SetLetterBitsUTF8(tr, LETTERGP_H, arab_hamza_letter, OFFSET_ARABIC);
  350. SetLetterBitsUTF8(tr, LETTERGP_Y, arab_sukun_letter, OFFSET_ARABIC);
  351. }
  352. static void SetCyrillicLetters(Translator *tr)
  353. {
  354. // Set letter types for Cyrillic script languages: bg (Bulgarian), ru (Russian), tt (Tatar), uk (Ukranian).
  355. // character codes offset by 0x420
  356. static const char cyrl_soft[] = { 0x2c, 0x19, 0x27, 0x29, 0 }; // letter group B [k ts; s;] -- ь й ч щ
  357. static const char cyrl_hard[] = { 0x2a, 0x16, 0x26, 0x28, 0 }; // letter group H [S Z ts] -- ъ ж ц ш
  358. static const char cyrl_nothard[] = { 0x11, 0x12, 0x13, 0x14, 0x17, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1f, 0x20, 0x21, 0x22, 0x24, 0x25, 0x27, 0x29, 0x2c, 0 }; // б в г д з й к л м н п р с т ф х ч щ ь
  359. static const char cyrl_voiced[] = { 0x11, 0x12, 0x13, 0x14, 0x16, 0x17, 0 }; // letter group G (voiced obstruents) -- б в г д ж з
  360. static const char cyrl_ivowels[] = { 0x2c, 0x2e, 0x2f, 0x31, 0 }; // letter group Y (iotated vowels & soft-sign) -- ь ю я ё
  361. tr->encoding = ESPEAKNG_ENCODING_KOI8_R;
  362. tr->transpose_min = 0x430; // convert cyrillic from unicode into range 0x01 to 0x22
  363. tr->transpose_max = 0x451;
  364. tr->transpose_map = NULL;
  365. tr->frequent_pairs = pairs_ru;
  366. tr->letter_bits_offset = OFFSET_CYRILLIC;
  367. memset(tr->letter_bits, 0, sizeof(tr->letter_bits));
  368. SetLetterBits(tr, LETTERGP_A, (char *)ru_vowels);
  369. SetLetterBits(tr, LETTERGP_B, cyrl_soft);
  370. SetLetterBits(tr, LETTERGP_C, (char *)ru_consonants);
  371. SetLetterBits(tr, LETTERGP_H, cyrl_hard);
  372. SetLetterBits(tr, LETTERGP_F, cyrl_nothard);
  373. SetLetterBits(tr, LETTERGP_G, cyrl_voiced);
  374. SetLetterBits(tr, LETTERGP_Y, cyrl_ivowels);
  375. SetLetterBits(tr, LETTERGP_VOWEL2, (char *)ru_vowels);
  376. }
  377. static void SetIndicLetters(Translator *tr)
  378. {
  379. // Set letter types for Devanagari (Indic) script languages: Devanagari, Tamill, etc.
  380. static const char deva_consonants2[] = { 0x02, 0x03, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x7b, 0x7c, 0x7e, 0x7f, 0 };
  381. static const char deva_vowels2[] = { 0x60, 0x61, 0x55, 0x56, 0x57, 0x62, 0x63, 0 }; // non-consecutive vowels and vowel-signs
  382. memset(tr->letter_bits, 0, sizeof(tr->letter_bits));
  383. SetLetterBitsRange(tr, LETTERGP_A, 0x04, 0x14); // vowel letters
  384. SetLetterBitsRange(tr, LETTERGP_A, 0x3e, 0x4d); // + vowel signs, and virama
  385. SetLetterBits(tr, LETTERGP_A, deva_vowels2); // + extra vowels and vowel signs
  386. SetLetterBitsRange(tr, LETTERGP_B, 0x3e, 0x4d); // vowel signs, and virama
  387. SetLetterBits(tr, LETTERGP_B, deva_vowels2); // + extra vowels and vowel signs
  388. SetLetterBitsRange(tr, LETTERGP_C, 0x15, 0x39); // the main consonant range
  389. SetLetterBits(tr, LETTERGP_C, deva_consonants2); // + additional consonants
  390. SetLetterBitsRange(tr, LETTERGP_Y, 0x04, 0x14); // vowel letters
  391. SetLetterBitsRange(tr, LETTERGP_Y, 0x3e, 0x4c); // + vowel signs
  392. SetLetterBits(tr, LETTERGP_Y, deva_vowels2); // + extra vowels and vowel signs
  393. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  394. tr->langopts.suffix_add_e = tr->letter_bits_offset + 0x4d; // virama
  395. }
  396. static void SetupTranslator(Translator *tr, const short *lengths, const unsigned char *amps)
  397. {
  398. if (lengths != NULL)
  399. memcpy(tr->stress_lengths, lengths, sizeof(tr->stress_lengths));
  400. if (amps != NULL)
  401. memcpy(tr->stress_amps, amps, sizeof(tr->stress_amps));
  402. }
  403. Translator *SelectTranslator(const char *name)
  404. {
  405. int name2 = 0;
  406. Translator *tr;
  407. static const short stress_lengths_equal[8] = { 230, 230, 230, 230, 0, 0, 230, 230 };
  408. static const unsigned char stress_amps_equal[8] = { 19, 19, 19, 19, 19, 19, 19, 19 };
  409. static const short stress_lengths_fr[8] = { 190, 170, 190, 200, 0, 0, 190, 240 };
  410. static const unsigned char stress_amps_fr[8] = { 18, 16, 18, 18, 18, 18, 18, 18 };
  411. static const unsigned char stress_amps_sk[8] = { 17, 16, 20, 20, 20, 22, 22, 21 };
  412. static const short stress_lengths_sk[8] = { 190, 190, 210, 210, 0, 0, 210, 210 };
  413. static const short stress_lengths_ta[8] = { 200, 200, 210, 210, 0, 0, 230, 230 };
  414. static const short stress_lengths_ta2[8] = { 230, 230, 240, 240, 0, 0, 260, 260 };
  415. static const unsigned char stress_amps_ta[8] = { 18, 18, 18, 18, 20, 20, 22, 22 };
  416. tr = NewTranslator();
  417. strcpy(tr->dictionary_name, name);
  418. // convert name string into a word of up to 4 characters, for the switch()
  419. while (*name != 0)
  420. name2 = (name2 << 8) + *name++;
  421. switch (name2)
  422. {
  423. case L('a', 'f'):
  424. {
  425. static const short stress_lengths_af[8] = { 170, 140, 220, 220, 0, 0, 250, 270 };
  426. SetupTranslator(tr, stress_lengths_af, NULL);
  427. tr->langopts.stress_rule = STRESSPOSN_1L;
  428. tr->langopts.vowel_pause = 0x30;
  429. tr->langopts.param[LOPT_DIERESES] = 1;
  430. tr->langopts.param[LOPT_PREFIXES] = 1;
  431. SetLetterVowel(tr, 'y'); // add 'y' to vowels
  432. tr->langopts.numbers = NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_SINGLE_AND | NUM_ROMAN | NUM_1900;
  433. tr->langopts.accents = 1;
  434. }
  435. break;
  436. case L('a', 'm'): // Amharic, Ethiopia
  437. {
  438. SetupTranslator(tr, stress_lengths_fr, stress_amps_fr);
  439. tr->letter_bits_offset = OFFSET_ETHIOPIC;
  440. tr->langopts.stress_rule = STRESSPOSN_1L;
  441. tr->langopts.stress_flags = S_NO_AUTO_2 | S_FINAL_DIM; // don't use secondary stress
  442. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  443. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  444. tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
  445. }
  446. break;
  447. case L('a', 'r'): // Arabic
  448. tr->transpose_min = OFFSET_ARABIC; // for ar_list, use 6-bit character codes
  449. tr->transpose_max = 0x65f;
  450. tr->transpose_map = NULL;
  451. tr->letter_bits_offset = OFFSET_ARABIC;
  452. tr->langopts.numbers = NUM_SWAP_TENS | NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_AND_HUNDRED | NUM_THOUSAND_AND | NUM_OMIT_1_THOUSAND;
  453. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  454. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_6;
  455. SetArabicLetters(tr);
  456. break;
  457. case L('b', 'g'): // Bulgarian
  458. {
  459. SetCyrillicLetters(tr);
  460. SetLetterVowel(tr, 0x2a);
  461. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_5;
  462. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
  463. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x107; // devoice at end of word, and change voicing to match a following consonant (except v)
  464. tr->langopts.param[LOPT_REDUCE] = 2;
  465. tr->langopts.stress_rule = STRESSPOSN_2R;
  466. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_SINGLE_AND | NUM_ROMAN | NUM_ROMAN_ORDINAL | NUM_ROMAN_CAPITALS;
  467. tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
  468. }
  469. break;
  470. case L('b', 'n'): // Bengali
  471. case L('a', 's'): // Assamese
  472. case L3('b', 'p', 'y'): // Manipuri (temporary placement - it's not indo-european)
  473. {
  474. static const short stress_lengths_bn[8] = { 180, 180, 210, 210, 0, 0, 230, 240 };
  475. static const unsigned char stress_amps_bn[8] = { 18, 18, 18, 18, 20, 20, 22, 22 };
  476. static const char bn_consonants2[3] = { 0x70, 0x71, 0 };
  477. SetupTranslator(tr, stress_lengths_bn, stress_amps_bn);
  478. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  479. tr->langopts.stress_rule = STRESSPOSN_1L;
  480. tr->langopts.stress_flags = S_MID_DIM | S_FINAL_DIM; // use 'diminished' for unstressed final syllable
  481. tr->letter_bits_offset = OFFSET_BENGALI;
  482. SetIndicLetters(tr); // call this after setting OFFSET_BENGALI
  483. SetLetterBitsRange(tr, LETTERGP_B, 0x01, 0x01); // candranindu
  484. SetLetterBitsRange(tr, LETTERGP_F, 0x3e, 0x4c); // vowel signs, but not virama
  485. SetLetterBits(tr, LETTERGP_C, bn_consonants2);
  486. tr->langopts.numbers = NUM_SWAP_TENS;
  487. tr->langopts.break_numbers = BREAK_LAKH_BN;
  488. if (name2 == L3('b', 'p', 'y')) {
  489. tr->langopts.numbers = NUM_DEFAULT;
  490. tr->langopts.numbers2 = NUM2_SWAP_THOUSANDS;
  491. }
  492. }
  493. break;
  494. case L('b', 'o'): // Tibet
  495. {
  496. tr->langopts.stress_rule = STRESSPOSN_1L;
  497. tr->letter_bits_offset = OFFSET_TIBET;
  498. SetLetterBitsRange(tr, LETTERGP_A, 0x71, 0x7d); // vowel signs
  499. SetLetterBitsRange(tr, LETTERGP_B, 0x71, 0x81); // vowel signs and subjoined letters
  500. SetLetterBitsRange(tr, LETTERGP_B, 0x90, 0xbc);
  501. SetLetterBitsRange(tr, LETTERGP_C, 0x40, 0x6c); // consonant letters (not subjoined)
  502. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  503. tr->langopts.numbers = NUM_DEFAULT;
  504. }
  505. break;
  506. case L3('c', 'h', 'r'): // Cherokee
  507. {
  508. tr->langopts.stress_flags = S_NO_AUTO_2 | S_FINAL_DIM | S_FINAL_DIM_ONLY | S_EO_CLAUSE1;
  509. }
  510. break;
  511. case L('c', 'y'): // Welsh
  512. {
  513. static const short stress_lengths_cy[8] = { 170, 220, 180, 180, 0, 0, 250, 270 };
  514. static const unsigned char stress_amps_cy[8] = { 17, 15, 18, 18, 0, 0, 22, 20 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  515. SetupTranslator(tr, stress_lengths_cy, stress_amps_cy);
  516. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_14;
  517. tr->langopts.stress_rule = STRESSPOSN_2R;
  518. // 'diminished' is an unstressed final syllable
  519. tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
  520. tr->langopts.unstressed_wd1 = 0;
  521. tr->langopts.unstressed_wd2 = 2;
  522. tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
  523. tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
  524. SetLetterVowel(tr, 'w'); // add letter to vowels and remove from consonants
  525. SetLetterVowel(tr, 'y');
  526. }
  527. break;
  528. case L('d', 'a'): // Danish
  529. {
  530. static const short stress_lengths_da[8] = { 160, 140, 200, 200, 0, 0, 220, 230 };
  531. SetupTranslator(tr, stress_lengths_da, NULL);
  532. tr->langopts.stress_rule = STRESSPOSN_1L;
  533. tr->langopts.param[LOPT_PREFIXES] = 1;
  534. SetLetterVowel(tr, 'y');
  535. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_ORDINAL_DOT | NUM_1900 | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_ORDINAL;
  536. }
  537. break;
  538. case L('d', 'e'):
  539. {
  540. static const short stress_lengths_de[8] = { 150, 130, 200, 200, 0, 0, 270, 270 };
  541. static const unsigned char stress_amps_de[] = { 20, 20, 20, 20, 20, 22, 22, 20 };
  542. SetupTranslator(tr, stress_lengths_de, stress_amps_de);
  543. tr->langopts.stress_rule = STRESSPOSN_1L;
  544. tr->langopts.word_gap = 0x8; // don't use linking phonemes
  545. tr->langopts.vowel_pause = 0x30;
  546. tr->langopts.param[LOPT_PREFIXES] = 1;
  547. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
  548. tr->langopts.param[LOPT_LONG_VOWEL_THRESHOLD] = 175/2;
  549. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_ALLOW_SPACE | NUM_ORDINAL_DOT | NUM_ROMAN;
  550. SetLetterVowel(tr, 'y');
  551. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use de_rules for unpronouncable rules
  552. }
  553. break;
  554. case L('d', 'v'): // Divehi (Maldives) FIXME: this language code is actually never used
  555. {
  556. SetupTranslator(tr, stress_lengths_ta, stress_amps_ta);
  557. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  558. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  559. tr->letter_bits_offset = OFFSET_THAANA;
  560. tr->langopts.stress_rule = STRESSPOSN_1L;
  561. tr->langopts.stress_flags = S_MID_DIM | S_FINAL_DIM; // use 'diminished' for unstressed final syllable
  562. SetLetterBitsRange(tr, LETTERGP_B, 0x26, 0x30); // vowel signs, and virama
  563. tr->langopts.break_numbers = BREAK_LAKH_DV;
  564. tr->langopts.numbers = NUM_DEFAULT;
  565. }
  566. break;
  567. case L('e', 'n'):
  568. {
  569. static const short stress_lengths_en[8] = { 182, 140, 220, 220, 0, 0, 248, 275 };
  570. SetupTranslator(tr, stress_lengths_en, NULL);
  571. tr->langopts.stress_rule = STRESSPOSN_1L;
  572. tr->langopts.stress_flags = 0x08;
  573. tr->langopts.numbers = NUM_HUNDRED_AND | NUM_ROMAN | NUM_1900;
  574. tr->langopts.max_digits = 33;
  575. tr->langopts.param[LOPT_COMBINE_WORDS] = 2; // allow "mc" to cmbine with the following word
  576. tr->langopts.suffix_add_e = 'e';
  577. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use en_rules for unpronouncable rules
  578. SetLetterBits(tr, 6, "aeiouy"); // Group Y: vowels, including y
  579. }
  580. break;
  581. case L('e', 'l'): // Greek
  582. case L3('g', 'r', 'c'): // Ancient Greek
  583. {
  584. static const short stress_lengths_el[8] = { 155, 180, 210, 210, 0, 0, 270, 300 };
  585. static const unsigned char stress_amps_el[8] = { 15, 12, 20, 20, 20, 22, 22, 21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  586. // character codes offset by 0x380
  587. static const char el_vowels[] = { 0x10, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x35, 0x37, 0x39, 0x3f, 0x45, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0 };
  588. static const char el_fvowels[] = { 0x2d, 0x2e, 0x2f, 0x35, 0x37, 0x39, 0x45, 0x4d, 0 }; // ε η ι υ έ ή ί ύ _
  589. static const char el_voiceless[] = { 0x38, 0x3a, 0x3e, 0x40, 0x42, 0x43, 0x44, 0x46, 0x47, 0 }; // θ κ ξ π ς σ τ φ χ _
  590. static const char el_consonants[] = { 0x32, 0x33, 0x34, 0x36, 0x38, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x40, 0x41, 0x42, 0x43, 0x44, 0x46, 0x47, 0x48, 0 };
  591. static const wchar_t el_char_apostrophe[] = { 0x3c3, 0 }; // σ _
  592. SetupTranslator(tr, stress_lengths_el, stress_amps_el);
  593. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_7;
  594. tr->char_plus_apostrophe = el_char_apostrophe;
  595. tr->letter_bits_offset = OFFSET_GREEK;
  596. memset(tr->letter_bits, 0, sizeof(tr->letter_bits));
  597. SetLetterBits(tr, LETTERGP_A, el_vowels);
  598. SetLetterBits(tr, LETTERGP_VOWEL2, el_vowels);
  599. SetLetterBits(tr, LETTERGP_B, el_voiceless);
  600. SetLetterBits(tr, LETTERGP_C, el_consonants);
  601. SetLetterBits(tr, LETTERGP_Y, el_fvowels); // front vowels: ε η ι υ _
  602. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  603. tr->langopts.stress_rule = STRESSPOSN_2R;
  604. tr->langopts.stress_flags = S_FINAL_DIM_ONLY; // mark unstressed final syllables as diminished
  605. tr->langopts.unstressed_wd1 = 0;
  606. tr->langopts.unstressed_wd2 = 2;
  607. tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
  608. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA;
  609. tr->langopts.numbers2 = NUM2_THOUSANDPLEX_VAR_THOUSANDS | NUM2_MULTIPLE_ORDINAL | NUM2_ORDINAL_NO_AND;
  610. if (name2 == L3('g', 'r', 'c')) {
  611. // ancient greek
  612. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1;
  613. }
  614. }
  615. break;
  616. case L('e', 'o'):
  617. {
  618. static const short stress_lengths_eo[8] = { 150, 140, 180, 180, 0, 0, 200, 200 };
  619. static const unsigned char stress_amps_eo[] = { 16, 14, 20, 20, 20, 22, 22, 21 };
  620. static const wchar_t eo_char_apostrophe[2] = { 'l', 0 };
  621. SetupTranslator(tr, stress_lengths_eo, stress_amps_eo);
  622. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_3;
  623. tr->char_plus_apostrophe = eo_char_apostrophe;
  624. tr->langopts.vowel_pause = 2;
  625. tr->langopts.stress_rule = STRESSPOSN_2R;
  626. tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
  627. tr->langopts.unstressed_wd2 = 2;
  628. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_ALLOW_SPACE | NUM_ROMAN;
  629. }
  630. break;
  631. case L('e', 's'): // Spanish
  632. case L('a', 'n'): // Aragonese
  633. case L('c', 'a'): // Catalan
  634. case L('i', 'a'): // Interlingua
  635. case L3('p', 'a', 'p'): // Papiamento
  636. {
  637. static const short stress_lengths_es[8] = { 160, 145, 155, 150, 0, 0, 200, 245 };
  638. static const unsigned char stress_amps_es[8] = { 16, 14, 15, 16, 20, 20, 22, 22 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  639. static const wchar_t ca_punct_within_word[] = { '\'', 0xb7, 0 }; // ca: allow middle-dot within word
  640. SetupTranslator(tr, stress_lengths_es, stress_amps_es);
  641. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  642. tr->langopts.stress_rule = STRESSPOSN_2R;
  643. // stress last syllable if it doesn't end in vowel or "s" or "n"
  644. // 'diminished' is an unstressed final syllable
  645. tr->langopts.stress_flags = S_FINAL_SPANISH | S_FINAL_DIM_ONLY | S_FINAL_NO_2;
  646. tr->langopts.unstressed_wd1 = 0;
  647. tr->langopts.unstressed_wd2 = 2;
  648. tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
  649. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ROMAN | NUM_ROMAN_AFTER | NUM_DFRACTION_4;
  650. tr->langopts.numbers2 = NUM2_MULTIPLE_ORDINAL | NUM2_ORDINAL_NO_AND;
  651. if (name2 == L('c', 'a')) {
  652. // stress last syllable unless word ends with a vowel
  653. tr->punct_within_word = ca_punct_within_word;
  654. tr->langopts.stress_flags = S_FINAL_SPANISH | S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_NO_AUTO_2;
  655. } else if (name2 == L('i', 'a')) {
  656. tr->langopts.stress_flags = S_FINAL_SPANISH | S_FINAL_DIM_ONLY | S_FINAL_NO_2;
  657. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ROMAN | NUM_ROMAN_AFTER;
  658. } else if (name2 == L('a', 'n')) {
  659. tr->langopts.stress_flags = S_FINAL_SPANISH | S_FINAL_DIM_ONLY | S_FINAL_NO_2;
  660. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ROMAN | NUM_ROMAN_ORDINAL;
  661. tr->langopts.numbers2 = NUM2_ORDINAL_NO_AND;
  662. tr->langopts.roman_suffix = utf8_ordinal;
  663. } else if (name2 == L3('p', 'a', 'p')) {
  664. // stress last syllable unless word ends with a vowel
  665. tr->langopts.stress_rule = STRESSPOSN_1R;
  666. tr->langopts.stress_flags = S_FINAL_VOWEL_UNSTRESSED | S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_NO_AUTO_2;
  667. } else
  668. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use es_rules for unpronouncable rules
  669. }
  670. break;
  671. case L('e', 'u'): // basque
  672. {
  673. static const short stress_lengths_eu[8] = { 200, 200, 200, 200, 0, 0, 210, 230 }; // very weak stress
  674. static const unsigned char stress_amps_eu[8] = { 16, 16, 18, 18, 18, 18, 18, 18 };
  675. SetupTranslator(tr, stress_lengths_eu, stress_amps_eu);
  676. tr->langopts.stress_rule = STRESSPOSN_2L; // ?? second syllable, but not on a word-final vowel
  677. tr->langopts.stress_flags = S_FINAL_VOWEL_UNSTRESSED;
  678. tr->langopts.param[LOPT_SUFFIX] = 1;
  679. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_VIGESIMAL;
  680. }
  681. break;
  682. case L('f', 'a'): // Farsi
  683. {
  684. // Convert characters in the range 0x620 to 0x6cc to the range 1 to 63.
  685. // 0 indicates no translation for this character
  686. static const char transpose_map_fa[] = {
  687. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0x620
  688. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, // 0x630
  689. 0, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, // 0x640
  690. 42, 43, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x650
  691. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x660
  692. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, // 0x670
  693. 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x680
  694. 0, 0, 0, 0, 0, 0, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, // 0x690
  695. 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 49, // 0x6a0
  696. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x6b0
  697. 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51 // 0x6c0
  698. };
  699. tr->transpose_min = 0x620;
  700. tr->transpose_max = 0x6cc;
  701. tr->transpose_map = transpose_map_fa;
  702. tr->letter_bits_offset = OFFSET_ARABIC;
  703. tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND;
  704. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  705. tr->chars_ignore = chars_ignore_zwnj_hyphen; // replace ZWNJ by hyphen
  706. }
  707. break;
  708. case L('e', 't'): // Estonian
  709. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_4;
  710. // fallthrough:
  711. case L('f', 'i'): // Finnish
  712. {
  713. static const unsigned char stress_amps_fi[8] = { 18, 16, 22, 22, 20, 22, 22, 22 };
  714. static const short stress_lengths_fi[8] = { 150, 180, 200, 200, 0, 0, 210, 250 };
  715. SetupTranslator(tr, stress_lengths_fi, stress_amps_fi);
  716. tr->langopts.stress_rule = STRESSPOSN_1L;
  717. tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_2_TO_HEAVY; // move secondary stress from light to a following heavy syllable
  718. tr->langopts.param[LOPT_IT_DOUBLING] = 1;
  719. tr->langopts.long_stop = 130;
  720. tr->langopts.numbers = NUM_DECIMAL_COMMA + NUM_ALLOW_SPACE;
  721. SetLetterVowel(tr, 'y');
  722. tr->langopts.spelling_stress = 1;
  723. tr->langopts.intonation_group = 3; // less intonation, don't raise pitch at comma
  724. }
  725. break;
  726. case L('f', 'r'): // french
  727. {
  728. SetupTranslator(tr, stress_lengths_fr, stress_amps_fr);
  729. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
  730. tr->langopts.stress_flags = S_NO_AUTO_2 | S_FINAL_DIM; // don't use secondary stress
  731. tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove lengthen indicator from unstressed syllables
  732. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  733. tr->langopts.accents = 2; // Say "Capital" after the letter.
  734. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_NOPAUSE | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_AFTER | NUM_VIGESIMAL | NUM_DFRACTION_4;
  735. SetLetterVowel(tr, 'y');
  736. }
  737. break;
  738. case L3('h','a', 'k'): // Hakka Chinese
  739. {
  740. tr->langopts.stress_flags = S_NO_DIM; // don't automatically set diminished stress (may be set in the intonation module)
  741. tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
  742. tr->langopts.tone_numbers = 1; // a number after letters indicates a tone number (eg. pinyin or jyutping)
  743. tr->langopts.ideographs = 1;
  744. }
  745. break;
  746. case L('g', 'a'): // irish
  747. case L('g', 'd'): // scots gaelic
  748. {
  749. tr->langopts.stress_rule = STRESSPOSN_1L;
  750. tr->langopts.stress_flags = S_NO_AUTO_2; // don't use secondary stress
  751. tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND;
  752. tr->langopts.accents = 2; // 'capital' after letter name
  753. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 3; // don't count apostrophe
  754. tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove [:] phoneme from non-stressed syllables (Lang=gd)
  755. }
  756. break;
  757. case L('g','n'): // guarani
  758. {
  759. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
  760. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  761. }
  762. break;
  763. case L('h', 'i'): // Hindi
  764. case L('n', 'e'): // Nepali
  765. case L('o', 'r'): // Oriya
  766. case L('p', 'a'): // Punjabi
  767. case L('g', 'u'): // Gujarati
  768. case L('m', 'r'): // Marathi
  769. {
  770. static const short stress_lengths_hi[8] = { 190, 190, 210, 210, 0, 0, 230, 250 };
  771. static const unsigned char stress_amps_hi[8] = { 17, 14, 20, 19, 20, 22, 22, 21 };
  772. SetupTranslator(tr, stress_lengths_hi, stress_amps_hi);
  773. tr->encoding = ESPEAKNG_ENCODING_ISCII;
  774. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  775. tr->langopts.stress_rule = 6; // stress on last heaviest syllable, excluding final syllable
  776. tr->langopts.stress_flags = S_MID_DIM | S_FINAL_DIM; // use 'diminished' for unstressed final syllable
  777. tr->langopts.numbers = NUM_SWAP_TENS;
  778. tr->langopts.break_numbers = BREAK_LAKH_HI;
  779. tr->letter_bits_offset = OFFSET_DEVANAGARI;
  780. if (name2 == L('p', 'a'))
  781. tr->letter_bits_offset = OFFSET_GURMUKHI;
  782. else if (name2 == L('g', 'u')) {
  783. SetupTranslator(tr, stress_lengths_equal, stress_amps_equal);
  784. tr->letter_bits_offset = OFFSET_GUJARATI;
  785. tr->langopts.stress_rule = STRESSPOSN_2R;
  786. } else if (name2 == L('n', 'e')) {
  787. SetupTranslator(tr, stress_lengths_equal, stress_amps_equal);
  788. tr->langopts.break_numbers = BREAK_LAKH;
  789. tr->langopts.max_digits = 22;
  790. tr->langopts.numbers2 |= NUM2_ENGLISH_NUMERALS;
  791. } else if (name2 == L('o', 'r'))
  792. tr->letter_bits_offset = OFFSET_ORIYA;
  793. SetIndicLetters(tr);
  794. }
  795. break;
  796. case L('h', 'r'): // Croatian
  797. case L('b', 's'): // Bosnian
  798. case L('s', 'r'): // Serbian
  799. {
  800. static const unsigned char stress_amps_hr[8] = { 17, 17, 20, 20, 20, 22, 22, 21 };
  801. static const short stress_lengths_hr[8] = { 180, 160, 200, 200, 0, 0, 220, 230 };
  802. static const short stress_lengths_sr[8] = { 160, 150, 200, 200, 0, 0, 250, 260 };
  803. strcpy(tr->dictionary_name, "hbs");
  804. if (name2 == L('s', 'r'))
  805. SetupTranslator(tr, stress_lengths_sr, stress_amps_hr);
  806. else
  807. SetupTranslator(tr, stress_lengths_hr, stress_amps_hr);
  808. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_2;
  809. tr->langopts.stress_rule = STRESSPOSN_1L;
  810. tr->langopts.stress_flags = S_FINAL_NO_2;
  811. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
  812. tr->langopts.max_initial_consonants = 5;
  813. tr->langopts.spelling_stress = 1;
  814. tr->langopts.accents = 1;
  815. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_DECIMAL_COMMA | NUM_THOUS_SPACE | NUM_DFRACTION_2 | NUM_ROMAN_CAPITALS;
  816. tr->langopts.numbers2 = NUM2_THOUSANDPLEX_VAR_THOUSANDS | NUM2_THOUSANDPLEX_VAR_MILLIARDS | NUM2_THOUSANDS_VAR5;
  817. tr->langopts.our_alphabet = OFFSET_CYRILLIC; // don't say "cyrillic" before letter names
  818. SetLetterVowel(tr, 'y');
  819. SetLetterVowel(tr, 'r');
  820. }
  821. break;
  822. case L('h', 't'): // Haitian Creole
  823. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
  824. tr->langopts.stress_flags = S_NO_AUTO_2 | S_FINAL_DIM; // don't use secondary stress
  825. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_OMIT_1_HUNDRED | NUM_NOPAUSE | NUM_ROMAN | NUM_VIGESIMAL | NUM_DFRACTION_4;
  826. break;
  827. case L('h', 'u'): // Hungarian
  828. {
  829. static const unsigned char stress_amps_hu[8] = { 17, 17, 19, 19, 20, 22, 22, 21 };
  830. static const short stress_lengths_hu[8] = { 185, 195, 195, 190, 0, 0, 210, 220 };
  831. SetupTranslator(tr, stress_lengths_hu, stress_amps_hu);
  832. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_2;
  833. tr->langopts.vowel_pause = 0x20;
  834. tr->langopts.stress_rule = STRESSPOSN_1L;
  835. tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_NO_AUTO_2 | 0x8000 | S_HYPEN_UNSTRESS;
  836. tr->langopts.unstressed_wd1 = 2;
  837. tr->langopts.param[LOPT_IT_DOUBLING] = 1;
  838. tr->langopts.param[LOPT_ANNOUNCE_PUNCT] = 2; // don't break clause before announcing . ? !
  839. tr->langopts.numbers = NUM_DFRACTION_5 | NUM_ALLOW_SPACE | NUM_ROMAN | NUM_ROMAN_ORDINAL | NUM_ROMAN_CAPITALS | NUM_ORDINAL_DOT | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND;
  840. tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
  841. tr->langopts.decimal_sep = ',';
  842. tr->langopts.max_roman = 899;
  843. tr->langopts.min_roman = 1;
  844. SetLetterVowel(tr, 'y');
  845. tr->langopts.spelling_stress = 1;
  846. SetLengthMods(tr, 3); // all equal
  847. }
  848. break;
  849. case L('h', 'y'): // Armenian
  850. {
  851. static const short stress_lengths_hy[8] = { 250, 200, 250, 250, 0, 0, 250, 250 };
  852. static const char hy_vowels[] = { 0x31, 0x35, 0x37, 0x38, 0x3b, 0x48, 0x55, 0 };
  853. static const char hy_consonants[] = {
  854. 0x32, 0x33, 0x34, 0x36, 0x39, 0x3a, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44,
  855. 0x46, 0x47, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x56, 0
  856. };
  857. static const char hy_consonants2[] = { 0x45, 0 };
  858. SetupTranslator(tr, stress_lengths_hy, NULL);
  859. tr->langopts.stress_rule = STRESSPOSN_1R; // default stress on final syllable
  860. tr->letter_bits_offset = OFFSET_ARMENIAN;
  861. memset(tr->letter_bits, 0, sizeof(tr->letter_bits));
  862. SetLetterBits(tr, LETTERGP_A, hy_vowels);
  863. SetLetterBits(tr, LETTERGP_VOWEL2, hy_vowels);
  864. SetLetterBits(tr, LETTERGP_B, hy_consonants); // not including 'j'
  865. SetLetterBits(tr, LETTERGP_C, hy_consonants);
  866. SetLetterBits(tr, LETTERGP_C, hy_consonants2); // add 'j'
  867. tr->langopts.max_initial_consonants = 6;
  868. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED;
  869. }
  870. break;
  871. case L('i', 'd'): // Indonesian
  872. case L('m', 's'): // Malay
  873. {
  874. static const short stress_lengths_id[8] = { 160, 200, 180, 180, 0, 0, 220, 240 };
  875. static const unsigned char stress_amps_id[8] = { 16, 18, 18, 18, 20, 22, 22, 21 };
  876. SetupTranslator(tr, stress_lengths_id, stress_amps_id);
  877. tr->langopts.stress_rule = STRESSPOSN_2R;
  878. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_ROMAN;
  879. tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
  880. tr->langopts.accents = 2; // "capital" after letter name
  881. }
  882. break;
  883. case L('i', 's'): // Icelandic
  884. {
  885. static const short stress_lengths_is[8] = { 180, 160, 200, 200, 0, 0, 240, 250 };
  886. static const wchar_t is_lettergroup_B[] = { 'c', 'f', 'h', 'k', 'p', 't', 'x', 0xfe, 0 }; // voiceless conants, including 'þ' ?? 's'
  887. SetupTranslator(tr, stress_lengths_is, NULL);
  888. tr->langopts.stress_rule = STRESSPOSN_1L;
  889. tr->langopts.stress_flags = S_FINAL_NO_2;
  890. tr->langopts.param[LOPT_IT_LENGTHEN] = 0x11; // remove lengthen indicator from unstressed vowels
  891. tr->langopts.param[LOPT_REDUCE] = 2;
  892. ResetLetterBits(tr, 0x18);
  893. SetLetterBits(tr, 4, "kpst"); // Letter group F
  894. SetLetterBits(tr, 3, "jvr"); // Letter group H
  895. tr->letter_groups[1] = is_lettergroup_B;
  896. SetLetterVowel(tr, 'y');
  897. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SINGLE_AND | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_1900;
  898. tr->langopts.numbers2 = NUM2_THOUSANDPLEX_VAR_THOUSANDS;
  899. }
  900. break;
  901. case L('i', 't'): // Italian
  902. {
  903. static const short stress_lengths_it[8] = { 160, 140, 150, 165, 0, 0, 218, 305 };
  904. static const unsigned char stress_amps_it[8] = { 17, 15, 18, 16, 20, 22, 22, 22 };
  905. SetupTranslator(tr, stress_lengths_it, stress_amps_it);
  906. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  907. tr->langopts.stress_rule = STRESSPOSN_2R;
  908. tr->langopts.stress_flags = S_NO_AUTO_2 | S_FINAL_DIM_ONLY | S_PRIORITY_STRESS;
  909. tr->langopts.vowel_pause = 1;
  910. tr->langopts.unstressed_wd1 = 0;
  911. tr->langopts.unstressed_wd2 = 2;
  912. tr->langopts.param[LOPT_IT_LENGTHEN] = 2; // remove lengthen indicator from unstressed or non-penultimate syllables
  913. tr->langopts.param[LOPT_IT_DOUBLING] = 1; // double the first consonant if the previous word ends in a stressed vowel (changed to =1, 23.01.2014 - only use if prev.word has $double)
  914. tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
  915. tr->langopts.param[LOPT_REDUCE] = 1; // reduce vowels even if phonemes are specified in it_list
  916. tr->langopts.param[LOPT_ALT] = 2; // call ApplySpecialAttributes2() if a word has $alt or $alt2
  917. tr->langopts.numbers = NUM_SINGLE_VOWEL | NUM_OMIT_1_HUNDRED |NUM_DECIMAL_COMMA | NUM_DFRACTION_1 | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_ORDINAL;
  918. tr->langopts.numbers2 = NUM2_NO_TEEN_ORDINALS;
  919. tr->langopts.roman_suffix = utf8_ordinal;
  920. tr->langopts.accents = 2; // Say "Capital" after the letter.
  921. SetLetterVowel(tr, 'y');
  922. }
  923. break;
  924. case L3('j', 'b', 'o'): // Lojban
  925. {
  926. static const short stress_lengths_jbo[8] = { 145, 145, 170, 160, 0, 0, 330, 350 };
  927. static const wchar_t jbo_punct_within_word[] = { '.', ',', '\'', 0x2c8, 0 }; // allow period and comma within a word, also stress marker (from LOPT_CAPS_IN_WORD)
  928. SetupTranslator(tr, stress_lengths_jbo, NULL);
  929. tr->langopts.stress_rule = STRESSPOSN_2R;
  930. tr->langopts.vowel_pause = 0x20c; // pause before a word which starts with a vowel, or after a word which ends in a consonant
  931. tr->punct_within_word = jbo_punct_within_word;
  932. tr->langopts.param[LOPT_CAPS_IN_WORD] = 2; // capitals indicate stressed syllables
  933. SetLetterVowel(tr, 'y');
  934. tr->langopts.max_lengthmod = 368;
  935. }
  936. break;
  937. case L('k', 'a'): // Georgian
  938. {
  939. // character codes offset by 0x1080
  940. static const char ka_vowels[] = { 0x30, 0x34, 0x38, 0x3d, 0x43, 0x55, 0x57, 0 };
  941. static const char ka_consonants[] =
  942. { 0x31, 0x32, 0x33, 0x35, 0x36, 0x37, 0x39, 0x3a, 0x3b, 0x3c, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x44,
  943. 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x56, 0 };
  944. SetupTranslator(tr, stress_lengths_ta, stress_amps_ta);
  945. memset(tr->letter_bits, 0, sizeof(tr->letter_bits));
  946. SetLetterBits(tr, LETTERGP_A, ka_vowels);
  947. SetLetterBits(tr, LETTERGP_C, ka_consonants);
  948. SetLetterBits(tr, LETTERGP_VOWEL2, ka_vowels);
  949. tr->langopts.stress_rule = STRESSPOSN_1L;
  950. tr->langopts.stress_flags = S_FINAL_NO_2;
  951. tr->letter_bits_offset = OFFSET_GEORGIAN;
  952. tr->langopts.max_initial_consonants = 7;
  953. tr->langopts.numbers = NUM_VIGESIMAL | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED |NUM_OMIT_1_THOUSAND | NUM_DFRACTION_5 | NUM_ROMAN;
  954. tr->langopts.alt_alphabet = OFFSET_CYRILLIC;
  955. tr->langopts.alt_alphabet_lang = L('r', 'u');
  956. }
  957. break;
  958. case L('k', 'k'): // Kazakh
  959. {
  960. static const unsigned char stress_amps_tr[8] = { 18, 16, 20, 21, 20, 21, 21, 20 };
  961. static const short stress_lengths_tr[8] = { 190, 180, 230, 230, 0, 0, 250, 250 };
  962. tr->letter_bits_offset = OFFSET_CYRILLIC;
  963. memset(tr->letter_bits, 0, sizeof(tr->letter_bits));
  964. SetLetterBits(tr, LETTERGP_A, (char *)ru_vowels);
  965. SetLetterBits(tr, LETTERGP_C, (char *)ru_consonants);
  966. SetLetterBits(tr, LETTERGP_VOWEL2, (char *)ru_vowels);
  967. SetupTranslator(tr, stress_lengths_tr, stress_amps_tr);
  968. tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
  969. tr->langopts.stress_flags = S_NO_AUTO_2 + S_NO_EOC_LENGTHEN; // no automatic secondary stress, don't lengthen at end-of-clause
  970. tr->langopts.lengthen_tonic = 0;
  971. tr->langopts.param[LOPT_SUFFIX] = 1;
  972. tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_DFRACTION_6;
  973. tr->langopts.max_initial_consonants = 2;
  974. SetLengthMods(tr, 3); // all equal
  975. }
  976. break;
  977. case L('k', 'l'): // Greenlandic
  978. {
  979. SetupTranslator(tr, stress_lengths_equal, stress_amps_equal);
  980. tr->langopts.stress_rule = 12;
  981. tr->langopts.stress_flags = S_NO_AUTO_2;
  982. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_ORDINAL_DOT | NUM_1900 | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_ORDINAL;
  983. }
  984. break;
  985. case L('k', 'o'): // Korean, TEST
  986. {
  987. static const char ko_ivowels[] = { 0x63, 0x64, 0x67, 0x68, 0x6d, 0x72, 0x74, 0x75, 0 }; // y and i vowels
  988. static const unsigned char ko_voiced[] = { 0x02, 0x05, 0x06, 0xab, 0xaf, 0xb7, 0xbc, 0 }; // voiced consonants, l,m,n,N
  989. tr->letter_bits_offset = OFFSET_KOREAN;
  990. tr->langopts.our_alphabet = 0xa700;
  991. memset(tr->letter_bits, 0, sizeof(tr->letter_bits));
  992. SetLetterBitsRange(tr, LETTERGP_A, 0x61, 0x75);
  993. SetLetterBits(tr, LETTERGP_Y, ko_ivowels);
  994. SetLetterBits(tr, LETTERGP_G, (const char *)ko_voiced);
  995. tr->langopts.stress_rule = 8; // ?? 1st syllable if it is heavy, else 2nd syllable
  996. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  997. tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
  998. tr->langopts.numbers2 = NUM2_MYRIADS;
  999. tr->langopts.break_numbers = BREAK_MYRIADS;
  1000. tr->langopts.max_digits = 20;
  1001. }
  1002. break;
  1003. case L('k', 'u'): // Kurdish
  1004. {
  1005. static const unsigned char stress_amps_ku[8] = { 18, 18, 20, 20, 20, 22, 22, 21 };
  1006. static const short stress_lengths_ku[8] = { 180, 180, 190, 180, 0, 0, 230, 240 };
  1007. SetupTranslator(tr, stress_lengths_ku, stress_amps_ku);
  1008. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_9;
  1009. tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
  1010. tr->langopts.numbers = NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_AND_HUNDRED;
  1011. tr->langopts.max_initial_consonants = 2;
  1012. }
  1013. break;
  1014. case L('k', 'y'): // Kyrgyx
  1015. tr->langopts.numbers = NUM_DEFAULT;
  1016. break;
  1017. case L('l', 'a'): // Latin
  1018. {
  1019. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_4; // includes a,e,i,o,u-macron
  1020. tr->langopts.stress_rule = STRESSPOSN_2R;
  1021. tr->langopts.stress_flags = S_NO_AUTO_2;
  1022. tr->langopts.unstressed_wd1 = 0;
  1023. tr->langopts.unstressed_wd2 = 2;
  1024. tr->langopts.param[LOPT_DIERESES] = 1;
  1025. tr->langopts.numbers = NUM_ROMAN;
  1026. tr->langopts.max_roman = 5000;
  1027. }
  1028. break;
  1029. case L('l', 't'): // Lithuanian
  1030. {
  1031. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_4;
  1032. tr->langopts.stress_rule = STRESSPOSN_2R;
  1033. tr->langopts.stress_flags = S_NO_AUTO_2;
  1034. tr->langopts.unstressed_wd1 = 0;
  1035. tr->langopts.unstressed_wd2 = 2;
  1036. tr->langopts.param[LOPT_DIERESES] = 1;
  1037. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_4 | NUM_ORDINAL_DOT;
  1038. tr->langopts.numbers2 = NUM2_THOUSANDS_VAR4;
  1039. tr->langopts.max_roman = 5000;
  1040. }
  1041. break;
  1042. case L('l', 'v'): // latvian
  1043. {
  1044. static const unsigned char stress_amps_lv[8] = { 14, 10, 10, 8, 0, 0, 20, 15 };
  1045. static const short stress_lengths_lv[8] = { 180, 180, 180, 160, 0, 0, 230, 180 };
  1046. SetupTranslator(tr, stress_lengths_lv, stress_amps_lv);
  1047. tr->langopts.stress_rule = STRESSPOSN_1L;
  1048. tr->langopts.spelling_stress = 1;
  1049. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_4;
  1050. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_4 | NUM_ORDINAL_DOT;
  1051. tr->langopts.stress_flags = S_NO_AUTO_2 | S_FINAL_DIM | S_FINAL_DIM_ONLY | S_EO_CLAUSE1;
  1052. }
  1053. break;
  1054. case L('m', 'k'): // Macedonian
  1055. {
  1056. static wchar_t vowels_cyrillic[] = {
  1057. // also include 'р' [R]
  1058. 0x440, 0x430, 0x435, 0x438, 0x439, 0x43e, 0x443, 0x44b, 0x44d,
  1059. 0x44e, 0x44f, 0x450, 0x451, 0x456, 0x457, 0x45d, 0x45e, 0
  1060. };
  1061. static const unsigned char stress_amps_mk[8] = { 17, 17, 20, 20, 20, 22, 22, 21 };
  1062. static const short stress_lengths_mk[8] = { 180, 160, 200, 200, 0, 0, 220, 230 };
  1063. SetupTranslator(tr, stress_lengths_mk, stress_amps_mk);
  1064. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_5;
  1065. tr->letter_groups[0] = tr->letter_groups[7] = vowels_cyrillic;
  1066. tr->letter_bits_offset = OFFSET_CYRILLIC;
  1067. tr->langopts.stress_rule = STRESSPOSN_3R; // antipenultimate
  1068. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
  1069. tr->langopts.numbers2 = NUM2_THOUSANDPLEX_VAR_THOUSANDS | NUM2_THOUSANDPLEX_VAR_MILLIARDS | NUM2_THOUSANDS_VAR2;
  1070. }
  1071. break;
  1072. case L('m', 't'): // Maltese
  1073. {
  1074. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_3;
  1075. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
  1076. tr->langopts.stress_rule = STRESSPOSN_2R; // penultimate
  1077. tr->langopts.numbers = NUM_DEFAULT;
  1078. }
  1079. break;
  1080. case L('n', 'l'): // Dutch
  1081. {
  1082. static const short stress_lengths_nl[8] = { 160, 135, 210, 210, 0, 0, 260, 280 };
  1083. tr->langopts.stress_rule = STRESSPOSN_1L;
  1084. tr->langopts.vowel_pause = 0x30; // ??
  1085. tr->langopts.param[LOPT_DIERESES] = 1;
  1086. tr->langopts.param[LOPT_PREFIXES] = 1;
  1087. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
  1088. SetLetterVowel(tr, 'y');
  1089. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ALLOW_SPACE | NUM_1900 | NUM_ORDINAL_DOT;
  1090. tr->langopts.ordinal_indicator = "e";
  1091. tr->langopts.stress_flags = S_FIRST_PRIMARY;
  1092. memcpy(tr->stress_lengths, stress_lengths_nl, sizeof(tr->stress_lengths));
  1093. }
  1094. break;
  1095. case L('n', 'o'): // Norwegian
  1096. {
  1097. static const short stress_lengths_no[8] = { 160, 140, 200, 200, 0, 0, 220, 230 };
  1098. SetupTranslator(tr, stress_lengths_no, NULL);
  1099. tr->langopts.stress_rule = STRESSPOSN_1L;
  1100. SetLetterVowel(tr, 'y');
  1101. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_HUNDRED_AND | NUM_ALLOW_SPACE | NUM_1900 | NUM_ORDINAL_DOT;
  1102. }
  1103. break;
  1104. case L('o', 'm'): // Oromo
  1105. {
  1106. static const unsigned char stress_amps_om[] = { 18, 15, 20, 20, 20, 22, 22, 22 };
  1107. static const short stress_lengths_om[8] = { 200, 200, 200, 200, 0, 0, 200, 200 };
  1108. SetupTranslator(tr, stress_lengths_om, stress_amps_om);
  1109. tr->langopts.stress_rule = STRESSPOSN_2R;
  1110. tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | 0x80000;
  1111. tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_HUNDRED_AND;
  1112. tr->langopts.numbers2 = NUM2_SWAP_THOUSANDS;
  1113. }
  1114. break;
  1115. case L('p', 'l'): // Polish
  1116. {
  1117. static const short stress_lengths_pl[8] = { 160, 190, 175, 175, 0, 0, 200, 210 };
  1118. static const unsigned char stress_amps_pl[8] = { 17, 13, 19, 19, 20, 22, 22, 21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  1119. SetupTranslator(tr, stress_lengths_pl, stress_amps_pl);
  1120. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_2;
  1121. tr->langopts.stress_rule = STRESSPOSN_2R;
  1122. tr->langopts.stress_flags = S_FINAL_DIM_ONLY; // mark unstressed final syllables as diminished
  1123. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x9;
  1124. tr->langopts.max_initial_consonants = 7; // for example: wchrzczony :)
  1125. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_2;
  1126. tr->langopts.numbers2 = NUM2_THOUSANDS_VAR3;
  1127. tr->langopts.param[LOPT_COMBINE_WORDS] = 4 + 0x100; // combine 'nie' (marked with $alt2) with some 1-syllable (and 2-syllable) words (marked with $alt)
  1128. SetLetterVowel(tr, 'y');
  1129. }
  1130. break;
  1131. case L('p', 't'): // Portuguese
  1132. {
  1133. static const short stress_lengths_pt[8] = { 170, 115, 210, 240, 0, 0, 260, 280 };
  1134. static const unsigned char stress_amps_pt[8] = { 16, 11, 19, 21, 20, 22, 22, 21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  1135. SetupTranslator(tr, stress_lengths_pt, stress_amps_pt);
  1136. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1137. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
  1138. tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_INITIAL_2 | S_PRIORITY_STRESS;
  1139. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_DFRACTION_2 | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_ROMAN_CAPITALS;
  1140. tr->langopts.numbers2 = NUM2_MULTIPLE_ORDINAL | NUM2_NO_TEEN_ORDINALS | NUM2_ORDINAL_NO_AND;
  1141. tr->langopts.max_roman = 5000;
  1142. SetLetterVowel(tr, 'y');
  1143. ResetLetterBits(tr, 0x2);
  1144. SetLetterBits(tr, 1, "bcdfgjkmnpqstvxz"); // B hard consonants, excluding h,l,r,w,y
  1145. tr->langopts.param[LOPT_ALT] = 2; // call ApplySpecialAttributes2() if a word has $alt or $alt2
  1146. tr->langopts.accents = 2; // 'capital' after letter name
  1147. }
  1148. break;
  1149. case L('r', 'o'): // Romanian
  1150. {
  1151. static const short stress_lengths_ro[8] = { 170, 170, 180, 180, 0, 0, 240, 260 };
  1152. static const unsigned char stress_amps_ro[8] = { 15, 13, 18, 18, 20, 22, 22, 21 };
  1153. SetupTranslator(tr, stress_lengths_ro, stress_amps_ro);
  1154. tr->langopts.stress_rule = STRESSPOSN_1R;
  1155. tr->langopts.stress_flags = S_FINAL_VOWEL_UNSTRESSED | S_FINAL_DIM_ONLY;
  1156. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_2;
  1157. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_3 | NUM_AND_UNITS | NUM_ROMAN;
  1158. tr->langopts.numbers2 = NUM2_THOUSANDPLEX_VAR_ALL;
  1159. }
  1160. break;
  1161. case L('r', 'u'): // Russian
  1162. Translator_Russian(tr);
  1163. break;
  1164. case L('r', 'w'): // Kiryarwanda
  1165. {
  1166. tr->langopts.stress_rule = STRESSPOSN_2R;
  1167. tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
  1168. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1169. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words. Need to allow "bw'" prefix
  1170. tr->langopts.numbers = NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_DFRACTION_2 | NUM_AND_HUNDRED;
  1171. tr->langopts.numbers2 = NUM2_SWAP_THOUSANDS;
  1172. }
  1173. break;
  1174. case L('s', 'k'): // Slovak
  1175. case L('c', 's'): // Czech
  1176. {
  1177. static const char *sk_voiced = "bdgjlmnrvwzaeiouy";
  1178. SetupTranslator(tr, stress_lengths_sk, stress_amps_sk);
  1179. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_2;
  1180. tr->langopts.stress_rule = STRESSPOSN_1L;
  1181. tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
  1182. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
  1183. tr->langopts.max_initial_consonants = 5;
  1184. tr->langopts.spelling_stress = 1;
  1185. tr->langopts.param[LOPT_COMBINE_WORDS] = 4; // combine some prepositions with the following word
  1186. tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2 | NUM_ROMAN;
  1187. tr->langopts.numbers2 = NUM2_THOUSANDS_VAR2;
  1188. tr->langopts.thousands_sep = 0; // no thousands separator
  1189. tr->langopts.decimal_sep = ',';
  1190. if (name2 == L('c', 's'))
  1191. tr->langopts.numbers2 = NUM2_THOUSANDPLEX_VAR_MILLIARDS | NUM2_THOUSANDS_VAR4;
  1192. SetLetterVowel(tr, 'y');
  1193. SetLetterVowel(tr, 'r');
  1194. ResetLetterBits(tr, 0x20);
  1195. SetLetterBits(tr, 5, sk_voiced);
  1196. }
  1197. break;
  1198. case L('s', 'i'): // Sinhala
  1199. {
  1200. SetupTranslator(tr, stress_lengths_ta, stress_amps_ta);
  1201. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1202. tr->langopts.stress_rule = STRESSPOSN_1L;
  1203. tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
  1204. tr->langopts.spelling_stress = 1;
  1205. tr->letter_bits_offset = OFFSET_SINHALA;
  1206. memset(tr->letter_bits, 0, sizeof(tr->letter_bits));
  1207. SetLetterBitsRange(tr, LETTERGP_A, 0x05, 0x16); // vowel letters
  1208. SetLetterBitsRange(tr, LETTERGP_A, 0x4a, 0x73); // + vowel signs, and virama
  1209. SetLetterBitsRange(tr, LETTERGP_B, 0x4a, 0x73); // vowel signs, and virama
  1210. SetLetterBitsRange(tr, LETTERGP_C, 0x1a, 0x46); // the main consonant range
  1211. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  1212. tr->langopts.suffix_add_e = tr->letter_bits_offset + 0x4a; // virama
  1213. tr->langopts.numbers = NUM_OMIT_1_THOUSAND | NUM_SINGLE_STRESS_L | NUM_DFRACTION_7;
  1214. tr->langopts.numbers2 = NUM2_PERCENT_BEFORE;
  1215. tr->langopts.break_numbers = BREAK_LAKH_HI;
  1216. }
  1217. break;
  1218. case L('s', 'l'): // Slovenian
  1219. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_2;
  1220. tr->langopts.stress_rule = STRESSPOSN_2R; // Temporary
  1221. tr->langopts.stress_flags = S_NO_AUTO_2;
  1222. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x103;
  1223. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x76; // [v] don't count this character at start of word
  1224. tr->langopts.param[LOPT_ALT] = 2; // call ApplySpecialAttributes2() if a word has $alt or $alt2
  1225. tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove lengthen indicator from unstressed syllables
  1226. tr->letter_bits[(int)'r'] |= 0x80; // add 'r' to letter group 7, vowels for Unpronouncable test
  1227. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2 | NUM_ORDINAL_DOT | NUM_ROMAN;
  1228. tr->langopts.numbers2 = NUM2_THOUSANDS_VAR4;
  1229. tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
  1230. break;
  1231. case L('s', 'q'): // Albanian
  1232. {
  1233. static const short stress_lengths_sq[8] = { 150, 150, 180, 180, 0, 0, 300, 300 };
  1234. static const unsigned char stress_amps_sq[8] = { 16, 12, 16, 16, 20, 20, 21, 19 };
  1235. SetupTranslator(tr, stress_lengths_sq, stress_amps_sq);
  1236. tr->langopts.stress_rule = STRESSPOSN_1R;
  1237. tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_FINAL_VOWEL_UNSTRESSED;
  1238. SetLetterVowel(tr, 'y');
  1239. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_DFRACTION_4;
  1240. tr->langopts.accents = 2; // "capital" after letter name
  1241. }
  1242. break;
  1243. case L('s', 'v'): // Swedish
  1244. {
  1245. static const unsigned char stress_amps_sv[] = { 16, 16, 20, 20, 20, 22, 22, 21 };
  1246. static const short stress_lengths_sv[8] = { 160, 135, 220, 220, 0, 0, 250, 280 };
  1247. SetupTranslator(tr, stress_lengths_sv, stress_amps_sv);
  1248. tr->langopts.stress_rule = STRESSPOSN_1L;
  1249. SetLetterVowel(tr, 'y');
  1250. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_1900;
  1251. tr->langopts.accents = 1;
  1252. }
  1253. break;
  1254. case L('s', 'w'): // Swahili
  1255. case L('t', 'n'): // Setswana
  1256. {
  1257. static const short stress_lengths_sw[8] = { 160, 170, 200, 200, 0, 0, 320, 340 };
  1258. static const unsigned char stress_amps_sw[] = { 16, 12, 19, 19, 20, 22, 22, 21 };
  1259. SetupTranslator(tr, stress_lengths_sw, stress_amps_sw);
  1260. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1261. tr->langopts.vowel_pause = 1;
  1262. tr->langopts.stress_rule = STRESSPOSN_2R;
  1263. tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
  1264. tr->langopts.max_initial_consonants = 4; // for example: mwngi
  1265. tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_SINGLE_AND | NUM_OMIT_1_HUNDRED;
  1266. }
  1267. break;
  1268. case L('t', 'a'): // Tamil
  1269. case L('k', 'n'): // Kannada
  1270. case L('m', 'l'): // Malayalam
  1271. case L('t', 'e'): // Telugu
  1272. {
  1273. SetupTranslator(tr, stress_lengths_ta2, stress_amps_ta);
  1274. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1275. tr->langopts.stress_rule = STRESSPOSN_1L;
  1276. tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2; // use 'diminished' for unstressed final syllable
  1277. tr->langopts.spelling_stress = 1;
  1278. tr->langopts.break_numbers = BREAK_LAKH_DV;
  1279. if (name2 == L('t', 'a')) {
  1280. SetupTranslator(tr, stress_lengths_ta, NULL);
  1281. tr->letter_bits_offset = OFFSET_TAMIL;
  1282. tr->langopts.numbers = NUM_OMIT_1_THOUSAND;
  1283. tr->langopts.numbers2 = NUM2_ORDINAL_AND_THOUSANDS;
  1284. tr->langopts.param[LOPT_WORD_MERGE] = 1; // don't break vowels betwen words
  1285. } else if (name2 == L('m', 'l')) {
  1286. static const short stress_lengths_ml[8] = { 180, 160, 240, 240, 0, 0, 260, 260 };
  1287. SetupTranslator(tr, stress_lengths_ml, stress_amps_equal);
  1288. tr->letter_bits_offset = OFFSET_MALAYALAM;
  1289. tr->langopts.numbers = NUM_OMIT_1_THOUSAND | NUM_OMIT_1_HUNDRED;
  1290. tr->langopts.numbers2 = NUM2_OMIT_1_HUNDRED_ONLY;
  1291. tr->langopts.stress_rule = 13; // 1st syllable, unless 1st vowel is short and 2nd is long
  1292. } else if (name2 == L('k', 'n')) {
  1293. tr->letter_bits_offset = OFFSET_KANNADA;
  1294. tr->langopts.numbers = NUM_DEFAULT;
  1295. } else if (name2 == L('t', 'e')) {
  1296. tr->letter_bits_offset = OFFSET_TELUGU;
  1297. tr->langopts.numbers = NUM_DEFAULT;
  1298. tr->langopts.numbers2 = NUM2_ORDINAL_DROP_VOWEL;
  1299. }
  1300. SetIndicLetters(tr); // call this after setting OFFSET_
  1301. SetLetterBitsRange(tr, LETTERGP_B, 0x4e, 0x4e); // chillu-virama (unofficial)
  1302. }
  1303. break;
  1304. case L('t', 'r'): // Turkish
  1305. case L('a', 'z'): // Azerbaijan
  1306. {
  1307. static const unsigned char stress_amps_tr[8] = { 18, 16, 20, 21, 20, 21, 21, 20 };
  1308. static const short stress_lengths_tr[8] = { 190, 180, 200, 230, 0, 0, 240, 250 };
  1309. SetupTranslator(tr, stress_lengths_tr, stress_amps_tr);
  1310. tr->encoding = ESPEAKNG_ENCODING_ISO_8859_9;
  1311. tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
  1312. tr->langopts.stress_flags = S_NO_AUTO_2; // no automatic secondary stress
  1313. tr->langopts.dotless_i = 1;
  1314. tr->langopts.param[LOPT_SUFFIX] = 1;
  1315. if (name2 == L('a', 'z'))
  1316. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
  1317. else
  1318. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
  1319. tr->langopts.max_initial_consonants = 2;
  1320. }
  1321. break;
  1322. case L('t', 't'): // Tatar
  1323. {
  1324. SetCyrillicLetters(tr);
  1325. SetupTranslator(tr, stress_lengths_fr, stress_amps_fr);
  1326. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
  1327. tr->langopts.stress_flags = S_NO_AUTO_2; // no automatic secondary stress
  1328. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_4;
  1329. }
  1330. break;
  1331. case L('u', 'k'): // Ukrainian
  1332. {
  1333. Translator_Russian(tr);
  1334. }
  1335. break;
  1336. case L('u', 'r'): // Urdu
  1337. case L('s', 'd'): // Sindhi
  1338. {
  1339. tr->letter_bits_offset = OFFSET_ARABIC;
  1340. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  1341. tr->langopts.numbers = NUM_SWAP_TENS;
  1342. tr->langopts.break_numbers = BREAK_LAKH_UR;
  1343. }
  1344. break;
  1345. case L('v', 'i'): // Vietnamese
  1346. {
  1347. static const short stress_lengths_vi[8] = { 150, 150, 180, 180, 210, 230, 230, 240 };
  1348. static const unsigned char stress_amps_vi[] = { 16, 16, 16, 16, 22, 22, 22, 22 };
  1349. static wchar_t vowels_vi[] = {
  1350. 0x61, 0xe0, 0xe1, 0x1ea3, 0xe3, 0x1ea1, // a
  1351. 0x103, 0x1eb1, 0x1eaf, 0x1eb3, 0x1eb5, 0x1eb7, // ă
  1352. 0xe2, 0x1ea7, 0x1ea5, 0x1ea9, 0x1eab, 0x1ead, // â
  1353. 0x65, 0xe8, 0xe9, 0x1ebb, 0x1ebd, 0x1eb9, // e
  1354. 0xea, 0x1ec1, 0x1ebf, 0x1ec3, 0x1ec5, 0x1ec7, // i
  1355. 0x69, 0xec, 0xed, 0x1ec9, 0x129, 0x1ecb, // i
  1356. 0x6f, 0xf2, 0xf3, 0x1ecf, 0xf5, 0x1ecd, // o
  1357. 0xf4, 0x1ed3, 0x1ed1, 0x1ed5, 0x1ed7, 0x1ed9, // ô
  1358. 0x1a1, 0x1edd, 0x1edb, 0x1edf, 0x1ee1, 0x1ee3, // ơ
  1359. 0x75, 0xf9, 0xfa, 0x1ee7, 0x169, 0x1ee5, // u
  1360. 0x1b0, 0x1eeb, 0x1ee9, 0x1eed, 0x1eef, 0x1ef1, // ư
  1361. 0x79, 0x1ef3, 0xfd, 0x1ef7, 0x1ef9, 0x1ef5, // y
  1362. 0
  1363. };
  1364. SetupTranslator(tr, stress_lengths_vi, stress_amps_vi);
  1365. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1366. tr->langopts.stress_rule = STRESSPOSN_1L;
  1367. tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
  1368. tr->letter_groups[0] = tr->letter_groups[7] = vowels_vi;
  1369. tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
  1370. tr->langopts.unstressed_wd1 = 2;
  1371. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_HUNDRED_AND_DIGIT | NUM_DFRACTION_4 | NUM_ZERO_HUNDRED;
  1372. }
  1373. break;
  1374. case L('w', 'o'):
  1375. tr->langopts.stress_rule = STRESSPOSN_1L;
  1376. tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_SINGLE_STRESS;
  1377. break;
  1378. case L3('s', 'h', 'n'):
  1379. tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
  1380. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1381. tr->langopts.numbers = NUM_DEFAULT;
  1382. tr->langopts.break_numbers = BREAK_INDIVIDUAL;
  1383. break;
  1384. case L3('c', 'm', 'n'): // no break, just go to 'zh' case
  1385. case L3('z', 'h', 'y'): // just go to 'zh' case
  1386. case L('z','h'):
  1387. {
  1388. static const short stress_lengths_zh[8] = { 230, 150, 230, 230, 230, 0, 240, 250 }; // 1=tone5. end-of-sentence, 6=tone 1&4, 7=tone 2&3
  1389. static const unsigned char stress_amps_zh[] = { 22, 16, 22, 22, 22, 22, 22, 22 };
  1390. SetupTranslator(tr, stress_lengths_zh, stress_amps_zh);
  1391. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable of a "word"
  1392. tr->langopts.stress_flags = S_NO_DIM; // don't automatically set diminished stress (may be set in the intonation module)
  1393. tr->langopts.vowel_pause = 0;
  1394. tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
  1395. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1396. tr->langopts.tone_numbers = 1; // a number after letters indicates a tone number (eg. pinyin or jyutping)
  1397. tr->langopts.ideographs = 1;
  1398. tr->langopts.our_alphabet = 0x3100;
  1399. tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
  1400. if (name2 == L3('z', 'h', 'y')) {
  1401. tr->langopts.textmode = true;
  1402. tr->langopts.listx = 1; // compile zh_listx after zh_list
  1403. tr->langopts.numbers = NUM_DEFAULT;
  1404. tr->langopts.numbers2 = NUM2_ZERO_TENS;
  1405. tr->langopts.break_numbers = BREAK_INDIVIDUAL;
  1406. }
  1407. break;
  1408. }
  1409. default:
  1410. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  1411. break;
  1412. }
  1413. tr->translator_name = name2;
  1414. ProcessLanguageOptions(&tr->langopts);
  1415. return tr;
  1416. }
  1417. void ProcessLanguageOptions(LANGUAGE_OPTIONS *langopts)
  1418. {
  1419. if (langopts->numbers & NUM_DECIMAL_COMMA) {
  1420. // use . and ; for thousands and decimal separators
  1421. langopts->thousands_sep = '.';
  1422. langopts->decimal_sep = ',';
  1423. }
  1424. if (langopts->numbers & NUM_THOUS_SPACE)
  1425. langopts->thousands_sep = 0; // don't allow thousands separator, except space
  1426. }
  1427. static void Translator_Russian(Translator *tr)
  1428. {
  1429. static const unsigned char stress_amps_ru[] = { 16, 16, 18, 18, 20, 24, 24, 22 };
  1430. static const short stress_lengths_ru[8] = { 150, 140, 220, 220, 0, 0, 260, 280 };
  1431. static const char ru_ivowels[] = { 0x15, 0x18, 0x34, 0x37, 0 }; // add "е и є ї" to Y lettergroup (iotated vowels & soft-sign)
  1432. SetupTranslator(tr, stress_lengths_ru, stress_amps_ru);
  1433. SetCyrillicLetters(tr);
  1434. SetLetterBits(tr, LETTERGP_Y, ru_ivowels);
  1435. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
  1436. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 1;
  1437. tr->langopts.param[LOPT_REDUCE] = 2;
  1438. tr->langopts.stress_rule = 5;
  1439. tr->langopts.stress_flags = S_NO_AUTO_2;
  1440. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED;
  1441. tr->langopts.numbers2 = NUM2_THOUSANDPLEX_VAR_THOUSANDS | NUM2_THOUSANDS_VAR1; // variant numbers before thousands
  1442. }