code cleanup: move SetLengthMods to setlengths.c

This commit is contained in:
Juho Hiltunen
2021-07-11 17:05:00 +03:00
parent 72434616b0
commit 863655903a
6 changed files with 69 additions and 68 deletions
+66
View File
@@ -807,3 +807,69 @@ void CalcLengths(Translator *tr)
}
}
}
// Tables of the relative lengths of vowels, depending on the
// type of the two phonemes that follow
// indexes are the "length_mod" value for the following phonemes
// use this table if vowel is not the last in the word
static unsigned char length_mods_en[100] = {
// a , t s n d z r N <- next
100, 120, 100, 105, 100, 110, 110, 100, 95, 100, // a <- next2
105, 120, 105, 110, 125, 130, 135, 115, 125, 100, // ,
105, 120, 75, 100, 75, 105, 120, 85, 75, 100, // t
105, 120, 85, 105, 95, 115, 120, 100, 95, 100, // s
110, 120, 95, 105, 100, 115, 120, 100, 100, 100, // n
105, 120, 100, 105, 95, 115, 120, 110, 95, 100, // d
105, 120, 100, 105, 105, 122, 125, 110, 105, 100, // z
105, 120, 100, 105, 105, 122, 125, 110, 105, 100, // r
105, 120, 95, 105, 100, 115, 120, 110, 100, 100, // N
100, 120, 100, 100, 100, 100, 100, 100, 100, 100
};
// as above, but for the last syllable in a word
static unsigned char length_mods_en0[100] = {
// a , t s n d z r N <- next
100, 150, 100, 105, 110, 115, 110, 110, 110, 100, // a <- next2
105, 150, 105, 110, 125, 135, 140, 115, 135, 100, // ,
105, 150, 90, 105, 90, 122, 135, 100, 90, 100, // t
105, 150, 100, 105, 100, 122, 135, 100, 100, 100, // s
105, 150, 100, 105, 105, 115, 135, 110, 105, 100, // n
105, 150, 100, 105, 105, 122, 130, 120, 125, 100, // d
105, 150, 100, 105, 110, 122, 125, 115, 110, 100, // z
105, 150, 100, 105, 105, 122, 135, 120, 105, 100, // r
105, 150, 100, 105, 105, 115, 135, 110, 105, 100, // N
100, 100, 100, 100, 100, 100, 100, 100, 100, 100
};
static unsigned char length_mods_equal[100] = {
// a , t s n d z r N <- next
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // a <- next2
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // ,
110, 120, 100, 110, 100, 110, 110, 110, 100, 110, // t
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // s
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // n
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // d
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // z
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // r
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // N
110, 120, 100, 110, 110, 110, 110, 110, 110, 110
};
static unsigned char *length_mod_tabs[6] = {
length_mods_en,
length_mods_en, // 1
length_mods_en0, // 2
length_mods_equal, // 3
length_mods_equal, // 4
length_mods_equal // 5
};
void SetLengthMods(Translator *tr, int value)
{
int value2;
tr->langopts.length_mods0 = tr->langopts.length_mods = length_mod_tabs[value % 100];
if ((value2 = value / 100) != 0)
tr->langopts.length_mods0 = length_mod_tabs[value2];
}
+1
View File
@@ -29,6 +29,7 @@ extern "C"
#endif
void CalcLengths(Translator *tr);
void SetLengthMods(Translator *tr, int value);
espeak_ng_STATUS SetParameter(int parameter,
int value,
+1
View File
@@ -31,6 +31,7 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>
#include "setlengths.h" // for SetLengthMods
#include "translate.h" // for Translator, LANGUAGE_OPTIONS, L, NUM...
// start of unicode pages for character sets
-67
View File
@@ -115,73 +115,6 @@ static const unsigned short brackets[] = {
// other characters which break a word, but don't produce a pause
static const unsigned short breaks[] = { '_', 0 };
// Tables of the relative lengths of vowels, depending on the
// type of the two phonemes that follow
// indexes are the "length_mod" value for the following phonemes
// use this table if vowel is not the last in the word
static unsigned char length_mods_en[100] = {
// a , t s n d z r N <- next
100, 120, 100, 105, 100, 110, 110, 100, 95, 100, // a <- next2
105, 120, 105, 110, 125, 130, 135, 115, 125, 100, // ,
105, 120, 75, 100, 75, 105, 120, 85, 75, 100, // t
105, 120, 85, 105, 95, 115, 120, 100, 95, 100, // s
110, 120, 95, 105, 100, 115, 120, 100, 100, 100, // n
105, 120, 100, 105, 95, 115, 120, 110, 95, 100, // d
105, 120, 100, 105, 105, 122, 125, 110, 105, 100, // z
105, 120, 100, 105, 105, 122, 125, 110, 105, 100, // r
105, 120, 95, 105, 100, 115, 120, 110, 100, 100, // N
100, 120, 100, 100, 100, 100, 100, 100, 100, 100
};
// as above, but for the last syllable in a word
static unsigned char length_mods_en0[100] = {
// a , t s n d z r N <- next
100, 150, 100, 105, 110, 115, 110, 110, 110, 100, // a <- next2
105, 150, 105, 110, 125, 135, 140, 115, 135, 100, // ,
105, 150, 90, 105, 90, 122, 135, 100, 90, 100, // t
105, 150, 100, 105, 100, 122, 135, 100, 100, 100, // s
105, 150, 100, 105, 105, 115, 135, 110, 105, 100, // n
105, 150, 100, 105, 105, 122, 130, 120, 125, 100, // d
105, 150, 100, 105, 110, 122, 125, 115, 110, 100, // z
105, 150, 100, 105, 105, 122, 135, 120, 105, 100, // r
105, 150, 100, 105, 105, 115, 135, 110, 105, 100, // N
100, 100, 100, 100, 100, 100, 100, 100, 100, 100
};
static unsigned char length_mods_equal[100] = {
// a , t s n d z r N <- next
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // a <- next2
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // ,
110, 120, 100, 110, 100, 110, 110, 110, 100, 110, // t
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // s
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // n
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // d
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // z
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // r
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // N
110, 120, 100, 110, 110, 110, 110, 110, 110, 110
};
static unsigned char *length_mod_tabs[6] = {
length_mods_en,
length_mods_en, // 1
length_mods_en0, // 2
length_mods_equal, // 3
length_mods_equal, // 4
length_mods_equal // 5
};
void SetLengthMods(Translator *tr, int value)
{
int value2;
tr->langopts.length_mods0 = tr->langopts.length_mods = length_mod_tabs[value % 100];
if ((value2 = value / 100) != 0)
tr->langopts.length_mods0 = length_mod_tabs[value2];
}
int IsAlpha(unsigned int c)
{
// Replacement for iswalph() which also checks for some in-word symbols
-1
View File
@@ -659,7 +659,6 @@ extern int dictionary_skipwords;
extern int (*uri_callback)(int, const char *, const char *);
extern int (*phoneme_callback)(const char *);
extern void SetLengthMods(Translator *tr, int value);
#define LEADING_2_BITS 0xC0 // 0b11000000
#define UTF8_TAIL_BITS 0x80 // 0b10000000
+1
View File
@@ -42,6 +42,7 @@
#include "dictionary.h" // for strncpy0, LoadDictionary
#include "mnemonics.h" // for LookupMnemName, MNEM_TAB
#include "phoneme.h" // for REPLACE_PHONEMES, n_replace_pho...
#include "setlengths.h" // for SetLengthMods
#include "speech.h" // for GetFileLength, PATHSEP
#include "mbrola.h" // for LoadMbrolaTable
#include "synthdata.h" // for SelectPhonemeTableName, LookupP...