Merge branch 'master' into build

This commit is contained in:
Reece Dunn
2011-08-29 11:59:07 +01:00
59 changed files with 2398 additions and 1034 deletions
+14
View File
@@ -26,6 +26,8 @@ LN_SF = /bin/ln -sf
MKDIR = mkdir -p
AUDIO = portaudio
#AUDIO = portaudio0
#AUDIO = portaudio2
#AUDIO = pulseaudio
#AUDIO = sada
@@ -39,6 +41,16 @@ WAVE=wave.cpp
LIB_AUDIO=-lportaudio
USE_AUDIO=-DUSE_PORTAUDIO
else
ifeq ($(AUDIO),portaudio0)
WAVE=wave.cpp
LIB_AUDIO=/usr/lib/libportaudio.so.0
USE_AUDIO=-DUSE_PORTAUDIO
else
ifeq ($(AUDIO),portaudio2)
WAVE=wave.cpp
LIB_AUDIO=/usr/lib/libportaudio.so.2
USE_AUDIO=-DUSE_PORTAUDIO
else
ifeq ($(AUDIO),sada)
WAVE=wave_sada.cpp
USE_AUDIO=-DUSE_SADA
@@ -47,6 +59,8 @@ WAVE=wave.cpp
endif
endif
endif
endif
endif
speak_SOURCES = speak.cpp compiledict.cpp dictionary.cpp intonation.cpp \
readclause.cpp setlengths.cpp numbers.cpp synth_mbrola.cpp \
+1 -1
View File
@@ -350,7 +350,7 @@ static keywtab_t keywords[] = {
{"glstop", tTRANSITION, 8},
{"lenadd", tTRANSITION, 9},
{"f4", tTRANSITION, 10},
{"paus", tTRANSITION, 11},
{"gpaus", tTRANSITION, 11},
{"colr=", tTRANSITION, 12},
{"amp=", tTRANSITION, 13}, // set rms of 1st frame as fraction of rms of 2nd frame (1/30ths)
+14 -3
View File
@@ -617,8 +617,8 @@ void GetTranslatedPhonemeString(char *phon_out, int n_phon_out)
*/
int ix;
int len;
int max_len;
unsigned int len;
unsigned int max_len;
int phon_out_ix=0;
int stress;
unsigned int c;
@@ -2928,7 +2928,7 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
const char *word_end;
const char *word1;
int wflags = 0;
int wflags2;
// int wflags2;
char word_buf[N_WORD_BYTES+1];
if(wtab != NULL)
@@ -3497,6 +3497,17 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
if(end_type & SUFX_E)
{
if(tr->translator_name == L('n','l'))
{
if(((word_end[0] & 0x80) == 0) && ((word_end[-1] & 0x80) == 0) && IsVowel(tr, word_end[-1]) && IsLetter(tr, word_end[0], LETTERGP_C) && !IsVowel(tr, word_end[-2]))
{
//double the vowel before the (ascii) final consonant
word_end[1] = word_end[0];
word_end[0] = word_end[-1];
word_end[2] = ' ';
}
}
else
if(tr->translator_name == L('e','n'))
{
// add 'e' to end of stem
+3 -2
View File
@@ -123,6 +123,7 @@ static void close_pipes(int p1[2], int p2[2], int p3[2])
static int start_mbrola(const char *voice_path)
{
int error, p_stdin[2], p_stdout[2], p_stderr[2];
ssize_t written;
char charbuf[20];
if (mbr_state != MBR_INACTIVE) {
@@ -151,7 +152,7 @@ static int start_mbrola(const char *voice_path)
dup2(p_stderr[1], 2) == -1) {
snprintf(mbr_errorbuf, sizeof(mbr_errorbuf),
"dup2(): %s\n", strerror(errno));
write(p_stderr[1], mbr_errorbuf, strlen(mbr_errorbuf));
written = write(p_stderr[1], mbr_errorbuf, strlen(mbr_errorbuf));
_exit(1);
}
@@ -168,7 +169,7 @@ static int start_mbrola(const char *voice_path)
/* if execution reaches this point then the exec() failed */
snprintf(mbr_errorbuf, sizeof(mbr_errorbuf),
"mbrola: %s\n", strerror(errno));
write(2, mbr_errorbuf, strlen(mbr_errorbuf));
written = write(2, mbr_errorbuf, strlen(mbr_errorbuf));
_exit(1);
}
+2 -2
View File
@@ -1590,13 +1590,13 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
int suffix_ix;
int skipwords = 0;
char *p;
char string[20]; // for looking up entries in **_list
char string[32]; // for looking up entries in **_list
char buf1[100];
char ph_append[50];
char ph_buf[200];
char ph_buf2[50];
char ph_zeros[50];
char suffix[20];
char suffix[30]; // string[] must be long enough for sizeof(suffix)+2
char buf_digit_lookup[50];
static const char str_pause[2] = {phonPAUSE_NOLINK,0};
+4 -2
View File
@@ -190,9 +190,11 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
if(regression & 0x2)
{
// [v] amd [v;] don't cause regression, or [R^]
if((ph->mnemonic == 'v') || (ph->mnemonic == ((';'<<8)+'v')) || ((ph->mnemonic & 0xff)== 'R'))
if(((ph->mnemonic & 0xff) == 'v') || ((ph->mnemonic & 0xff)== 'R'))
{
stop_propagation = 1;
if(regression & 0x10)
voicing = 0;
}
}
@@ -247,7 +249,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
// stop propagation at a word boundary
voicing = 0;
}
if(regression & 0x10)
if(regression & 0x100)
{
// devoice word-final consonants, unless propagating voiced
if(voicing == 0)
+46 -12
View File
@@ -164,7 +164,7 @@ static const unsigned int punct_attributes [] = { 0,
// frame 0 is for the defaults, before any ssml tags.
typedef struct {
int tag_type;
int voice_variant;
int voice_variant_number;
int voice_gender;
int voice_age;
char voice_name[40];
@@ -175,6 +175,8 @@ typedef struct {
static int n_ssml_stack;
static SSML_STACK ssml_stack[N_SSML_STACK];
static espeak_VOICE base_voice;
static char base_voice_variant_name[40] = {0};
static char current_voice_id[40] = {0};
@@ -1037,19 +1039,21 @@ static const char *VoiceFromStack()
// Use the voice properties from the SSML stack to choose a voice, and switch
// to that voice if it's not the current voice
int ix;
const char *p;
SSML_STACK *sp;
const char *v_id;
int voice_name_specified;
int voice_found;
espeak_VOICE voice_select;
char voice_name[40];
static char voice_name[40];
char language[40];
char buf[80];
strcpy(voice_name,ssml_stack[0].voice_name);
strcpy(language,ssml_stack[0].language);
voice_select.age = ssml_stack[0].voice_age;
voice_select.gender = ssml_stack[0].voice_gender;
voice_select.variant = ssml_stack[0].voice_variant;
voice_select.variant = ssml_stack[0].voice_variant_number;
voice_select.identifier = NULL;
for(ix=0; ix<n_ssml_stack; ix++)
@@ -1069,15 +1073,32 @@ static const char *VoiceFromStack()
if(sp->language[0] != 0)
{
strcpy(language, sp->language);
// is this language provided by the base voice?
p = base_voice.languages;
while(*p++ != 0)
{
if(strcmp(p, language) == 0)
{
// yes, change the language to the main language of the base voice
strcpy(language, &base_voice.languages[1]);
break;
}
p += (strlen(p) + 1);
}
if(voice_name_specified == 0)
voice_name[0] = 0; // forget a previous voice name if a language is specified
}
if(sp->voice_gender != 0)
{
voice_select.gender = sp->voice_gender;
}
if(sp->voice_age != 0)
voice_select.age = sp->voice_age;
if(sp->voice_variant != 0)
voice_select.variant = sp->voice_variant;
if(sp->voice_variant_number != 0)
voice_select.variant = sp->voice_variant_number;
}
voice_select.name = voice_name;
@@ -1085,6 +1106,14 @@ static const char *VoiceFromStack()
v_id = SelectVoice(&voice_select, &voice_found);
if(v_id == NULL)
return("default");
if((strchr(v_id, '+') == NULL) && ((voice_select.gender == 0) || (voice_select.gender == base_voice.gender)) && (base_voice_variant_name[0] != 0))
{
// a voice variant has not been selected, use the original voice variant
sprintf(buf, "%s+%s", v_id, base_voice_variant_name);
strncpy0(voice_name, buf, sizeof(voice_name));
return(voice_name);
}
return(v_id);
} // end of VoiceFromStack
@@ -1389,8 +1418,8 @@ int AddNameData(const char *name, int wide)
} // end of AddNameData
void SetVoiceStack(espeak_VOICE *v)
{//================================
void SetVoiceStack(espeak_VOICE *v, const char *variant_name)
{//==========================================================
SSML_STACK *sp;
sp = &ssml_stack[0];
@@ -1402,10 +1431,12 @@ void SetVoiceStack(espeak_VOICE *v)
if(v->languages != NULL)
strcpy(sp->language,v->languages);
if(v->name != NULL)
strcpy(sp->voice_name,v->name);
sp->voice_variant = v->variant;
strncpy0(sp->voice_name, v->name, sizeof(sp->voice_name));
sp->voice_variant_number = v->variant;
sp->voice_age = v->age;
sp->voice_gender = v->gender;
strncpy0(base_voice_variant_name, variant_name, sizeof(base_voice_variant_name));
memcpy(&base_voice, &current_voice_selected, sizeof(base_voice));
}
@@ -1467,7 +1498,7 @@ static int GetVoiceAttributes(wchar_t *pw, int tag_type)
attrcopy_utf8(ssml_sp->language,lang,sizeof(ssml_sp->language));
attrcopy_utf8(ssml_sp->voice_name,name,sizeof(ssml_sp->voice_name));
ssml_sp->voice_variant = attrnumber(variant,1,0)-1;
ssml_sp->voice_variant_number = attrnumber(variant,1,0)-1;
ssml_sp->voice_age = attrnumber(age,0,0);
ssml_sp->voice_gender = attrlookup(gender,mnem_gender);
ssml_sp->tag_type = tag_type;
@@ -1647,6 +1678,7 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int &outix, int n_outb
{"reduced",2},
{"moderate",3},
{"strong",4},
{"x-strong",5},
{NULL,-1}};
static const char *prosody_attr[5] = {
@@ -1735,14 +1767,16 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int &outix, int n_outb
if(translator->langopts.tone_language == 1)
{
static unsigned char emphasis_to_pitch_range[] = {50,50,40,70,90,90};
static unsigned char emphasis_to_volume[] = {100,100,70,110,140,140};
static unsigned char emphasis_to_pitch_range[] = {50,50,40,70,90,100};
static unsigned char emphasis_to_volume[] = {100,100,70,110,135,150};
// tone language (eg.Chinese) do emphasis by increasing the pitch range.
sp->parameter[espeakRANGE] = emphasis_to_pitch_range[value];
sp->parameter[espeakVOLUME] = emphasis_to_volume[value];
}
else
{
static unsigned char emphasis_to_volume2[] = {100,100,75,100,120,150};
sp->parameter[espeakVOLUME] = emphasis_to_volume2[value];
sp->parameter[espeakEMPHASIS] = value;
}
ProcessParamStack(outbuf, outix);
+1 -1
View File
@@ -428,7 +428,7 @@ static int initialise(void)
fprintf(stderr,"Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n",result,version_phdata,path_home);
}
LoadConfig();
SetVoiceStack(NULL);
SetVoiceStack(NULL, "");
SynthesizeInit();
for(param=0; param<N_SPEECH_PARAM; param++)
+2 -3
View File
@@ -47,7 +47,6 @@
#include "wave.h"
unsigned char *outbuf=NULL;
extern espeak_VOICE voice_selected;
espeak_EVENT *event_list=NULL;
int event_list_ix=0;
@@ -391,8 +390,8 @@ static int initialise(int control)
fprintf(stderr,"Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n",result,version_phdata,path_home);
}
memset(&voice_selected,0,sizeof(voice_selected));
SetVoiceStack(NULL);
memset(&current_voice_selected,0,sizeof(current_voice_selected));
SetVoiceStack(NULL, "");
SynthesizeInit();
InitNamedata();
+2 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.45.31 25.Jun.11";
const char *version_string = "1.45.40 23.Aug.11";
const int version_phdata = 0x014500;
int option_device_number = -1;
@@ -512,6 +512,7 @@ void LoadConfig(void)
}
}
}
fclose(f);
} // end of LoadConfig
+1 -1
View File
@@ -762,7 +762,7 @@ if(voice->klattv[0])
}
if(flags & 0x40)
DoPause(12,0); // add a short pause after the consonant
DoPause(20,0); // add a short pause after the consonant
if(flags & 16)
return(len);
+15 -6
View File
@@ -342,7 +342,7 @@ Translator *SelectTranslator(const char *name)
static const short stress_lengths_fr[8] = {190, 170, 190, 200, 0, 0, 190, 240};
static const unsigned char stress_amps_fr[8] = {18,16, 18,18, 18,18, 18,18 };
static const unsigned char stress_amps_sk[8] = {17,17, 20,20, 20,22, 22,21 };
static const unsigned char stress_amps_sk[8] = {17,16, 20,20, 20,22, 22,21 };
static const short stress_lengths_sk[8] = {190,190, 210,210, 0,0, 210,210};
static const short stress_lengths_ta[8] = {200, 200, 210, 210, 0, 0, 230, 230};
@@ -379,6 +379,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.stress_flags = 0x0024; // don't use secondary stress
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
}
break;
@@ -394,7 +395,7 @@ Translator *SelectTranslator(const char *name)
SetCyrillicLetters(tr);
SetLetterVowel(tr,0x2a);
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x17; // devoice at end of word, and change voicing to match a following consonant (except v)
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x107; // devoice at end of word, and change voicing to match a following consonant (except v)
tr->langopts.param[LOPT_REDUCE] = 2;
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_SINGLE_AND | NUM_ROMAN | NUM_ROMAN_ORDINAL | NUM_ROMAN_CAPITALS ;
@@ -468,7 +469,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.word_gap = 0x8; // don't use linking phonemes
tr->langopts.vowel_pause = 0x30;
tr->langopts.param[LOPT_PREFIXES] = 1;
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x10; // devoice at end of word
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
tr->langopts.param[LOPT_LONG_VOWEL_THRESHOLD] = 175/2;
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_ALLOW_SPACE | NUM_ORDINAL_DOT | NUM_ROMAN;
@@ -954,6 +955,14 @@ SetLengthMods(tr,3); // all equal
}
break;
case L('m','t'): // Maltese
{
tr->charset_a0 = charsets[3]; // ISO-8859-3
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
tr->langopts.stress_rule = STRESSPOSN_2R; // penultimate
tr->langopts.numbers = 1;
}
break;
case L('n','l'): // Dutch
{
@@ -963,7 +972,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.vowel_pause = 0x30; // ??
tr->langopts.param[LOPT_DIERESES] = 1;
tr->langopts.param[LOPT_PREFIXES] = 1;
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x10; // devoice at end of word
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
SetLetterVowel(tr,'y');
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ALLOW_SPACE | NUM_1900 | NUM_ORDINAL_DOT;
@@ -1005,7 +1014,7 @@ SetLengthMods(tr,3); // all equal
tr->charset_a0 = charsets[2]; // ISO-8859-2
tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x8;
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x9;
tr->langopts.max_initial_consonants = 7; // for example: wchrzczony :)
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_2;
tr->langopts.numbers2 = 0x40;
@@ -1123,7 +1132,7 @@ SetLengthMods(tr,3); // all equal
tr->charset_a0 = charsets[2]; // ISO-8859-2
tr->langopts.stress_rule = STRESSPOSN_2R; // Temporary
tr->langopts.stress_flags = 0x20;
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x13;
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x103;
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2 | NUM_ORDINAL_DOT | NUM_ROMAN;
tr->langopts.numbers2 = 0x100; // plural forms of millions etc
tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
+41 -27
View File
@@ -1563,6 +1563,39 @@ static int CountSyllables(unsigned char *phonemes)
}
void Word_EmbeddedCmd()
{//====================
// Process embedded commands for emphasis, sayas, and break
int embedded_cmd;
int value;
do
{
embedded_cmd = embedded_list[embedded_read++];
value = embedded_cmd >> 8;
switch(embedded_cmd & 0x1f)
{
case EMBED_Y:
option_sayas = value;
break;
case EMBED_F:
option_emphasis = value;
break;
case EMBED_B:
// break command
if(value == 0)
pre_pause = 0; // break=none
else
pre_pause += value;
break;
}
} while(((embedded_cmd & 0x80) == 0) && (embedded_read < embedded_ix));
} // end of Word_EmbeddedCmd
int SetTranslator2(const char *new_language)
{//=========================================
// Set translator2 to a second language
@@ -1603,8 +1636,6 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
int next_tone=0;
unsigned char *p;
int srcix;
int embedded_cmd;
int value;
int found_dict_flag;
unsigned char ph_code;
PHONEME_LIST2 *plist2;
@@ -1646,30 +1677,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
{
embedded_flag = SFLAG_EMBEDDED;
do
{
embedded_cmd = embedded_list[embedded_read++];
value = embedded_cmd >> 8;
switch(embedded_cmd & 0x1f)
{
case EMBED_Y:
option_sayas = value;
break;
case EMBED_F:
option_emphasis = value;
break;
case EMBED_B:
// break command
if(value == 0)
pre_pause = 0; // break=none
else
pre_pause += value;
break;
}
} while((embedded_cmd & 0x80) == 0);
Word_EmbeddedCmd();
}
if((word[0] == 0) || (word_flags & FLAG_DELETE_WORD))
@@ -3208,7 +3216,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
}
}
if((dict_flags & (FLAG_ALLOW_DOT | FLAG_NEEDS_DOT)) && (ix == word_count-1) && (terminator & CLAUSE_DOT))
if((dict_flags & (FLAG_ALLOW_DOT | FLAG_NEEDS_DOT)) && (ix == word_count - 1 - dictionary_skipwords) && (terminator & CLAUSE_DOT))
{
// probably an abbreviation such as Mr. or B. rather than end of sentence
clause_pause = 10;
@@ -3227,6 +3235,12 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
}
}
if(embedded_read < embedded_ix)
{
// any embedded commands not yet processed?
Word_EmbeddedCmd();
}
for(ix=0; ix<2; ix++)
{
// terminate the clause with 2 PAUSE phonemes
+4 -2
View File
@@ -266,10 +266,12 @@ extern const int param_defaults[N_SPEECH_PARAM];
#define LOPT_PREFIXES 3
// non-zero, change voiced/unoiced to match last consonant in a cluster
// bit 0=use regressive voicing
// bit 1=LANG=cz,bg don't propagate over [v]
// bit 2=don't propagate acress word boundaries
// bit 3=LANG=pl, propagate over liquids and nasals
// bit 4=devoice word-final consonants
// bit 4=LANG=cz,sk don't progagate to [v]
// bit 8=devoice word-final consonants
#define LOPT_REGRESSIVE_VOICING 4
// 0=default, 1=no check, other allow this character as an extra initial letter (default is 's')
@@ -666,7 +668,7 @@ int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab);
void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *tone, char **voice_change);
int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type, char *voice_change);
void SetVoiceStack(espeak_VOICE *v);
void SetVoiceStack(espeak_VOICE *v, const char *variant_name);
void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_DATA *phdata);
void InterpretPhoneme2(int phcode, PHONEME_DATA *phdata);
+1
View File
@@ -69,6 +69,7 @@ typedef struct {
// percentages shown to user, ix=N_PEAKS means ALL peaks
extern USHORT voice_pcnt[N_PEAKS+1][3];
extern espeak_VOICE current_voice_selected;
extern voice_t *voice;
extern int tone_points[12];
+49 -35
View File
@@ -66,7 +66,7 @@ static int n_voices_list = 0;
static espeak_VOICE *voices_list[N_VOICES_LIST];
static int len_path_voices;
espeak_VOICE voice_selected;
espeak_VOICE current_voice_selected;
enum {
@@ -564,9 +564,9 @@ voice_t *LoadVoice(const char *vname, int control)
int pitch1;
int pitch2;
static char voice_identifier[40]; // file name for voice_selected
static char voice_name[40]; // voice name for voice_selected
static char voice_languages[100]; // list of languages and priorities for voice_selected
static char voice_identifier[40]; // file name for current_voice_selected
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
strcpy(voicename,vname);
if(voicename[0]==0)
@@ -635,9 +635,9 @@ voice_t *LoadVoice(const char *vname, int control)
voice_name[0] = 0;
voice_languages[0] = 0;
voice_selected.identifier = voice_identifier;
voice_selected.name = voice_name;
voice_selected.languages = voice_languages;
current_voice_selected.identifier = voice_identifier;
current_voice_selected.name = voice_name;
current_voice_selected.languages = voice_languages;
}
else
{
@@ -720,11 +720,11 @@ voice_t *LoadVoice(const char *vname, int control)
case V_GENDER:
{
int age;
int age = 0;
char vgender[80];
sscanf(p,"%s %d",vgender,&age);
voice_selected.gender = LookupMnem(genders,vgender);
voice_selected.age = age;
current_voice_selected.gender = LookupMnem(genders,vgender);
current_voice_selected.age = age;
}
break;
@@ -1029,23 +1029,26 @@ voice_t *LoadVoice(const char *vname, int control)
} // end of LoadVoice
static char *ExtractVoiceVariantName(char *vname, int variant_num)
{//===============================================================
static char *ExtractVoiceVariantName(char *vname, int variant_num, int add_dir)
{//===========================================================================
// Remove any voice variant suffix (name or number) from a voice name
// Returns the voice variant name
char *p;
static char variant_name[20];
static char variant_name[40];
char variant_prefix[5];
variant_name[0] = 0;
sprintf(variant_prefix,"!v%c",PATHSEP);
if(add_dir == 0)
variant_prefix[0] = 0;
if(vname != NULL)
{
if((p = strchr(vname,'+')) != NULL)
{
// The voice name has a +variant suffix
variant_num = 0;
*p++ = 0; // delete the suffix from the voice name
if(isdigit(*p))
{
@@ -1054,8 +1057,7 @@ static char *ExtractVoiceVariantName(char *vname, int variant_num)
else
{
// voice variant name, not number
strcpy(variant_name,variant_prefix);
strncpy0(&variant_name[3],p,sizeof(variant_name)-3);
sprintf(variant_name, "%s%s", variant_prefix, p);
}
}
}
@@ -1083,7 +1085,7 @@ voice_t *LoadVoiceVariant(const char *vname, int variant_num)
char buf[60];
strncpy0(buf,vname,sizeof(buf));
variant_name = ExtractVoiceVariantName(buf,variant_num);
variant_name = ExtractVoiceVariantName(buf,variant_num, 1);
if((v = LoadVoice(buf,0)) == NULL)
return(NULL);
@@ -1319,15 +1321,17 @@ static int SetVoiceScores(espeak_VOICE *voice_select, espeak_VOICE **voices, int
espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name)
{//=====================================================================
espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name2)
{//======================================================================
int ix;
int match_fname = -1;
int match_fname2 = -1;
int match_name = -1;
const char *id;
const char *id; // this is the filename within espeak-data/voices
char *variant_name;
int last_part_len;
char last_part[41];
char name[40];
if(voices == NULL)
{
@@ -1336,6 +1340,13 @@ espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name)
voices = voices_list;
}
strncpy0(name, name2, sizeof(name));
if((variant_name = strchr(name, '+')) != NULL)
{
*variant_name = 0;
variant_name++;
}
sprintf(last_part,"%c%s",PATHSEP,name);
last_part_len = strlen(last_part);
@@ -1347,14 +1358,17 @@ espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name)
break;
}
else
if(strcmp(name,id = voices[ix]->identifier)==0)
{
match_fname = ix; // matching identifier, use this if no matching name
}
else
if(strcmp(last_part,&id[strlen(id)-last_part_len])==0)
{
match_fname2 = ix;
id = voices[ix]->identifier;
if(strcmp(name, id)==0)
{
match_fname = ix; // matching identifier, use this if no matching name
}
else
if(strcmp(last_part,&id[strlen(id)-last_part_len])==0)
{
match_fname2 = ix;
}
}
}
@@ -1414,7 +1428,7 @@ char const *SelectVoice(espeak_VOICE *voice_select, int *found)
}
strncpy0(buf,voice_select2.name,sizeof(buf));
variant_name = ExtractVoiceVariantName(buf,0);
variant_name = ExtractVoiceVariantName(buf,0,0);
vp = SelectVoiceByName(voices_list,buf);
if(vp != NULL)
@@ -1425,7 +1439,7 @@ char const *SelectVoice(espeak_VOICE *voice_select, int *found)
{
if(variant_name[0] != 0)
{
sprintf(voice_id,"%s+%s",vp->identifier,&variant_name[3]); // omit the !v/ from variant_name
sprintf(voice_id,"%s+%s", vp->identifier, variant_name);
return(voice_id);
}
@@ -1512,8 +1526,8 @@ char const *SelectVoice(espeak_VOICE *voice_select, int *found)
if(vp->variant != 0)
{
variant_name = ExtractVoiceVariantName(NULL,vp->variant);
sprintf(voice_id,"%s+%s",vp->identifier,&variant_name[3]);
variant_name = ExtractVoiceVariantName(NULL, vp->variant, 0);
sprintf(voice_id,"%s+%s", vp->identifier, variant_name);
return(voice_id);
}
@@ -1671,7 +1685,7 @@ espeak_ERROR SetVoiceByName(const char *name)
static char buf[60];
strncpy0(buf,name,sizeof(buf));
variant_name = ExtractVoiceVariantName(buf,0);
variant_name = ExtractVoiceVariantName(buf, 0, 1);
memset(&voice_selector,0,sizeof(voice_selector));
// voice_selector.name = buf;
@@ -1688,7 +1702,7 @@ espeak_ERROR SetVoiceByName(const char *name)
}
DoVoiceChange(voice);
SetVoiceStack(&voice_selector);
SetVoiceStack(&voice_selector, variant_name);
return(EE_OK);
}
@@ -1704,7 +1718,7 @@ espeak_ERROR SetVoiceByName(const char *name)
LoadVoice(variant_name,2);
}
DoVoiceChange(voice);
SetVoiceStack(&voice_selector);
SetVoiceStack(&voice_selector, variant_name);
return(EE_OK);
}
}
@@ -1725,7 +1739,7 @@ espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector)
LoadVoiceVariant(voice_id,0);
DoVoiceChange(voice);
SetVoiceStack(voice_selector);
SetVoiceStack(voice_selector, "");
return(EE_OK);
} // end of SetVoiceByProperties
@@ -1795,7 +1809,7 @@ ESPEAK_API const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec)
ESPEAK_API espeak_VOICE *espeak_GetCurrentVoice(void)
{//==================================================
return(&voice_selected);
return(&current_voice_selected);
}
#pragma GCC visibility pop