mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-21 11:31:00 +00:00
Merge branch 'master' into build
This commit is contained in:
+16
-3
@@ -536,6 +536,13 @@ static void WritePhMnemonic(char **buf, PHONEME_TAB *ph, PHONEME_LIST *plist)
|
||||
|
||||
phon_out = *buf;
|
||||
|
||||
if(ph->code == phonEND_WORD)
|
||||
{
|
||||
// ignore
|
||||
phon_out[0] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if(option_phonemes == 3)
|
||||
{
|
||||
// has an ipa name been defined for this phoneme ?
|
||||
@@ -2920,6 +2927,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;
|
||||
char word_buf[N_WORD_BYTES+1];
|
||||
|
||||
if(wtab != NULL)
|
||||
@@ -3014,11 +3022,16 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
|
||||
skipwords = flag - 80;
|
||||
|
||||
// don't use the contraction if any of the words are emphasized
|
||||
for(ix=0; ix <= skipwords; ix++)
|
||||
// or has an embedded command, such as MARK
|
||||
if(wtab != NULL)
|
||||
{
|
||||
if(wflags & FLAG_EMPHASIZED2)
|
||||
for(ix=0; ix <= skipwords; ix++)
|
||||
{
|
||||
condition_failed = 1;
|
||||
if(wtab[ix].flags & FLAG_EMPHASIZED2)
|
||||
// if(((wflags2 = wtab[ix].flags) & FLAG_EMPHASIZED2) || ((ix > 0) && (wflags2 & FLAG_EMBEDDED)))
|
||||
{
|
||||
condition_failed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -47,9 +47,7 @@
|
||||
#define phVOWEL2 0x100 // liquid that is considered a vowel
|
||||
#define phPALATAL 0x200
|
||||
#define phSINGLE_INSTN 0x1000 // this phoneme has a single instruction program, with an implicit Return
|
||||
#define phAPPENDPH 0x2000 // always insert another phoneme (link_out) after this one
|
||||
#define phBRKAFTER 0x4000 // [*] add a post-pause
|
||||
#define phBEFOREPAUSE 0x8000 // replace with the link_out phoneme if the next phoneme is a pause
|
||||
|
||||
#define phNONSYLLABIC 0x100000 // don't count this vowel as a syllable when finding the stress position
|
||||
#define phLONG 0x200000
|
||||
@@ -106,14 +104,14 @@ extern const unsigned char pause_phonemes[8]; // 0, vshort, short, pause, long,
|
||||
// main table of phonemes, index by phoneme number (1-254)
|
||||
|
||||
typedef struct {
|
||||
unsigned int mnemonic; // 1st char is in the l.s.byte
|
||||
unsigned int mnemonic; // Up to 4 characters. The first char is in the l.s.byte
|
||||
unsigned int phflags; // bits 16-19 place of articulation
|
||||
unsigned short program;
|
||||
unsigned short program; // index into phondata file
|
||||
unsigned char code; // the phoneme number
|
||||
unsigned char type; // phVOWEL, phPAUSE, phSTOP etc
|
||||
unsigned char start_type;
|
||||
unsigned char end_type;
|
||||
unsigned char std_length; // for vowels, in mS/2; for phSTRESS, the stress/tone type
|
||||
unsigned char std_length; // for vowels, in mS/2; for phSTRESS phonemes, this is the stress/tone type
|
||||
unsigned char length_mod; // a length_mod group number, used to access length_mod_tab
|
||||
|
||||
} PHONEME_TAB;
|
||||
|
||||
+34
-14
@@ -139,15 +139,18 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
|
||||
if(GetFileLength(path) <= 0)
|
||||
{
|
||||
sprintf(path,"/usr/share/mbrola/%s",mbrola_voice);
|
||||
|
||||
if(GetFileLength(path) <= 0)
|
||||
{
|
||||
sprintf(path,"/usr/share/mbrola/%s/%s",mbrola_voice,mbrola_voice);
|
||||
|
||||
if(GetFileLength(path) <= 0)
|
||||
{
|
||||
sprintf(path,"/usr/share/mbrola/voices/%s",mbrola_voice);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(GetFileLength(path) <= 0)
|
||||
{
|
||||
sprintf(path,"/usr/share/mbrola/%s/%s",mbrola_voice,mbrola_voice);
|
||||
}
|
||||
if(GetFileLength(path) <= 0)
|
||||
{
|
||||
sprintf(path,"/usr/share/mbrola/voices/%s",mbrola_voice);
|
||||
}
|
||||
close_MBR();
|
||||
#endif
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
if(load_MBR() == FALSE) // load mbrola.dll
|
||||
@@ -478,7 +481,8 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
else
|
||||
len = (80 * speed.wav_factor)/256;
|
||||
|
||||
DoMarker(espeakEVENT_PHONEME, (p->sourceix & 0x7ff) + clause_start_char, 0, ph->mnemonic);
|
||||
if(ph->code != phonEND_WORD)
|
||||
DoMarker(espeakEVENT_PHONEME, (p->sourceix & 0x7ff) + clause_start_char, 0, ph->mnemonic);
|
||||
|
||||
ptr += sprintf(ptr,"%s\t",WordToString(name));
|
||||
|
||||
@@ -645,12 +649,15 @@ int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
}
|
||||
|
||||
|
||||
int MbrolaFill(int length, int resume)
|
||||
{//===================================
|
||||
// Read audio data from Mbrola (length is in milisecs)
|
||||
int MbrolaFill(int length, int resume, int amplitude)
|
||||
{//==================================================
|
||||
// Read audio data from Mbrola (length is in millisecs)
|
||||
|
||||
static int n_samples;
|
||||
int req_samples, result;
|
||||
int ix;
|
||||
short value16;
|
||||
int value;
|
||||
|
||||
if (!resume)
|
||||
n_samples = samplerate * length / 1000;
|
||||
@@ -661,7 +668,20 @@ int MbrolaFill(int length, int resume)
|
||||
result = read_MBR((short *)out_ptr, req_samples);
|
||||
if (result <= 0)
|
||||
return 0;
|
||||
out_ptr += result*2;
|
||||
|
||||
for(ix=0; ix < result; ix++)
|
||||
{
|
||||
value16 = out_ptr[0] + (out_ptr[1] << 8);
|
||||
value = value16 * amplitude;
|
||||
value = value / 40; // adjust this constant to give a suitable amplitude for mbrola voices
|
||||
if(value > 0x7fff)
|
||||
value = 0x7fff;
|
||||
if(value < -0x8000)
|
||||
value = 0x8000;
|
||||
out_ptr[0] = value;
|
||||
out_ptr[1] = value >> 8;
|
||||
out_ptr += 2;
|
||||
}
|
||||
n_samples -= result;
|
||||
return n_samples ? 1 : 0;
|
||||
}
|
||||
@@ -688,7 +708,7 @@ int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int MbrolaFill(int length, int resume)
|
||||
int MbrolaFill(int length, int resume, int amplitude)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@
|
||||
#include "translate.h"
|
||||
#include "wave.h"
|
||||
|
||||
const char *version_string = "1.45.27 19.May.11";
|
||||
const char *version_string = "1.45.28 24.May.11";
|
||||
const int version_phdata = 0x014500;
|
||||
|
||||
int option_device_number = -1;
|
||||
|
||||
+2
-2
@@ -1393,7 +1393,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
// DoMarker(espeakEVENT_END, count_characters, 0, count_sentences); // end of clause
|
||||
|
||||
if(p->newword & 1)
|
||||
DoMarker(espeakEVENT_WORD, sourceix, p->sourceix >> 11, clause_start_word + word_count++);
|
||||
DoMarker(espeakEVENT_WORD, sourceix, p->sourceix >> 11, clause_start_word + word_count++); // NOTE, this count doesn't include multiple-word pronunciations in *_list. eg (of a)
|
||||
}
|
||||
|
||||
EndAmplitude();
|
||||
@@ -1401,7 +1401,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
if(p->prepause > 0)
|
||||
DoPause(p->prepause,1);
|
||||
|
||||
if(option_phoneme_events && (p->type != phVOWEL))
|
||||
if(option_phoneme_events && (p->type != phVOWEL) && (p->ph->code != phonEND_WORD))
|
||||
{
|
||||
// Note, for vowels, do the phoneme event after the vowel-start
|
||||
DoMarker(espeakEVENT_PHONEME, sourceix, 0, p->ph->mnemonic);
|
||||
|
||||
+1
-1
@@ -553,7 +553,7 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
|
||||
void SetParameter(int parameter, int value, int relative);
|
||||
int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbrola);
|
||||
int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume);
|
||||
int MbrolaFill(int length, int resume);
|
||||
int MbrolaFill(int length, int resume, int amplitude);
|
||||
void MbrolaReset(void);
|
||||
void DoEmbedded(int *embix, int sourceix);
|
||||
void DoMarker(int type, int char_posn, int length, int value);
|
||||
|
||||
+20
-3
@@ -1672,9 +1672,20 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
} while((embedded_cmd & 0x80) == 0);
|
||||
}
|
||||
|
||||
if(word[0] == 0)
|
||||
if((word[0] == 0) || (word_flags & FLAG_DELETE_WORD))
|
||||
{
|
||||
// nothing to translate
|
||||
// nothing to translate. Add a dummy phoneme to carry any embedded commands
|
||||
if(embedded_flag)
|
||||
{
|
||||
ph_list2[n_ph_list2].phcode = phonEND_WORD;
|
||||
ph_list2[n_ph_list2].stresslevel = 0;
|
||||
ph_list2[n_ph_list2].wordstress = 0;
|
||||
ph_list2[n_ph_list2].tone_ph = 0;
|
||||
ph_list2[n_ph_list2].synthflags = embedded_flag;
|
||||
ph_list2[n_ph_list2].sourceix = 0;
|
||||
n_ph_list2++;
|
||||
embedded_flag = 0;
|
||||
}
|
||||
word_phonemes[0] = 0;
|
||||
return(0);
|
||||
}
|
||||
@@ -3175,6 +3186,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
|
||||
else
|
||||
{
|
||||
pre_pause = 0;
|
||||
|
||||
dict_flags = TranslateWord2(tr, word, &words[ix], words[ix].pre_pause, words[ix+1].pre_pause);
|
||||
|
||||
if(pre_pause > words[ix+1].pre_pause)
|
||||
@@ -3206,7 +3218,12 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
|
||||
|
||||
if(dict_flags & FLAG_SKIPWORDS)
|
||||
{
|
||||
ix += dictionary_skipwords; // dictionary indicates skip next word(s)
|
||||
// dictionary indicates skip next word(s)
|
||||
while(dictionary_skipwords > 0)
|
||||
{
|
||||
words[ix+dictionary_skipwords].flags |= FLAG_DELETE_WORD;
|
||||
dictionary_skipwords--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
#define FLAG_COMMA_AFTER 0x20000 // comma after this word
|
||||
#define FLAG_MULTIPLE_SPACES 0x40000 // word is preceded by multiple spaces, newline, or tab
|
||||
#define FLAG_INDIVIDUAL_DIGITS 0x80000 // speak number as individual digits
|
||||
#define FLAG_DELETE_WORD 0x100000 // don't speak this word, it has been spoken as part of the previous word
|
||||
|
||||
#define FLAG_SUFFIX_VOWEL 0x08000000 // remember an initial vowel from the suffix
|
||||
#define FLAG_NO_TRACE 0x10000000 // passed to TranslateRules() to suppress dictionary lookup printout
|
||||
|
||||
+1
-1
@@ -1966,7 +1966,7 @@ int WavegenFill2(int fill_zeros)
|
||||
break;
|
||||
|
||||
case WCMD_MBROLA_DATA:
|
||||
result = MbrolaFill(length, resume);
|
||||
result = MbrolaFill(length, resume, (general_amplitude * wvoice->voicing)/64);
|
||||
break;
|
||||
|
||||
case WCMD_FMT_AMPLITUDE:
|
||||
|
||||
Reference in New Issue
Block a user