From b0a7ef278927c8a877a6dd5f4a4a377080188543 Mon Sep 17 00:00:00 2001 From: Juho Hiltunen Date: Thu, 4 Mar 2021 18:52:16 +0200 Subject: [PATCH 1/3] add macro L4() needed by Klingon (piqd) --- src/libespeak-ng/translate.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libespeak-ng/translate.h b/src/libespeak-ng/translate.h index d9f79b4a..75ef984c 100644 --- a/src/libespeak-ng/translate.h +++ b/src/libespeak-ng/translate.h @@ -32,6 +32,7 @@ extern "C" #define L(c1, c2) (c1<<8)+c2 // combine two characters into an integer for translator name #define L3(c1, c2, c3) (c1<<16)+(c2<<8) + c3 // combine three characters into an integer for translator name +#define L4(c1, c2, c3, c4) (c1<<24)+(c2<<16)+(c3<<8) + c4 // combine four characters into an integer for translator name #define CTRL_EMBEDDED 0x01 // control character at the start of an embedded command #define REPLACED_E 'E' // 'e' replaced by silent e From a54824c9e59ebf4ba78971c8082884f8e0504dba Mon Sep 17 00:00:00 2001 From: jaacoppi Date: Wed, 3 Mar 2021 15:06:21 +0200 Subject: [PATCH 2/3] voices: Change default number pronunciation rule to enabled. docs: add details about number flags to the documentation. It's clearly intended to be enabled by default: - it's defined as default behaviour translate.h (NUM_DEFAULT) - tr_languages.c sets many default values related to number processing that have no meaning unless langopts.numbers == 1. It is also a more sensible default since most languages will want to have number processing on. This makes adding new languages easier because adding an entry to tr_languages.c is unnecessary. A negative side effect is that languages with partial number defines might experience bugs when reading undefined numbers. This is a bug and should be fixed. This will have the side effect of enabling number processing for languages that currently have it disabled. However, there shouldn't be any. Here's a way to check affected languages: for voice in $(ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} src/espeak-ng --voices | grep -v Languages | awk '{print $2}'); do OUTPUT=$(ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} src/espeak-ng -qx -v $voice "1 - 2 - 3 - 12 - 123") && echo "$voice: $OUTPUT" ; done These voices clearly benefit from enabling numbers (they already have number rules in *_list): ba, cmn (zh), hak, haw, ja, kok, nb, nci Some languages are missing some definitions (like _12) in _list files. It causes the program to skip some numbers. Numbering needs to be turned off explicitly for: jbo, mi, my, piqd, py, qu, quc, th, uz Languages with no number rules at all: chr, cv, he, nog, tk, ug --- docs/numbers.md | 6 ++++-- src/libespeak-ng/tr_languages.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/numbers.md b/docs/numbers.md index 348fd475..c9fc5991 100644 --- a/docs/numbers.md +++ b/docs/numbers.md @@ -12,8 +12,10 @@ language: These controls how numbers are pronounced. -If `numbers` is set to `0` (the default value), numbers will not be pronounced. -Setting it to `1` will enable number pronunciation using the dictionary rules. +If `numbers` is set to `0`, numbers will not be pronounced. +Setting it to `1` (the default value) will enable number pronunciation using the dictionary rules. +For more control over number pronunciation, see the flags in `translate.h`. + tr->langopts.max_digits diff --git a/src/libespeak-ng/tr_languages.c b/src/libespeak-ng/tr_languages.c index 7ed230b1..170572e3 100644 --- a/src/libespeak-ng/tr_languages.c +++ b/src/libespeak-ng/tr_languages.c @@ -2,6 +2,7 @@ * Copyright (C) 2005 to 2015 by Jonathan Duddington * email: jonsd@users.sourceforge.net * Copyright (C) 2015-2016, 2020 Reece H. Dunn + * Copyright (C) 2021 Juho Hiltunen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -305,6 +306,7 @@ static Translator *NewTranslator(void) tr->langopts.min_roman = 2; tr->langopts.thousands_sep = ','; tr->langopts.decimal_sep = '.'; + tr->langopts.numbers = NUM_DEFAULT; tr->langopts.break_numbers = BREAK_THOUSANDS; tr->langopts.max_digits = 14; @@ -477,6 +479,18 @@ Translator *SelectTranslator(const char *name) switch (name2) { + case L('m', 'i'): + case L('m', 'y'): + case L4('p', 'i', 'q', 'd'): // piqd + case L('p', 'y'): + case L('q', 'u'): + case L3('q', 'u', 'c'): + case L('t', 'h'): + case L('u', 'z'): + { + tr->langopts.numbers = 0; // disable numbers until the definition are complete in _list file + } + break; case L('a', 'f'): { static const short stress_lengths_af[8] = { 170, 140, 220, 220, 0, 0, 250, 270 }; @@ -1065,6 +1079,7 @@ Translator *SelectTranslator(const char *name) tr->langopts.param[LOPT_CAPS_IN_WORD] = 1; // capitals indicate stressed syllables SetLetterVowel(tr, 'y'); tr->langopts.max_lengthmod = 368; + tr->langopts.numbers = 0; // disable numbers until the definition are complete in _list file } break; case L('k', 'a'): // Georgian From 1914d39d9f02b694f0b29648eb3149914749fc65 Mon Sep 17 00:00:00 2001 From: Juho Hiltunen Date: Fri, 5 Mar 2021 06:21:47 +0200 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34d5a8bf..1f93ad05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,17 +20,21 @@ documentation: * Add documentation about dictionary flags. updated languages: -* ba (Bashkir) -- boracasli98, Valdis Vitolins -* chr (Cherokee) -- Michael Conrad +* ba (Bashkir) -- boracasli98, Valdis Vitolins, Juho Hiltunen * de (German) -- Karl Eick * el (Modern Greek) -- Reece Dunn (support for variant Greek letter forms) * en (English) -- Steven Presser, Ben Talagan * ga (Gaelic (Irish)) Chen, Chien-ting * grc (Ancient Greek) -- Reece Dunn (support for variant Greek letter forms) +* hak (Hakka Chinese) -- Juho Hiltunen +* haw (Hawaiian) -- Juho Hiltunen +* kok (Konkani) -- Juho Hiltunen +* nb (Norwegian Bokmål) -- Juho Hiltunen +* nci (Classical Nahuatl) -- Juho Hiltunen * hy (Armenian) -- tigransimonyan * ia (Interlingua) -- nesrad * it (Italian) -- Christian Leo -* ja (Japanese) -- fukuen +* ja (Japanese) -- fukuen, Juho Hiltunen * jbo (Lojban) -- Juho Hiltunen, xunsku * lv (Latvian) -- Valdis Vitolins * mi (Māori) -- boracasli98 @@ -38,7 +42,7 @@ updated languages: * tr (Turkish) -- boracasli98 * ur (Urdu) -- Ejaz Shah * uz (Uzbek) -- boracasli98, Valdis Vitolins -* zh (Chinese) -- Silas S. Brown, Rongcui Dong, Icenowy Zheng +* zh (Chinese) -- Silas S. Brown, Rongcui Dong, Icenowy Zheng, Juho Hiltunen new languages: * chr (Cherokee) -- Michael Conrad