[1.39.18]

*_list  Allow Hyphens in multi-word entries  (aa-bb).  This will only match a pair of words which are hyphenated.
*_list  Fix abbreviations of the form  a.b.cde
Recognise Armenian punctuation, allow and process Armenian punctuation inside words (affects intonation type, and marks the focus word of the clause).
Mbrola: add a delay so that SAPI5 events better follow the speaking.
Mbrola: generate phoneme events, and hence SAPI5 viseme events.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@200 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2008-11-07 19:43:53 +00:00
parent af5209f741
commit 75970b147a
29 changed files with 531 additions and 337 deletions
+5
View File
@@ -312,6 +312,11 @@ static char nullstring[] = {0};
break;
case 1:
if(c == '-')
{
flag_codes[n_flag_codes++] = BITNUM_FLAG_HYPHENATED;
c = ' ';
}
if(isspace2(c))
{
p[0] = 0; /* terminate english word */
+13 -2
View File
@@ -2867,7 +2867,7 @@ const char *Translator::LookupDict2(const char *word, const char *word2, char *p
// don't use the contraction if any of the words are emphasized
for(ix=0; ix <= skipwords; ix++)
{
if((wtab != NULL) && (wtab[ix].flags & FLAG_EMPHASIZED))
if((wtab != NULL) && (wtab[ix].flags & FLAG_EMPHASIZED2))
{
condition_failed = 1;
}
@@ -2935,6 +2935,13 @@ const char *Translator::LookupDict2(const char *word, const char *word2, char *p
}
}
if(dictionary_flags2 & FLAG_HYPHENATED)
{
if(!(word_flags & FLAG_HYPHEN_AFTER))
{
continue;
}
}
if(dictionary_flags2 & FLAG_CAPITAL)
{
if(!(word_flags & FLAG_FIRST_UPPER))
@@ -3070,7 +3077,11 @@ int Translator::LookupDictList(char **wordptr, char *ph_out, unsigned int *flags
if(length > 0)
{
// found an abbreviation containing dots
nbytes = utf8_nbytes(word2);
nbytes = 0;
while(((c = word2[nbytes]) != 0) && (c != ' '))
{
nbytes++;
}
memcpy(&word[length],word2,nbytes);
word[length+nbytes] = 0;
found = LookupDict2(word, word2, ph_out, flags, end_flags, wtab);
+2 -1
View File
@@ -126,7 +126,8 @@ int TestSynthCallback(short *wav, int numsamples, espeak_EVENT *events)
while((type = events->type) != 0)
{
fprintf(f_events,"%2d (%4d %4d) %5d %5d (%3d) ",type,events->unique_identifier,(int)events->user_data,events->audio_position,events->text_position,events->length);
fprintf(f_events,"%2d (%4d %4ld) %5d %5d (%3d) ",type,events->unique_identifier,(long)events->user_data,events->audio_position,events->text_position,events->length);
if((type==3) || (type==4))
fprintf(f_events,"'%s'\n",events->id.name);
else
+57 -18
View File
@@ -82,6 +82,12 @@ const unsigned short punct_chars[] = {',','.','?','!',':',';',
0x3001, // ideograph comma
0x3002, // ideograph period
0x0589, // Armenian period
0x055d, // Armenian comma
0x055c, // Armenian exclamation
0x055e, // Armenian question
0x055b, // Armenian emphasis mark
0xff01, // fullwidth exclamation
0xff0c, // fullwidth comma
0xff0e, // fullwidth period
@@ -106,6 +112,12 @@ static const unsigned int punct_attributes [] = { 0,
CLAUSE_COMMA+0x8000, // ideograph comma
CLAUSE_PERIOD+0x8000, // ideograph period
CLAUSE_PERIOD+0x8000, // Armenian period
CLAUSE_COMMA, // Armenian comma
CLAUSE_EXCLAMATION + PUNCT_IN_WORD, // Armenian exclamation
CLAUSE_QUESTION + PUNCT_IN_WORD, // Armenian question
CLAUSE_PERIOD + PUNCT_IN_WORD, // Armenian emphasis mark
CLAUSE_EXCLAMATION+0x8000, // fullwidth
CLAUSE_COMMA+0x8000,
CLAUSE_PERIOD+0x8000,
@@ -1826,8 +1838,8 @@ MNEM_TAB xml_char_mnemonics[] = {
{NULL,-1}};
int Translator::ReadClause(FILE *f_in, char *buf, short *charix, int n_buf)
{//========================================================================
int Translator::ReadClause(FILE *f_in, char *buf, short *charix, int n_buf, int *tone_type)
{//========================================================================================
/* Find the end of the current clause.
Write the clause into buf
@@ -1855,6 +1867,7 @@ int Translator::ReadClause(FILE *f_in, char *buf, short *charix, int n_buf)
int any_alnum = 0;
int self_closing;
int punct_data;
int stressed_word = 0;
const char *p;
wchar_t xml_buf[N_XML_BUF+1];
@@ -1872,6 +1885,7 @@ int Translator::ReadClause(FILE *f_in, char *buf, short *charix, int n_buf)
clause_upper_count = 0;
clause_lower_count = 0;
end_of_input = 0;
*tone_type = 0;
f_input = f_in; // for GetC etc
@@ -2110,25 +2124,35 @@ f_input = f_in; // for GetC etc
if(iswalnum(c1))
any_alnum = 1;
else
if(iswspace(c1))
{
char *p_word;
if(translator_name == 0x6a626f)
if(stressed_word)
{
// language jbo : lojban
// treat "i" or ".i" as end-of-sentence
p_word = &buf[ix-1];
if(p_word[0] == 'i')
stressed_word = 0;
c1 = CHAR_EMPHASIS; // indicate this word is strtessed
UngetC(c2);
c2 = ' ';
}
if(iswspace(c1))
{
char *p_word;
if(translator_name == 0x6a626f)
{
if(p_word[-1] == '.')
p_word--;
if(p_word[-1] == ' ')
// language jbo : lojban
// treat "i" or ".i" as end-of-sentence
p_word = &buf[ix-1];
if(p_word[0] == 'i')
{
ungot_word = "i ";
UngetC(c2);
p_word[0] = 0;
return(CLAUSE_PERIOD);
if(p_word[-1] == '.')
p_word--;
if(p_word[-1] == ' ')
{
ungot_word = "i ";
UngetC(c2);
p_word[0] = 0;
return(CLAUSE_PERIOD);
}
}
}
}
@@ -2218,7 +2242,17 @@ if(option_ssml) parag=1;
if((phoneme_mode==0) && (sayas_mode==0) && ((punct = lookupwchar(punct_chars,c1)) != 0))
{
if((iswspace(c2) || (punct_attributes[punct] & 0x8000) || IsBracket(c2) || (c2=='?') || (c2=='-') || Eof()))
punct_data = punct_attributes[punct];
if(punct_data & PUNCT_IN_WORD)
{
// Armenian punctuation inside a word
stressed_word = 1;
*tone_type = punct_data >> 12 & 0xf; // override the end-of-sentence type
continue;
}
if((iswspace(c2) || (punct_data & 0x8000) || IsBracket(c2) || (c2=='?') || (c2=='-') || Eof()))
{
// note: (c2='?') is for when a smart-quote has been replaced by '?'
buf[ix] = ' ';
@@ -2295,6 +2329,11 @@ if(option_ssml) parag=1;
return(CLAUSE_NONE);
}
}
if(stressed_word)
{
ix += utf8_out(CHAR_EMPHASIS, &buf[ix]);
}
buf[ix] = ' ';
buf[ix+1] = 0;
return(CLAUSE_EOF); // end of file
+4 -1
View File
@@ -542,7 +542,10 @@ void Translator::CalcLengths()
if(end_of_clause == 2)
{
// this is the last syllable in the clause, lengthen it - more for short vowels
length_mod = length_mod * (256 + (280 - p->ph->std_length)/3)/256;
len = p->ph->std_length;
if(langopts.stress_flags & 0x40000)
len=200; // don't lengthen short vowels more than long vowels at end-of-clause
length_mod = length_mod * (256 + (280 - len)/3)/256;
}
if(p->type != phVOWEL)
+2 -2
View File
@@ -517,9 +517,9 @@ void MarkerEvent(int type, unsigned int char_position, int value, unsigned char
ep->text_position = char_position & 0xffff;
ep->length = char_position >> 24;
time = (double(count_samples + (out_ptr - out_start)/2)*1000.0)/samplerate;
time = (double(count_samples + mbrola_delay + (out_ptr - out_start)/2)*1000.0)/samplerate;
ep->audio_position = int(time);
ep->sample = (count_samples + (out_ptr - out_start)/2);
ep->sample = (count_samples + mbrola_delay + (out_ptr - out_start)/2);
SHOW("MarkerEvent > count_samples=%d, out_ptr=%x, out_start=0x%x\n",count_samples, out_ptr, out_start);
SHOW("*** MarkerEvent > type=%s, uid=%d, text_pos=%d, length=%d, audio_position=%d, sample=%d\n",
+7
View File
@@ -123,6 +123,8 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
char path[sizeof(path_home)+15];
mbrola_name[0] = 0;
mbrola_delay = 0;
if(mbrola_voice == NULL)
{
samplerate = samplerate_native;
@@ -193,6 +195,7 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
else
SetParameter(espeakVOICETYPE,1,0);
strcpy(mbrola_name,mbrola_voice);
mbrola_delay = 3800; // improve synchronization of events
return(EE_OK);
} // end of LoadMbrolaTable
@@ -602,6 +605,10 @@ void MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, FILE *f_mbrola)
else
len = (80 * speed_factor2)/256;
#ifdef USE_MBROLA_LIB
MbrolaMarker(espeakEVENT_PHONEME, (p->sourceix & 0x7ff) + clause_start_char, 0, ph->mnemonic);
#endif
sprintf(buf,"%s\t",WordToString(name));
strcat(mbr_buf,buf);
+1 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.39.14 02.Nov.08";
const char *version_string = "1.39.18 06.Nov.08";
const int version_phdata = 0x013900;
int option_device_number = -1;
+1
View File
@@ -42,6 +42,7 @@ static void SmoothSpect(void);
int n_phoneme_list=0;
PHONEME_LIST phoneme_list[N_PHONEME_LIST];
int mbrola_delay;
char mbrola_name[20];
int speed_factor1;
+1
View File
@@ -220,6 +220,7 @@ extern int wavefile_amp2;
extern int vowel_transition[4];
extern int vowel_transition0, vowel_transition1;
extern int mbrola_delay;
extern char mbrola_name[20];
// from synthdata file
+19 -2
View File
@@ -45,6 +45,7 @@
// start of unicode pages for character sets
#define OFFSET_GREEK 0x380
#define OFFSET_CYRILLIC 0x420
#define OFFSET_ARMENIAN 0x530
#define OFFSET_DEVANAGARI 0x900
#define OFFSET_BENGALI 0x980
#define OFFSET_TAMIL 0xb80
@@ -431,6 +432,22 @@ SetLengthMods(tr,3); // all equal
}
break;
case L('h','y'): // Armenian
{
static const char hy_vowels[] = {0x31, 0x35, 0x37, 0x38, 0x3b, 0x48, 0x55, 0};
static const char hy_consonants[] = {0x32,0x33,0x34,0x36,0x39,0x3a,0x3c,0x3d,0x3e,0x3f,
0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x56,0};
tr = new Translator();
tr->langopts.stress_rule = 3; // default stress on final syllable
tr->letter_bits_offset = OFFSET_ARMENIAN;
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
SetLetterBits(tr,LETTERGP_A,hy_vowels);
SetLetterBits(tr,LETTERGP_C,hy_consonants);
tr->langopts.max_initial_consonants = 4;
}
break;
case L('i','d'): // Indonesian
{
static const short stress_lengths_id[8] = {160, 200, 180, 180, 0, 0, 220, 240};
@@ -563,8 +580,8 @@ SetLengthMods(tr,3); // all equal
tr->langopts.stress_rule = 0;
tr->langopts.spelling_stress = 1;
tr->charset_a0 = charsets[4]; // ISO-8859-4
tr->langopts.numbers = 0x409;
tr->langopts.stress_flags = 0x16;
tr->langopts.numbers = 0x409 + 0x8000 + 0x10000;
tr->langopts.stress_flags = 0x16 + 0x40000;
}
break;
+16 -3
View File
@@ -1179,13 +1179,13 @@ strcpy(phonemes2,phonemes);
dictionary_flags[0] &= ~FLAG_PAUSE1;
}
if(wflags & FLAG_EMPHASIZED)
if(wflags & FLAG_EMPHASIZED2)
{
// A word is indicated in the source text as stressed
// Give it stress level 6 (for the intonation module)
ChangeWordStress(this,word_phonemes,6);
// if(!(wflags & FLAG_LAST_WORD)) // ?? omit pre-pause if it's the last word in the sentence?
if(wflags & FLAG_EMPHASIZED)
dictionary_flags[0] |= FLAG_PAUSE1; // precede by short pause
}
else
@@ -2030,6 +2030,7 @@ void *Translator::TranslateClause(FILE *f_text, const void *vp_input, int *tone_
int terminator;
int tone;
int tone2;
p_textinput = (char *)vp_input;
p_wchar_input = (wchar_t *)vp_input;
@@ -2044,12 +2045,17 @@ void *Translator::TranslateClause(FILE *f_text, const void *vp_input, int *tone_
for(ix=0; ix<N_TR_SOURCE; ix++)
charix[ix] = 0;
terminator = translator->ReadClause(f_text,source,charix,N_TR_SOURCE);
terminator = translator->ReadClause(f_text, source, charix, N_TR_SOURCE, &tone2);
charix[N_TR_SOURCE] = count_characters;
clause_pause = (terminator & 0xfff) * 10; // mS
tone = (terminator >> 12) & 0xf;
if(tone2 != 0)
{
// override the tone type
tone = tone2;
}
for(p=source; *p != 0; p++)
{
@@ -2248,6 +2254,13 @@ if((c == '/') && (langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(prev_ou
c = '\'';
}
if(c == CHAR_EMPHASIS)
{
// this character is a marker that the previous word is the focus of the clause
c = ' ';
word_flags |= FLAG_FOCUS;
}
c = TranslateChar(&source[source_index], prev_in,c, next_in, &char_inserted); // optional language specific function
if(c == 8)
continue; // ignore this character
+11 -4
View File
@@ -76,7 +76,8 @@
#define FLAG_CAPITAL 0x200 /* pronunciation if initial letter is upper case */
#define FLAG_ALLCAPS 0x400 // only if the word is all capitals
#define FLAG_ACCENT 0x800 // character name is base-character name + accent name
#define FLAG_HYPHENATED 0x1000 // multiple-words, but needs hyphen between parts 1 and 2
#define BITNUM_FLAG_HYPHENATED 0x2c
// wordflags, flags in source word
@@ -86,15 +87,16 @@
#define FLAG_HAS_PLURAL 0x4 /* upper-case word with s or 's lower-case ending */
#define FLAG_PHONEMES 0x8 /* word is phonemes */
#define FLAG_LAST_WORD 0x10 /* last word in clause */
//#define FLAG_SPELLING 0x20 // speak the word as individual letters
#define FLAG_EMBEDDED 0x40 /* word is preceded by embedded commands */
#define FLAG_HYPHEN 0x80
#define FLAG_NOSPACE 0x100 // word is not seperated from previous word by a space
#define FLAG_FIRST_WORD 0x200 // first word in clause
#define FLAG_FOCUS 0x400 // the focus word of a clause
#define FLAG_EMPHASIZED 0x800
#define FLAG_EMPHASIZED2 0xc00 // FLAG_FOCUS | FLAG_EMPHASIZED
#define FLAG_DONT_SWITCH_TRANSLATOR 0x1000
#define FLAG_SUFFIX_REMOVED 0x2000
#define FLAG_HYPHEN_AFTER 0x4000
#define FLAG_EMPHASIZED 0x8000
#define FLAG_NO_TRACE 0x10000 // passed to TranslateRules() to suppress dictionary lookup printout
#define FLAG_NO_PREFIX 0x20000
@@ -161,8 +163,10 @@
// bits 0-7 pause x 10mS, bits 12-14 intonation type,
// bit 19=sentence, bit 18=clause, bits 17=voice change
// bit 16 used to distinguish otherwise identical types
// bit 20= punctuation character can be inside a word (Armenian)
#define CLAUSE_BIT_SENTENCE 0x80000
#define CLAUSE_BIT_VOICE 0x20000
#define PUNCT_IN_WORD 0x100000
#define CLAUSE_NONE 0 + 0x04000
#define CLAUSE_PARAGRAPH 70 + 0x80000
@@ -187,6 +191,8 @@
#define SAYAS_DIGITS 0x40 // + number of digits
#define SAYAS_DIGITS1 0xc1
#define CHAR_EMPHASIS 0x0530 // this is an unused character code
// Rule:
// [4] [match] [1 pre] [2 post] [3 phonemes] 0
// match 1 pre 2 post 0 - use common phoneme string
@@ -306,6 +312,7 @@ typedef struct {
// bit15= Give stress to the first unstressed syllable
// bit16= Don't diminish consecutive syllables within a word.
// bit17= "priority" stress reduces other primary stress to "unstressed" not "secondary"
// bit18= don't lengthen short vowels more than long vowels at end-of-clause
int stress_flags;
int unstressed_wd1; // stress for $u word of 1 syllable
@@ -435,7 +442,7 @@ private:
void MakePhonemeList(int post_pause, int new_sentence);
int SubstitutePhonemes(PHONEME_LIST2 *plist_out);
int ReadClause(FILE *f_in, char *buf, short *charix, int n_buf);
int ReadClause(FILE *f_in, char *buf, short *charix, int n_buf, int *tone_type);
int AnnouncePunctuation(int c1, int c2, char *buf, int ix);
const char *LookupDict2(const char *word, const char *word2, char *phonetic, unsigned int *flags, int end_flags, WORD_TAB *wtab);