mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-21 03:24:48 +00:00
[1.26.02] SelectVoice(), make voice_variants[] static.
lang=de many translation improvements. TranslateWord(), check that a prefix rule is still allowed after a suffix has been removed. git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@43 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
+3
-3
@@ -689,7 +689,7 @@ void copy_rule_string(char *string, int &state)
|
||||
case '$': // obsolete, replaced by S
|
||||
case 'S':
|
||||
output[ix++] = RULE_ENDING;
|
||||
value = 0x80;
|
||||
value = 0;
|
||||
while(!isspace2(c = *p++) && (c != 0))
|
||||
{
|
||||
switch(c)
|
||||
@@ -720,14 +720,14 @@ void copy_rule_string(char *string, int &state)
|
||||
break;
|
||||
default:
|
||||
if(isdigit(c))
|
||||
value = (c - '0') + 0x80;
|
||||
value = (value*10) + (c - '0');
|
||||
break;
|
||||
}
|
||||
}
|
||||
p--;
|
||||
output[ix++] = sxflags >> 16;
|
||||
output[ix++] = sxflags >> 8;
|
||||
c = value;
|
||||
c = value | 0x80;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+17
-5
@@ -2115,7 +2115,7 @@ void Translator::MatchRule(char *word[], const char *group, char *rule, MatchRec
|
||||
}
|
||||
|
||||
#ifdef LOG_TRANSLATE
|
||||
if((option_phonemes == 2) && (match.points > 0))
|
||||
if((option_phonemes == 2) && (match.points > 0) && ((word_flags & FLAG_NO_TRACE) == 0))
|
||||
{
|
||||
// show each rule that matches, and it's points score
|
||||
int pts;
|
||||
@@ -2137,7 +2137,7 @@ void Translator::MatchRule(char *word[], const char *group, char *rule, MatchRec
|
||||
}
|
||||
|
||||
#ifdef LOG_TRANSLATE
|
||||
if(option_phonemes == 2)
|
||||
if((option_phonemes == 2) && ((word_flags & FLAG_NO_TRACE)==0))
|
||||
{
|
||||
if(group_length <= 1)
|
||||
fprintf(f_trans,"\n");
|
||||
@@ -2188,7 +2188,7 @@ int Translator::TranslateRules(char *p, char *phonemes, int ph_size, char *end_p
|
||||
return(0);
|
||||
|
||||
#ifdef LOG_TRANSLATE
|
||||
if(option_phonemes == 2)
|
||||
if((option_phonemes == 2) && ((word_flags & FLAG_NO_TRACE)==0))
|
||||
{
|
||||
char wordbuf[120];
|
||||
int ix;
|
||||
@@ -2345,8 +2345,20 @@ int Translator::TranslateRules(char *p, char *phonemes, int ph_size, char *end_p
|
||||
if((match1.end_type != 0) && (end_phonemes != NULL))
|
||||
{
|
||||
/* a standard ending has been found, re-translate the word without it */
|
||||
strcpy(end_phonemes,match1.phonemes);
|
||||
return(match1.end_type);
|
||||
if((match1.end_type & SUFX_P) && (word_flags & FLAG_NO_PREFIX))
|
||||
{
|
||||
// ignore the match on a prefix
|
||||
}
|
||||
else
|
||||
{
|
||||
if((match1.end_type & SUFX_P) && ((match1.end_type & 0x7f) == 0))
|
||||
{
|
||||
// no prefix length specified
|
||||
match1.end_type |= p - p_start;
|
||||
}
|
||||
strcpy(end_phonemes,match1.phonemes);
|
||||
return(match1.end_type);
|
||||
}
|
||||
}
|
||||
if(match1.del_fwd != NULL)
|
||||
*match1.del_fwd = REPLACED_E;
|
||||
|
||||
+29
-2
@@ -214,8 +214,8 @@ void DecodePhonemes2(const char *inptr, char *outptr)
|
||||
int start;
|
||||
static const char *stress_chars = "==,,'* ";
|
||||
|
||||
unsigned int replace_ph[] = {',',PH('@','-'),'W','3','y',PH('A',':'),'*',PH('_','!'),PH('_','|'),PH('O','I'),PH('Y',':'),PH('p','F'),PH('E','2'),0};
|
||||
const char *replace_ph2[] = {NULL,NULL, "9","@r","Y", "a:", "r", "?", "?", "OY", "2:", "pf" ,"E",NULL};
|
||||
unsigned int replace_ph[] = {',',PH('@','-'),'W','3','y','A',PH('A',':'),'*',PH('_','!'),PH('_','|'),PH('O','I'),PH('Y',':'),PH('p','F'),PH('E','2'),0};
|
||||
const char *replace_ph2[] = {NULL,NULL,"9","@r","Y","a:", "a:", "r", "?", "?", "OY", "2:", "pf" ,"E",NULL};
|
||||
|
||||
|
||||
start = 1;
|
||||
@@ -289,11 +289,13 @@ void Lexicon_De()
|
||||
FILE *f_out;
|
||||
int ix;
|
||||
int c;
|
||||
int c2;
|
||||
char *p;
|
||||
int stress;
|
||||
int count=0;
|
||||
int start;
|
||||
int matched=0;
|
||||
int defer_stress = 0;
|
||||
char buf[120];
|
||||
char word[80];
|
||||
char word2[80];
|
||||
@@ -367,7 +369,32 @@ void Lexicon_De()
|
||||
if((c == '?') && start)
|
||||
continue; // omit initial [?]
|
||||
|
||||
if(c == '<')
|
||||
{
|
||||
if((c2 = pronounce[ix+1]) == 'i')
|
||||
{
|
||||
defer_stress =1;
|
||||
#ifdef deleted
|
||||
if(stress == 4)
|
||||
{
|
||||
*p++ = 'i';
|
||||
c =':';
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
c = 'I';
|
||||
}
|
||||
ix++;
|
||||
}
|
||||
}
|
||||
|
||||
start =0;
|
||||
if(defer_stress)
|
||||
{
|
||||
defer_stress = 0;
|
||||
}
|
||||
else
|
||||
if(stress && (strchr(vowels,c) != NULL))
|
||||
{
|
||||
if(stress == 4)
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@
|
||||
#include "translate.h"
|
||||
#include "wave.h"
|
||||
|
||||
const char *version_string = "1.26.01 09.Jun.07";
|
||||
const char *version_string = "1.26.02 11.Jun.07";
|
||||
const int version_phdata = 0x012601;
|
||||
|
||||
int option_device_number = -1;
|
||||
|
||||
+38
-2
@@ -606,6 +606,7 @@ int Translator::TranslateWord(char *word1, int next_pause, WORD_TAB *wtab)
|
||||
int unpron_length;
|
||||
int add_plural_suffix = 0;
|
||||
int prefix_flags = 0;
|
||||
int confirm_prefix;
|
||||
int spell_word;
|
||||
int wflags = wtab->flags;
|
||||
int wmark = wtab->wmark;
|
||||
@@ -755,9 +756,42 @@ printf("TR3 length=%d\n",length);
|
||||
c_temp = word[-1];
|
||||
|
||||
found = 0;
|
||||
confirm_prefix = 1;
|
||||
while(end_type & SUFX_P)
|
||||
{
|
||||
// Found a standard prefix, remove it and retranslate
|
||||
|
||||
if(confirm_prefix)
|
||||
{
|
||||
int end2;
|
||||
char phonemes2[N_WORD_PHONEMES];
|
||||
char end_phonemes2[N_WORD_PHONEMES];
|
||||
|
||||
// remove any standard suffix and confirm that the prefix is still recognised
|
||||
end2 = TranslateRules(word, phonemes2, N_WORD_PHONEMES, end_phonemes2, wflags|FLAG_NO_PREFIX|FLAG_NO_TRACE, dictionary_flags);
|
||||
if(end2)
|
||||
{
|
||||
RemoveEnding(word,end2,word_copy);
|
||||
end_type = TranslateRules(word, phonemes, N_WORD_PHONEMES, end_phonemes, wflags|FLAG_NO_TRACE, dictionary_flags);
|
||||
memcpy(word,word_copy,strlen(word_copy));
|
||||
if((end_type & SUFX_P) == 0)
|
||||
{
|
||||
// after removing the suffix, the prefix is no longer recognised.
|
||||
// Keep the suffix, but don't use the prefix
|
||||
end_type = end2;
|
||||
strcpy(phonemes,phonemes2);
|
||||
strcpy(end_phonemes,end_phonemes2);
|
||||
if(option_phonemes == 2)
|
||||
{
|
||||
DecodePhonemes(end_phonemes,end_phonemes2);
|
||||
fprintf(f_trans," suffix [%s]\n\n",end_phonemes2);
|
||||
}
|
||||
}
|
||||
confirm_prefix = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
strcat(prefix_phonemes,end_phonemes);
|
||||
end_phonemes[0] = 0;
|
||||
prefix_type = end_type;
|
||||
@@ -775,6 +809,7 @@ printf("TR3 length=%d\n",length);
|
||||
}
|
||||
c_temp = word[-1];
|
||||
word[-1] = ' ';
|
||||
confirm_prefix = 1;
|
||||
|
||||
end_type = 0;
|
||||
found = LookupDictList(word,phonemes,&dictionary_flags2,SUFX_P | (wflags << 16));
|
||||
@@ -817,8 +852,9 @@ strcpy(phonemes2,phonemes);
|
||||
dictionary_flags = dictionary_flags2;
|
||||
if(found)
|
||||
prefix_phonemes[0] = 0; // matched whole word, don't need prefix now
|
||||
if(found || (dictionary_flags2 != 0))
|
||||
prefix_flags = 1;
|
||||
|
||||
// if(found || (dictionary_flags2 != 0))
|
||||
// prefix_flags = 1; // ?? this looks wrong
|
||||
}
|
||||
if(found == 0)
|
||||
{
|
||||
|
||||
@@ -78,6 +78,8 @@
|
||||
#define FLAG_DONT_SWITCH_TRANSLATOR 0x1000
|
||||
#define FLAG_SUFFIX_REMOVED 0x2000
|
||||
#define FLAG_HYPHEN_AFTER 0x4000
|
||||
#define FLAG_NO_PREFIX 0x8000
|
||||
#define FLAG_NO_TRACE 0x10000
|
||||
|
||||
// prefix/suffix flags (bits 8 to 14, bits 16 to 22) don't use 0x8000, 0x800000
|
||||
#define SUFX_E 0x0100 // e may have been added
|
||||
|
||||
+1
-1
@@ -1156,7 +1156,7 @@ espeak_VOICE *SelectVoice(espeak_VOICE *voice_select, int *variant)
|
||||
espeak_VOICE *voices[N_VOICES_LIST]; // list of candidates
|
||||
espeak_VOICE *voices2[N_VOICES_LIST+N_VOICE_VARIANTS];
|
||||
|
||||
espeak_VOICE voice_variants[N_VOICE_VARIANTS];
|
||||
static espeak_VOICE voice_variants[N_VOICE_VARIANTS];
|
||||
|
||||
if(n_voices_list == 0)
|
||||
espeak_ListVoices(NULL); // create the voices list
|
||||
|
||||
Reference in New Issue
Block a user