mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-23 20:14:23 +00:00
New language option lowercaseSentence
When set in a language file, a period followed by a lower case letter is detected as end of sentence. Normal behavior is to require a capital letter.
This commit is contained in:
@@ -876,9 +876,9 @@ int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_
|
||||
else if (iswlower(c_next) || (c_next == '-')) // hyphen is needed for lang-hu (eg. 2.-kal)
|
||||
is_end_clause = false; // only if followed by lower-case, (or if there is a XML tag)
|
||||
}
|
||||
if (iswlower(c_next)) {
|
||||
if (iswlower(c_next) && tr->langopts.lowercase_sentence == false) {
|
||||
// next word has no capital letter, this dot is probably from an abbreviation
|
||||
is_end_clause = 0;
|
||||
is_end_clause = false;
|
||||
}
|
||||
if (any_alnum == false) {
|
||||
// no letters or digits yet, so probably not a sentence terminator
|
||||
|
||||
@@ -295,6 +295,7 @@ static Translator *NewTranslator(void)
|
||||
tr->langopts.replace_chars = NULL;
|
||||
tr->langopts.alt_alphabet_lang = L('e', 'n');
|
||||
tr->langopts.roman_suffix = utf8_null;
|
||||
tr->langopts.lowercase_sentence = false;
|
||||
|
||||
SetLengthMods(tr, 201);
|
||||
|
||||
|
||||
@@ -540,6 +540,7 @@ typedef struct {
|
||||
int max_lengthmod;
|
||||
int lengthen_tonic; // lengthen the tonic syllable
|
||||
int suffix_add_e; // replace a suffix (which has the SUFX_E flag) with this character
|
||||
bool lowercase_sentence; // when true, a period . causes a sentence stop even if next character is lowercase
|
||||
} LANGUAGE_OPTIONS;
|
||||
|
||||
typedef struct {
|
||||
@@ -608,6 +609,7 @@ typedef struct {
|
||||
int end_stressed_vowel; // word ends with stressed vowel
|
||||
int prev_dict_flags[2]; // dictionary flags from previous word
|
||||
int clause_terminator;
|
||||
|
||||
} Translator;
|
||||
|
||||
#define OPTION_EMPHASIZE_ALLCAPS 0x100
|
||||
|
||||
@@ -92,6 +92,7 @@ enum {
|
||||
V_BREATHW,
|
||||
|
||||
// these override defaults set by the translator
|
||||
V_LOWERCASE_SENTENCE,
|
||||
V_WORDGAP,
|
||||
V_INTONATION,
|
||||
V_TUNES,
|
||||
@@ -122,6 +123,8 @@ static MNEM_TAB keyword_tab[] = {
|
||||
{ "maintainer", V_MAINTAINER },
|
||||
{ "status", V_STATUS },
|
||||
|
||||
|
||||
{ "lowercaseSentence", V_LOWERCASE_SENTENCE },
|
||||
{ "variants", V_VARIANTS },
|
||||
{ "formant", V_FORMANT },
|
||||
{ "pitch", V_PITCH },
|
||||
@@ -654,6 +657,14 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
case V_FORMANT:
|
||||
VoiceFormant(p);
|
||||
break;
|
||||
case V_LOWERCASE_SENTENCE: {
|
||||
if (langopts)
|
||||
langopts->lowercase_sentence = true;
|
||||
else
|
||||
fprintf(stderr, "Cannot set lowercaseSentence: language not set, or is invalid.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
case V_PITCH:
|
||||
// default is pitch 82 118
|
||||
if (sscanf(p, "%d %d", &pitch1, &pitch2) == 2) {
|
||||
|
||||
Reference in New Issue
Block a user