Browse Source

Fix non-Latin character languages falling back to English when reading Latin characters.

master
Reece H. Dunn 8 years ago
parent
commit
48ca2239bb
2 changed files with 25 additions and 4 deletions
  1. 8
    0
      src/libespeak-ng/dictionary.c
  2. 17
    4
      tests/languages.test

+ 8
- 0
src/libespeak-ng/dictionary.c View File

@@ -2290,6 +2290,14 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
if ((match1.points == 0) && ((option_sayas & 0x10) == 0)) {
n = utf8_in(&letter, p-1)-1;

if (tr->letter_bits_offset > 0) {
// not a Latin alphabet, switch to the default Latin alphabet language
if ((letter <= 0x241) && iswalpha(letter)) {
sprintf(phonemes, "%cen", phonSWITCH);
return 0;
}
}

// is it a bracket ?
if (letter == 0xe000+'(') {
if (pre_pause < tr->langopts.param2[LOPT_BRACKET_PAUSE])

+ 17
- 4
tests/languages.test View File

@@ -1,11 +1,19 @@
#!/bin/sh

test_lang() {
TEST_LANG=$1
EXPECTED=$2
TEST_TEXT=$3
if test "$#" -eq 3; then
TEST_LANG=$1
TEST_NAME=$1
EXPECTED=$2
TEST_TEXT=$3
else
TEST_LANG=$1
TEST_NAME=$2
EXPECTED=$3
TEST_TEXT=$4
fi

echo "testing ${TEST_LANG}"
echo "testing ${TEST_NAME}"
ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
src/espeak-ng --stdout -v ${TEST_LANG} "${TEST_TEXT}" | \
sha1sum | awk '{ print $1 }' > actual.txt
@@ -30,3 +38,8 @@ test_lang en-GB-x-rp 8f1f36267f10c88ca822355ecd9d4ee37faa8228 "foot strut north
test_lang en-US 1653355ef008d67d315aa20e630e00614472a045 "foot strut north force cure thought lot cloth trap bath"

test_lang jp a3651d81da9158ee8b76bd6a31025220b4d84932 "か き く け こ"

# Languages with non-Latin characters fall back to en when speaking Latin characters.
test_lang bg "bg (English text)" ad98e816727288c7f3c525a4b4c30e72c7ea0c00 "foot strut north force cure thought lot cloth trap bath"
test_lang fa "fa (English text)" 9460f3dcd6cc7b4f3f45a9021f7706f1bdc7ae8f "foot strut north force cure thought lot cloth trap bath"
test_lang ka "ka (English text)" 4995fdb0fbe16bd97061c762badea03c1c44ba63 "foot strut north force cure thought lot cloth trap bath"

Loading…
Cancel
Save