mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-04 22:38:33 +00:00
[1.47.03]
git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@329 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
+8
-5
@@ -2694,7 +2694,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
{
|
||||
if(tr->langopts.alt_alphabet == alphabet->offset)
|
||||
{
|
||||
sprintf(phonemes,"%c%s",phonSWITCH, tr->langopts.alt_alphabet_lang);
|
||||
sprintf(phonemes,"%c%s",phonSWITCH, WordToString2(tr->langopts.alt_alphabet_lang));
|
||||
return(0);
|
||||
}
|
||||
if(alphabet->flags & AL_WORDS)
|
||||
@@ -2984,6 +2984,7 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
|
||||
const char *word_end;
|
||||
const char *word1;
|
||||
int wflags = 0;
|
||||
int lookup_symbol;
|
||||
char word_buf[N_WORD_BYTES+1];
|
||||
char dict_flags_buf[80];
|
||||
|
||||
@@ -2992,6 +2993,7 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
|
||||
wflags = wtab->flags;
|
||||
}
|
||||
|
||||
lookup_symbol = flags[1] & FLAG_LOOKUP_SYMBOL;
|
||||
word1 = word;
|
||||
if(tr->transpose_min > 0)
|
||||
{
|
||||
@@ -3178,9 +3180,9 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
|
||||
continue;
|
||||
}
|
||||
|
||||
if((dictionary_flags2 & FLAG_ATEND) && (word_end < translator->clause_end))
|
||||
if((dictionary_flags2 & FLAG_ATEND) && (word_end < translator->clause_end) && (lookup_symbol==0))
|
||||
{
|
||||
// only use this pronunciation if it's the last word of the clause
|
||||
// only use this pronunciation if it's the last word of the clause, or called from Lookup()
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3192,7 +3194,7 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
|
||||
|
||||
if((dictionary_flags2 & FLAG_SENTENCE) && !(translator->clause_terminator & CLAUSE_BIT_SENTENCE))
|
||||
{
|
||||
// only uis this clause is a sentence , i.e. terminator is {. ? !} not {, : :}
|
||||
// only if this clause is a sentence , i.e. terminator is {. ? !} not {, : :}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3471,7 +3473,8 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
|
||||
int Lookup(Translator *tr, const char *word, char *ph_out)
|
||||
{//===================================================
|
||||
unsigned int flags[2];
|
||||
flags[0] = flags[1] = 0;
|
||||
flags[0] = 0;
|
||||
flags[1] = FLAG_LOOKUP_SYMBOL;
|
||||
char *word1 = (char *)word;
|
||||
return(LookupDictList(tr, &word1, ph_out, flags, 0, NULL));
|
||||
}
|
||||
|
||||
+4
-1
@@ -691,6 +691,9 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
|
||||
if(ph_buf[0] == 0)
|
||||
{
|
||||
if(al_offset == translator->langopts.alt_alphabet)
|
||||
language = translator->langopts.alt_alphabet_lang;
|
||||
else
|
||||
if((alphabet != NULL) && (alphabet->language != 0) && !(al_flags & AL_NOT_LETTERS))
|
||||
language = alphabet->language;
|
||||
else
|
||||
@@ -793,7 +796,7 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
|
||||
len = strlen(phonemes);
|
||||
|
||||
if(tr->langopts.accents & 2)
|
||||
if(tr->langopts.accents & 2) // 'capital' before or after the word ?
|
||||
sprintf(ph_buf2,"%c%s%s%s",0xff,ph_alphabet,ph_buf,capital);
|
||||
else
|
||||
sprintf(ph_buf2,"%c%s%s%s",0xff,ph_alphabet,capital,ph_buf); // the 0xff marker will be removed or replaced in SetSpellingStress()
|
||||
|
||||
+13
-16
@@ -750,11 +750,22 @@ int main (int argc, char **argv)
|
||||
init_path(argv[0],data_path);
|
||||
initialise();
|
||||
|
||||
if(voicename[0] == 0)
|
||||
strcpy(voicename,"default");
|
||||
|
||||
if(SetVoiceByName(voicename) != EE_OK)
|
||||
{
|
||||
memset(&voice_select,0,sizeof(voice_select));
|
||||
voice_select.languages = voicename;
|
||||
if(SetVoiceByProperties(&voice_select) != EE_OK)
|
||||
{
|
||||
fprintf(stderr,"%svoice '%s'\n",err_load,voicename);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
if(flag_compile)
|
||||
{
|
||||
LoadVoice(voicename,5);
|
||||
|
||||
#ifdef PLATFORM_DOS
|
||||
char path_dsource[sizeof(path_home)+20];
|
||||
strcpy(path_dsource,path_home);
|
||||
@@ -776,20 +787,6 @@ int main (int argc, char **argv)
|
||||
}
|
||||
|
||||
|
||||
if(voicename[0] == 0)
|
||||
strcpy(voicename,"default");
|
||||
|
||||
if(SetVoiceByName(voicename) != EE_OK)
|
||||
{
|
||||
memset(&voice_select,0,sizeof(voice_select));
|
||||
voice_select.languages = voicename;
|
||||
if(SetVoiceByProperties(&voice_select) != EE_OK)
|
||||
{
|
||||
fprintf(stderr,"%svoice '%s'\n",err_load,voicename);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
SetParameter(espeakRATE,speed,0);
|
||||
SetParameter(espeakVOLUME,amp,0);
|
||||
SetParameter(espeakCAPITALS,option_capitals,0);
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@
|
||||
#include "translate.h"
|
||||
#include "wave.h"
|
||||
|
||||
const char *version_string = "1.47.02 19.Mar.13";
|
||||
const char *version_string = "1.47.03 21.Mar.13";
|
||||
const int version_phdata = 0x014701;
|
||||
|
||||
int option_device_number = -1;
|
||||
|
||||
+16
-2
@@ -103,6 +103,19 @@ ALPHABET alphabets [] = {
|
||||
};
|
||||
|
||||
|
||||
ALPHABET *AlphabetFromName(const char *name)
|
||||
{//==========================================
|
||||
ALPHABET *alphabet;
|
||||
|
||||
for(alphabet=alphabets; alphabet->name != NULL; alphabet++)
|
||||
{
|
||||
if(strcmp(name, &alphabet->name[1]) == 0)
|
||||
return(alphabet);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
ALPHABET *AlphabetFromChar(int c)
|
||||
{//===============================
|
||||
// Find the alphabet from a character.
|
||||
@@ -276,7 +289,7 @@ static const char transpose_map_latin[] = {
|
||||
tr->langopts.param2[LOPT_BRACKET_PAUSE] = 2; // pauses when announcing bracket names
|
||||
tr->langopts.max_initial_consonants = 3;
|
||||
tr->langopts.replace_chars = NULL;
|
||||
tr->langopts.ascii_language = ""; // Non-Latin alphabet languages, use this language to speak Latin words, default is English
|
||||
tr->langopts.ascii_language[0] = 0; // Non-Latin alphabet languages, use this language to speak Latin words, default is English
|
||||
|
||||
|
||||
SetLengthMods(tr,201);
|
||||
@@ -828,6 +841,7 @@ Translator *SelectTranslator(const char *name)
|
||||
{
|
||||
tr->langopts.stress_rule = STRESSPOSN_1L;
|
||||
tr->langopts.numbers = 1;
|
||||
tr->langopts.accents = 2; // 'capital' after letter name
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1054,7 +1068,7 @@ SetLengthMods(tr,3); // all equal
|
||||
tr->langopts.numbers = NUM_VIGESIMAL | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED |NUM_OMIT_1_THOUSAND | NUM_DFRACTION_5 | NUM_ROMAN;
|
||||
|
||||
tr->langopts.alt_alphabet = OFFSET_CYRILLIC;
|
||||
tr->langopts.alt_alphabet_lang = "ru";
|
||||
tr->langopts.alt_alphabet_lang = L('r','u');
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
+4
-2
@@ -83,6 +83,7 @@
|
||||
#define FLAG_STEM 0x10000 // must have a suffix
|
||||
#define FLAG_ATEND 0x20000 /* use this pronunciation if at end of clause */
|
||||
#define FLAG_ATSTART 0x40000 // use this pronunciation if at start of clause
|
||||
#define FLAG_LOOKUP_SYMBOL 0x40000000 // to indicate called from Lookup()
|
||||
|
||||
#define BITNUM_FLAG_ALLCAPS 0x2a
|
||||
#define BITNUM_FLAG_HYPHENATED 0x2c
|
||||
@@ -542,9 +543,9 @@ typedef struct {
|
||||
int testing; // testing options: bit 1= specify stressed syllable in the form: "outdoor/2"
|
||||
int listx; // compile *_listx after *list
|
||||
const unsigned int *replace_chars; // characters to be substitutes
|
||||
const char *ascii_language; // switch to this language for Latin characters
|
||||
char ascii_language[8]; // switch to this language for Latin characters
|
||||
int alt_alphabet; // offset for another language to recognize
|
||||
const char *alt_alphabet_lang; // language for the alt_alphabet
|
||||
int alt_alphabet_lang; // language for the alt_alphabet
|
||||
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
|
||||
@@ -713,6 +714,7 @@ int towlower2(unsigned int c);
|
||||
void GetTranslatedPhonemeString(char *phon_out, int n_phon_out, int use_ipa);
|
||||
const char *WordToString2(unsigned int word);
|
||||
ALPHABET *AlphabetFromChar(int c);
|
||||
ALPHABET *AlphabetFromName(const char *name);
|
||||
|
||||
Translator *SelectTranslator(const char *name);
|
||||
int SetTranslator2(const char *name);
|
||||
|
||||
+45
-7
@@ -109,6 +109,7 @@ enum {
|
||||
V_FAST,
|
||||
V_SPEED,
|
||||
V_DICTMIN,
|
||||
V_ALPHABET2,
|
||||
|
||||
// these need a phoneme table to have been specified
|
||||
V_REPLACE,
|
||||
@@ -160,6 +161,7 @@ static MNEM_TAB keyword_tab[] = {
|
||||
{"fast_test2", V_FAST},
|
||||
{"speed", V_SPEED},
|
||||
{"dict_min", V_DICTMIN},
|
||||
{"alphabet2", V_ALPHABET2},
|
||||
|
||||
// these just set a value in langopts.param[]
|
||||
{"l_dieresis", 0x100+LOPT_DIERESES},
|
||||
@@ -530,6 +532,21 @@ static int Read8Numbers(char *data_in,int *data)
|
||||
}
|
||||
|
||||
|
||||
static unsigned int StringToWord2(const char *string)
|
||||
{//======================================================
|
||||
// Convert a language name string to a word such as L('e','n')
|
||||
int ix;
|
||||
int c;
|
||||
unsigned int value = 0;
|
||||
|
||||
for(ix=0; (ix<4) & ((c = string[ix]) != 0); ix++)
|
||||
{
|
||||
value = (value << 8) | (c & 0xff);
|
||||
}
|
||||
return(value);
|
||||
}
|
||||
|
||||
|
||||
voice_t *LoadVoice(const char *vname, int control)
|
||||
{//===============================================
|
||||
// control, bit 0 1= no_default
|
||||
@@ -571,6 +588,7 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
int stress_lengths[8];
|
||||
int stress_add[8];
|
||||
char names[8][40];
|
||||
char name1[40];
|
||||
char name2[80];
|
||||
const char *voice_dir;
|
||||
|
||||
@@ -581,11 +599,11 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
static char voice_name[40]; // voice name for current_voice_selected
|
||||
static char voice_languages[100]; // list of languages and priorities for current_voice_selected
|
||||
|
||||
// which directory to look for a named voice
|
||||
// which directory to look for a named voice. List of voice names, must end in a space.
|
||||
static const char *voices_asia =
|
||||
"fa fa-pin hi hy hy-west id ka kn ku ml ne pa ta tr vi vi-hue zh zh-yue ";
|
||||
static const char *voices_europe =
|
||||
"an bg bs ca cs cy da el es et fi fr-be hr hu is it lt lv mk nl no pl pt-pt ro ru sk sq sr sv ";
|
||||
"an bg bs ca cs cy da el es et fi fr-be ga hr hu is it lt lv mk nl no pl pt-pt ro ru sk sq sr sv ";
|
||||
|
||||
|
||||
strncpy0(voicename, vname, sizeof(voicename));
|
||||
@@ -960,12 +978,10 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
case V_MBROLA:
|
||||
{
|
||||
int srate = 16000;
|
||||
char name[40];
|
||||
char phtrans[40];
|
||||
|
||||
phtrans[0] = 0;
|
||||
sscanf(p,"%s %s %d",name,phtrans,&srate);
|
||||
if(LoadMbrolaTable(name,phtrans,srate) != EE_OK)
|
||||
name2[0] = 0;
|
||||
sscanf(p,"%s %s %d",name1,name2,&srate);
|
||||
if(LoadMbrolaTable(name1,name2,srate) != EE_OK)
|
||||
{
|
||||
fprintf(stderr,"mbrola voice not found\n");
|
||||
}
|
||||
@@ -988,6 +1004,28 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
sscanf(p,"%d",&dict_min);
|
||||
break;
|
||||
|
||||
case V_ALPHABET2:
|
||||
{
|
||||
ALPHABET *alphabet;
|
||||
name1[0] = name2[0] = 0;
|
||||
sscanf(p, "%s %s", name1, name2);
|
||||
|
||||
if(strcmp(name1, "latin") == 0)
|
||||
{
|
||||
strncpy0(langopts->ascii_language,name2,sizeof(langopts->ascii_language));
|
||||
}
|
||||
else if((alphabet = AlphabetFromName(name1)) != 0)
|
||||
{
|
||||
langopts->alt_alphabet = alphabet->offset;
|
||||
langopts->alt_alphabet_lang = StringToWord2(name2);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"alphabet name '%s' not found\n", name1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if((key & 0xff00) == 0x100)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user