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

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