option_emphasize_allcaps in translate.cpp, if set will emphasize words which are all-capitals. Changed intonation.cpp. Added an intonation for sentences which end in an exclamation mark. git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@111 d46cf337-b52f-0410-862d-fd96e6ae7743master
| @@ -907,10 +907,11 @@ genome dZi:noUm | |||
| genre Z0nr@ | |||
| genuine dZEnju:In | |||
| geyser gi:z3 | |||
| gibbon gIb@n | |||
| gig gIg | |||
| gigantic dZaIg'antIk | |||
| gibbon gIb@n | |||
| gilead g'IlIad | |||
| gimme gImI | |||
| giraffe dZI2raaf | |||
| goin ,goUIn $only // for goin' | |||
| goodbye $2 | |||
| @@ -1473,6 +1474,7 @@ ratatouille rat@t'u:I2 | |||
| ?!3 rather rA:D3 | |||
| ratio reISI2oU | |||
| rationale raS@n'al | |||
| ravenous rav@n@s | |||
| ravine r@vi:n | |||
| rawest rO:@st | |||
| re r,i: | |||
| @@ -1511,6 +1513,7 @@ region ri:dZ@n // & regional | |||
| reign reIn | |||
| rein reIn | |||
| reined reInd | |||
| reining reInIN | |||
| reindeer reIndi@ | |||
| reinvent ri:Inv'Ent | |||
| refinery rI2faIn@rI2 | |||
| @@ -2349,6 +2352,7 @@ to t@5 $verbf // @ change to U before vowel | |||
| (to to) %tU_t@5 $verbf | |||
| (to and fro) tu:@ndfr'oU | |||
| to tu: $u $atend | |||
| to tu: $allcaps | |||
| at at $nounf $only $u | |||
| @@ -2487,6 +2491,7 @@ has %ha2z $pastf $only | |||
| has haz $only $atend | |||
| (has been) %haz%bIn $pastf | |||
| (has to) haztU $atend | |||
| has haz $allcaps | |||
| hath %haT $pastf $only | |||
| had %had $pastf $strend2 $only | |||
| (had been) %had%bIn $pastf | |||
| @@ -2429,7 +2429,8 @@ | |||
| &) hold (_$4 hoUld | |||
| holme hoUm | |||
| _) h (our | |||
| _) h (ono | |||
| _) h (onor | |||
| _) h (onou | |||
| hone (st 0nI | |||
| _) horri h0rI | |||
| _) horse hO@s | |||
| @@ -3490,6 +3491,7 @@ | |||
| n) o (ta oU | |||
| n) o (tor oU | |||
| r) o (ta oU | |||
| r) o (to oU | |||
| t) o (ta oU | |||
| piv) o (t @ | |||
| o (tat oU | |||
| @@ -144,7 +144,7 @@ typedef enum { | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| int espeak_Initialize(espeak_AUDIO_OUTPUT output, int buflength, const char *path, int options); | |||
| ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output, int buflength, const char *path, int options); | |||
| /* Must be called before any synthesis functions are called. | |||
| output: the audio data can either be played by eSpeak or passed back by the SynthCallback function. | |||
| @@ -163,7 +163,7 @@ typedef int (t_espeak_callback)(short*, int, espeak_EVENT*); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| void espeak_SetSynthCallback(t_espeak_callback* SynthCallback); | |||
| ESPEAK_API void espeak_SetSynthCallback(t_espeak_callback* SynthCallback); | |||
| /* Must be called before any synthesis functions are called. | |||
| This specifies a function in the calling program which is called when a buffer of | |||
| speech sound data has been produced. | |||
| @@ -191,7 +191,7 @@ int SynthCallback(short *wav, int numsamples, espeak_EVENT *events); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| void espeak_SetUriCallback(int (*UriCallback)(int, const char*, const char*)); | |||
| ESPEAK_API void espeak_SetUriCallback(int (*UriCallback)(int, const char*, const char*)); | |||
| /* This function may be called before synthesis functions are used, in order to deal with | |||
| <audio> tags. It specifies a callback function which is called when an <audio> element is | |||
| encountered and allows the calling program to indicate whether the sound file which | |||
| @@ -231,7 +231,7 @@ int UriCallback(int type, const char *uri, const char *base); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| espeak_ERROR espeak_Synth(const void *text, | |||
| ESPEAK_API espeak_ERROR espeak_Synth(const void *text, | |||
| size_t size, | |||
| unsigned int position, | |||
| espeak_POSITION_TYPE position_type, | |||
| @@ -287,7 +287,7 @@ espeak_ERROR espeak_Synth(const void *text, | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| espeak_ERROR espeak_Synth_Mark(const void *text, | |||
| ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text, | |||
| size_t size, | |||
| const char *index_mark, | |||
| unsigned int end_position, | |||
| @@ -311,7 +311,7 @@ espeak_ERROR espeak_Synth_Mark(const void *text, | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| espeak_ERROR espeak_Key(const char *key_name); | |||
| ESPEAK_API espeak_ERROR espeak_Key(const char *key_name); | |||
| /* Speak the name of a keyboard key. | |||
| Currently this just speaks the "key_name" as given | |||
| @@ -324,7 +324,7 @@ espeak_ERROR espeak_Key(const char *key_name); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| espeak_ERROR espeak_Char(wchar_t character); | |||
| ESPEAK_API espeak_ERROR espeak_Char(wchar_t character); | |||
| /* Speak the name of the given character | |||
| Return: EE_OK: operation achieved | |||
| @@ -364,7 +364,7 @@ typedef enum { | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int value, int relative); | |||
| ESPEAK_API espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int value, int relative); | |||
| /* Sets the value of the specified parameter. | |||
| relative=0 Sets the absolute value of the parameter. | |||
| relative=1 Sets a relative value of the parameter. | |||
| @@ -398,7 +398,7 @@ espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int value, int rela | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| int espeak_GetParameter(espeak_PARAMETER parameter, int current); | |||
| ESPEAK_API int espeak_GetParameter(espeak_PARAMETER parameter, int current); | |||
| /* current=0 Returns the default value of the specified parameter. | |||
| current=1 Returns the current value of the specified parameter, as set by SetParameter() | |||
| */ | |||
| @@ -406,7 +406,7 @@ int espeak_GetParameter(espeak_PARAMETER parameter, int current); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist); | |||
| ESPEAK_API espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist); | |||
| /* Specified a list of punctuation characters whose names are to be spoken when the | |||
| value of the Punctuation parameter is set to "some". | |||
| @@ -421,7 +421,7 @@ espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| void espeak_SetPhonemeTrace(int value, FILE *stream); | |||
| ESPEAK_API void espeak_SetPhonemeTrace(int value, FILE *stream); | |||
| /* Controls the output of phoneme symbols for the text | |||
| value=0 No phoneme output (default) | |||
| value=1 Output the translated phoneme symbols for the text | |||
| @@ -433,7 +433,7 @@ void espeak_SetPhonemeTrace(int value, FILE *stream); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| void espeak_CompileDictionary(const char *path, FILE *log); | |||
| ESPEAK_API void espeak_CompileDictionary(const char *path, FILE *log); | |||
| /* Compile pronunciation dictionary for a language which corresponds to the currently | |||
| selected voice. The required voice should be selected before calling this function. | |||
| @@ -483,7 +483,7 @@ typedef struct { | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec); | |||
| ESPEAK_API const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec); | |||
| /* Reads the voice files from espeak-data/voices and creates an array of espeak_VOICE pointers. | |||
| The list is terminated by a NULL pointer | |||
| @@ -495,7 +495,7 @@ const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| espeak_ERROR espeak_SetVoiceByName(const char *name); | |||
| ESPEAK_API espeak_ERROR espeak_SetVoiceByName(const char *name); | |||
| /* Searches for a voice with a matching "name" field. Language is not considered. | |||
| "name" is a UTF8 string. | |||
| @@ -508,7 +508,7 @@ espeak_ERROR espeak_SetVoiceByName(const char *name); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| espeak_ERROR espeak_SetVoiceByProperties(espeak_VOICE *voice_spec); | |||
| ESPEAK_API espeak_ERROR espeak_SetVoiceByProperties(espeak_VOICE *voice_spec); | |||
| /* An espeak_VOICE structure is used to pass criteria to select a voice. Any of the following | |||
| fields may be set: | |||
| @@ -528,7 +528,7 @@ espeak_ERROR espeak_SetVoiceByProperties(espeak_VOICE *voice_spec); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| espeak_VOICE *espeak_GetCurrentVoice(void); | |||
| ESPEAK_API espeak_VOICE *espeak_GetCurrentVoice(void); | |||
| /* Returns the espeak_VOICE data for the currently selected voice. | |||
| This is not affected by temporary voice changes caused by SSML elements such as <voice> and <s> | |||
| */ | |||
| @@ -536,7 +536,7 @@ espeak_VOICE *espeak_GetCurrentVoice(void); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| espeak_ERROR espeak_Cancel(void); | |||
| ESPEAK_API espeak_ERROR espeak_Cancel(void); | |||
| /* Stop immediately synthesis and audio output of the current text. When this | |||
| function returns, the audio output is fully stopped and the synthesizer is ready to | |||
| synthesize a new message. | |||
| @@ -549,14 +549,14 @@ espeak_ERROR espeak_Cancel(void); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| int espeak_IsPlaying(void); | |||
| ESPEAK_API int espeak_IsPlaying(void); | |||
| /* Returns 1 if audio is played, 0 otherwise. | |||
| */ | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| espeak_ERROR espeak_Synchronize(void); | |||
| ESPEAK_API espeak_ERROR espeak_Synchronize(void); | |||
| /* This function returns when all data have been spoken. | |||
| Return: EE_OK: operation achieved | |||
| EE_INTERNAL_ERROR. | |||
| @@ -565,7 +565,7 @@ espeak_ERROR espeak_Synchronize(void); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| espeak_ERROR espeak_Terminate(void); | |||
| ESPEAK_API espeak_ERROR espeak_Terminate(void); | |||
| /* last function to be called. | |||
| Return: EE_OK: operation achieved | |||
| EE_INTERNAL_ERROR. | |||
| @@ -575,7 +575,7 @@ espeak_ERROR espeak_Terminate(void); | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| #endif | |||
| const char *espeak_Info(void* ptr); | |||
| ESPEAK_API const char *espeak_Info(void* ptr); | |||
| /* Returns the version number string. | |||
| The parameter is for future use, and should be set to NULL | |||
| */ | |||
| @@ -1163,6 +1163,8 @@ int x; | |||
| espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,100,NULL,0); | |||
| memset(&voicespec,0,sizeof(voicespec)); | |||
| voicespec.languages = "de"; | |||
| voicespec.gender = 2; | |||
| espeak_SetVoiceByProperties(&voicespec); | |||
| newvoice = espeak_GetCurrentVoice(); | |||
| x = 1; | |||
| @@ -1232,6 +1234,7 @@ void TestTest(int control) | |||
| //CharsetToUnicode("ISO-8859-4"); | |||
| //CharsetToUnicode("ISCII"); | |||
| return; | |||
| if(control==2) | |||
| @@ -35,12 +35,19 @@ | |||
| provide a more flexible intonation system. | |||
| */ | |||
| static int tone_pitch_env; /* used to return pitch envelope */ | |||
| typedef struct { | |||
| char stress; | |||
| char env; | |||
| char flags; //bit 0=pitch rising, bit1=emnphasized | |||
| short pitch1; | |||
| short pitch2; | |||
| } SYLLABLE; | |||
| SYLLABLE syllable_tab[N_PHONEME_LIST]; | |||
| static int vowel_ix; | |||
| static int vowel_ix_top; | |||
| static int *vowel_tab; | |||
| static int tone_pitch_env; /* used to return pitch envelope */ | |||
| /* Pitch data for tone types */ | |||
| @@ -241,9 +248,6 @@ typedef struct { | |||
| unsigned char tonic_max1; | |||
| unsigned char tonic_min1; | |||
| unsigned char emph_level; | |||
| unsigned char emph_next; | |||
| unsigned char pre_start; | |||
| unsigned char pre_end; | |||
| @@ -262,17 +266,17 @@ typedef struct { | |||
| #define N_TONE_TABLE 15 | |||
| static TONE_TABLE tone_table[N_TONE_TABLE] = { | |||
| {PITCHfall, 30, 5, PITCHfall, 30, 7, // statement | |||
| 12, 10, | |||
| 20, 25, 34, 22, drops_0, 3, 3, 12, 8, 0}, | |||
| {PITCHfall, 30, 5, PITCHfall, 30, 8, // statement | |||
| 20, 25, 34, 22, drops_0, 3, 3, 12, 7, 0}, | |||
| {PITCHfrise, 38,10, PITCHfrise2, 36,10, // comma, or question | |||
| 30, 20, | |||
| 20, 25, 34, 20, drops_0, 3, 3, 15, 25, 0}, | |||
| {PITCHfrise, 37,10, PITCHfrise2, 35,10, // comma | |||
| 20, 25, 34, 20, drops_0, 3, 3, 15, 24, 0}, | |||
| {PITCHfrise, 39,10, PITCHfrise2, 36,10, // question | |||
| 20, 25, 34, 20, drops_0, 3, 3, 15, 29, 0}, | |||
| {PITCHdrop, 38, 1, PITCHdrop, 42,25, // exclamation | |||
| 30, 20, | |||
| 20, 25, 34, 22, drops_0, 3, 3, 12, 8, 0}, | |||
| {PITCHfall, 36, 0, PITCHfall, 40, 30, // statement, emphatic | |||
| 20, 25, 34, 22, drops_0, 3, 3, 20, 4, 0}, | |||
| #ifdef deleted | |||
| @@ -314,15 +318,14 @@ static TONE_TABLE tone_table[N_TONE_TABLE] = { | |||
| /* indexed by stress */ | |||
| static int min_drop[] = {0x300,0x300,0x400,0x400,0x900,0x900,0x900,0x900}; | |||
| static int min_drop[] = {0x300,0x300,0x400,0x400,0x900,0x900,0x900,0xb00}; | |||
| #define SECONDARY 3 | |||
| #define PRIMARY 4 | |||
| #define PRIMARY_STRESSED 5 | |||
| #define PRIMARY_MARKED 6 | |||
| #define PRIMARY_STRESSED 6 | |||
| #define PRIMARY_LAST 7 | |||
| @@ -330,37 +333,48 @@ static int number_pre; | |||
| static int number_body; | |||
| static int number_tail; | |||
| static int last_primary; | |||
| static int tone_type; | |||
| static int tone_posn; | |||
| static int annotation; | |||
| static int tone_posn2; | |||
| static int no_tonic; | |||
| static void count_pitch_vowels() | |||
| /******************************/ | |||
| static void count_pitch_vowels(int start, int end, int clause_end) | |||
| /****************************************************************/ | |||
| { | |||
| int ix; | |||
| int stress; | |||
| int max_stress = 0; | |||
| int max_stress_posn = 0; | |||
| int max_stress_posn = 0; // last syllable ot the highest stress | |||
| int max_stress_posn2 = 0; // penuntimate syllable of the highest stress | |||
| int last2_primary; | |||
| number_pre = -1; /* number of vowels before 1st primary stress */ | |||
| number_body = 0; | |||
| number_tail = 0; /* number between tonic syllable and next primary */ | |||
| last_primary = 0; | |||
| last2_primary = 0; | |||
| for(ix=vowel_ix; ix<vowel_ix_top; ix++) | |||
| for(ix=start; ix<end; ix++) | |||
| { | |||
| stress = vowel_tab[ix] & 0x3f; /* marked stress level */ | |||
| stress = syllable_tab[ix].stress; /* marked stress level */ | |||
| if(stress >= max_stress) | |||
| { | |||
| max_stress = stress; | |||
| if(stress > max_stress) | |||
| { | |||
| max_stress_posn2 = ix; | |||
| } | |||
| else | |||
| { | |||
| max_stress_posn2 = max_stress_posn; | |||
| } | |||
| max_stress_posn = ix; | |||
| max_stress = stress; | |||
| } | |||
| if(stress >= PRIMARY) | |||
| { | |||
| if(number_pre < 0) | |||
| number_pre = ix; | |||
| number_pre = ix - start; | |||
| last_primary = ix; | |||
| } | |||
| @@ -370,19 +384,18 @@ static void count_pitch_vowels() | |||
| if(number_pre < 0) | |||
| number_pre = 0; | |||
| number_tail = vowel_ix_top - max_stress_posn - 1; | |||
| number_tail = end - max_stress_posn - 1; | |||
| tone_posn = max_stress_posn; | |||
| tone_posn = last_primary; | |||
| tone_posn2 = max_stress_posn2; | |||
| if(no_tonic) | |||
| { | |||
| tone_posn = vowel_ix_top; | |||
| tone_posn = tone_posn2 = end-1; | |||
| } | |||
| else | |||
| // if((last_primary - max_stress_posn) > 2) | |||
| if(end == clause_end) | |||
| { | |||
| if(vowel_tab[last_primary] < PRIMARY_MARKED) | |||
| vowel_tab[last_primary] = PRIMARY_LAST; | |||
| syllable_tab[last_primary].stress = PRIMARY_LAST; | |||
| } | |||
| } /* end of count_pitch_vowels */ | |||
| @@ -398,7 +411,7 @@ static int count_increments(int ix, int end_ix, int min_stress) | |||
| while(ix < end_ix) | |||
| { | |||
| stress = vowel_tab[ix++] & 0x3f; | |||
| stress = syllable_tab[ix++].stress; | |||
| // if(stress >= PRIMARY_MARKED) | |||
| // break; | |||
| @@ -410,9 +423,9 @@ static int count_increments(int ix, int end_ix, int min_stress) | |||
| static void set_pitch(int ix, int base, int drop) | |||
| /***********************************************/ | |||
| // Set the pitch of a vowel in vowel_tab. Base & drop are Hz * 256 | |||
| static void set_pitch(SYLLABLE *syl, int base, int drop) | |||
| /******************************************************/ | |||
| // Set the pitch of a vowel in syllable_tab. Base & drop are Hz * 256 | |||
| { | |||
| int pitch1, pitch2; | |||
| int flags = 0; | |||
| @@ -421,39 +434,30 @@ static void set_pitch(int ix, int base, int drop) | |||
| int pitch_range2 = 148; | |||
| int pitch_base2 = 72; | |||
| // fprintf(f_log,"base=%3d,drop=%3d ",base>>8,drop>>8); | |||
| // pitch_range2 = pitch_range + 20; | |||
| // pitch_base2 = pitch_base - (128-72); | |||
| if(base < 0) base = 0; | |||
| pitch2 = ((base * pitch_range2 ) >> 15) + pitch_base2; | |||
| if(drop < 0) | |||
| { | |||
| flags = 0x80; | |||
| flags = 1; | |||
| drop = -drop; | |||
| } | |||
| pitch1 = pitch2 + ((drop * pitch_range2) >> 15); | |||
| //x = (pitch1 - pitch2) / 4; // TEST | |||
| //pitch1 -= x; | |||
| //pitch2 += x; | |||
| if(pitch1 > 511) pitch1 = 511; | |||
| if(pitch2 > 511) pitch2 = 511; | |||
| // fprintf(f_log," %d p1=%3d p2=%3d %x\n",vowel_tab[ix] & 0x3f,pitch1,pitch2,flags); | |||
| vowel_tab[ix] = (vowel_tab[ix] & 0x3f) + flags | |||
| + (pitch1 << 8) + (pitch2 << 17); | |||
| syl->pitch1 = pitch1; | |||
| syl->pitch2 = pitch2; | |||
| syl->flags |= flags; | |||
| } /* end of set_pitch */ | |||
| static int calc_pitch_segment(int ix, int end_ix, TONE_TABLE *t, int min_stress) | |||
| /******************************************************************************/ | |||
| static int calc_pitch_segment(int ix, int end_ix, TONE_TABLE *t, int min_stress, int continuing) | |||
| /**********************************************************************************************/ | |||
| /* Calculate pitches until next RESET or tonic syllable, or end. | |||
| Increment pitch if stress is >= min_stress. | |||
| Used for tonic segment */ | |||
| @@ -464,17 +468,33 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_TABLE *t, int min_stress) | |||
| int n_primary=0; | |||
| int initial; | |||
| int overflow=0; | |||
| int marking=0; | |||
| int *drops; | |||
| short *overflow_tab; | |||
| SYLLABLE *syl; | |||
| static char overflow_tab[5] = {0, 20, 12, 4, 0}; | |||
| static short overflow_tab1[5] = {0, 20, 12, 4, 0}; | |||
| static short continue_tab[5] = {-14, 16, 10, 4, 0}; | |||
| drops = t->body_drops; | |||
| initial = 1; | |||
| if(continuing) | |||
| { | |||
| initial =0; | |||
| overflow = 0; | |||
| overflow_tab = continue_tab; | |||
| increment = (t->body_end - t->body_start) << 8; | |||
| increment = increment / (t->body_max_steps -1); | |||
| } | |||
| else | |||
| { | |||
| overflow_tab = overflow_tab1; | |||
| initial = 1; | |||
| } | |||
| while(ix < end_ix) | |||
| { | |||
| stress = vowel_tab[ix] & 0x3f; | |||
| syl = &syllable_tab[ix]; | |||
| stress = syl->stress; | |||
| // if(stress == PRIMARY_MARKED) | |||
| // initial = 1; // reset the intonation pattern | |||
| @@ -509,50 +529,34 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_TABLE *t, int min_stress) | |||
| else | |||
| { | |||
| pitch = (t->body_end << 8) - (increment * overflow_tab[overflow++])/16; | |||
| if(overflow > 4) overflow = 0; | |||
| if(overflow > 4) | |||
| { | |||
| overflow = 0; | |||
| overflow_tab = overflow_tab1; | |||
| } | |||
| } | |||
| } | |||
| if(stress == PRIMARY_MARKED) | |||
| { | |||
| pitch = (t->emph_level << 8); | |||
| marking = 2; | |||
| n_primary = marking+1; // move into overflow region | |||
| } | |||
| else | |||
| if(marking > 0) | |||
| { | |||
| marking--; | |||
| pitch = (t->emph_next << 8); | |||
| } | |||
| n_primary--; | |||
| } | |||
| if((annotation==0) && (stress >= PRIMARY)) | |||
| { | |||
| vowel_tab[ix] = PRIMARY_STRESSED; | |||
| set_pitch(ix,pitch,drops[stress]); | |||
| } | |||
| if(stress >= PRIMARY_MARKED) | |||
| if(stress >= PRIMARY) | |||
| { | |||
| vowel_tab[ix] = PRIMARY_MARKED; | |||
| set_pitch(ix,pitch,drops[stress]); | |||
| syl->stress = PRIMARY_STRESSED; | |||
| set_pitch(syl,pitch,drops[stress]); | |||
| } | |||
| else | |||
| if(stress >= SECONDARY) | |||
| { | |||
| /* use secondary stress for unmarked word stress, if no annotation */ | |||
| set_pitch(ix,pitch,drops[stress]); | |||
| set_pitch(syl,pitch,drops[stress]); | |||
| } | |||
| else | |||
| { | |||
| /* unstressed, drop pitch if preceded by PRIMARY */ | |||
| if((vowel_tab[ix-1] & 0x3f) >= SECONDARY) | |||
| set_pitch(ix,pitch - (t->body_lower_u << 8), drops[stress]); | |||
| if((syllable_tab[ix-1].stress & 0x3f) >= SECONDARY) | |||
| set_pitch(syl,pitch - (t->body_lower_u << 8), drops[stress]); | |||
| else | |||
| set_pitch(ix,pitch,drops[stress]); | |||
| set_pitch(syl,pitch,drops[stress]); | |||
| } | |||
| ix++; | |||
| @@ -562,6 +566,8 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_TABLE *t, int min_stress) | |||
| static int calc_pitch_segment2(int ix, int end_ix, int start_p, int end_p, int min_stress) | |||
| /****************************************************************************************/ | |||
| /* Linear pitch rise/fall, change pitch at min_stress or stronger | |||
| @@ -572,6 +578,7 @@ static int calc_pitch_segment2(int ix, int end_ix, int start_p, int end_p, int m | |||
| int increment; | |||
| int n_increments; | |||
| int drop; | |||
| SYLLABLE *syl; | |||
| if(ix >= end_ix) | |||
| return(ix); | |||
| @@ -588,11 +595,12 @@ static int calc_pitch_segment2(int ix, int end_ix, int start_p, int end_p, int m | |||
| pitch = start_p << 8; | |||
| while(ix < end_ix) | |||
| { | |||
| stress = vowel_tab[ix] & 0x3f; | |||
| syl = &syllable_tab[ix]; | |||
| stress = syl->stress; | |||
| if(increment > 0) | |||
| { | |||
| set_pitch(ix,pitch,-increment); | |||
| set_pitch(syl,pitch,-increment); | |||
| pitch += increment; | |||
| } | |||
| else | |||
| @@ -602,7 +610,7 @@ static int calc_pitch_segment2(int ix, int end_ix, int start_p, int end_p, int m | |||
| drop = min_drop[stress]; | |||
| pitch += increment; | |||
| set_pitch(ix,pitch,drop); | |||
| set_pitch(syl,pitch,drop); | |||
| } | |||
| ix++; | |||
| @@ -615,32 +623,40 @@ static int calc_pitch_segment2(int ix, int end_ix, int start_p, int end_p, int m | |||
| static int calc_pitches(int *syllable_tab, int num, int sentence_tone) | |||
| /********************************************************************/ | |||
| static int calc_pitches(int start, int end, int group_tone) | |||
| /**********************************************************/ | |||
| /* Calculate pitch values for the vowels in this tone group */ | |||
| { | |||
| int ix; | |||
| TONE_TABLE *t; | |||
| int drop; | |||
| int continuing = 0; | |||
| if(start > 0) | |||
| continuing = 1; | |||
| t = &tone_table[tone_type]; | |||
| ix = vowel_ix; | |||
| t = &tone_table[group_tone]; | |||
| ix = start; | |||
| /* vowels before the first primary stress */ | |||
| /******************************************/ | |||
| if(number_pre > 0) | |||
| { | |||
| ix = calc_pitch_segment2(ix,ix+number_pre,t->pre_start,t->pre_end, 0); | |||
| ix = calc_pitch_segment2(ix, ix+number_pre, t->pre_start, t->pre_end, 0); | |||
| } | |||
| /* body of tonic segment */ | |||
| /*************************/ | |||
| if(annotation) | |||
| ix = calc_pitch_segment(ix,tone_posn, t, PRIMARY_MARKED); | |||
| else | |||
| ix = calc_pitch_segment(ix,tone_posn, t, PRIMARY); | |||
| if(option_tone2 & 1) | |||
| { | |||
| static int count=0; | |||
| count++; | |||
| //if(count & 1) | |||
| tone_posn = tone_posn2; // TEST put tone on the penultimate stressed word | |||
| } | |||
| ix = calc_pitch_segment(ix,tone_posn, t, PRIMARY, continuing); | |||
| if(no_tonic) | |||
| return(0); | |||
| @@ -652,20 +668,23 @@ static int calc_pitches(int *syllable_tab, int num, int sentence_tone) | |||
| { | |||
| tone_pitch_env = t->pitch_env0; | |||
| drop = t->tonic_max0 - t->tonic_min0; | |||
| set_pitch(ix++,t->tonic_min0 << 8,drop << 8); | |||
| set_pitch(&syllable_tab[ix++],t->tonic_min0 << 8,drop << 8); | |||
| } | |||
| else | |||
| { | |||
| tone_pitch_env = t->pitch_env1; | |||
| drop = t->tonic_max1 - t->tonic_min1; | |||
| set_pitch(ix++,t->tonic_min1 << 8,drop << 8); | |||
| set_pitch(&syllable_tab[ix++],t->tonic_min1 << 8,drop << 8); | |||
| } | |||
| syllable_tab[tone_posn].env = tone_pitch_env; | |||
| if(syllable_tab[tone_posn].stress == PRIMARY) | |||
| syllable_tab[tone_posn].stress = PRIMARY_STRESSED; | |||
| /* tail, after the tonic syllable */ | |||
| /**********************************/ | |||
| calc_pitch_segment2(ix,vowel_ix_top,t->tail_start,t->tail_end,0); | |||
| calc_pitch_segment2(ix, end, t->tail_start, t->tail_end, 0); | |||
| return(tone_pitch_env); | |||
| } /* end of calc_pitches */ | |||
| @@ -674,129 +693,6 @@ static int calc_pitches(int *syllable_tab, int num, int sentence_tone) | |||
| static int calc_pitch_segmentX(int ix, int end_ix, TONE_TABLE *t, int min_stress) | |||
| /******************************************************************************/ | |||
| /* Calculate pitches until next RESET or tonic syllable, or end. | |||
| Increment pitch if stress is >= min_stress. | |||
| Used for tonic segment */ | |||
| // EXPERIMENTAL VERSION | |||
| { | |||
| int stress; | |||
| int pitch=0; | |||
| int n_primary; | |||
| int initial; | |||
| int *drops; | |||
| int prev_stress=0; | |||
| int n_unstressed; | |||
| int j; | |||
| drops = t->body_drops; // pitch fall or raise for each stress value | |||
| n_primary = count_increments(ix,end_ix,min_stress)-1; // number if primary stress in the clause -1 | |||
| initial = 1; | |||
| while(ix < end_ix) // for each syllable | |||
| { | |||
| for(j=ix; j<end_ix; j++) | |||
| { | |||
| // how many unstressed syllables before the next primary stress ? | |||
| if((vowel_tab[j] & 0x3f) > SECONDARY) | |||
| break; | |||
| } | |||
| n_unstressed = (j - ix - 1); | |||
| stress = vowel_tab[ix] & 0x3f; // stress value of this syllable | |||
| pitch = 0x1000; // set a base pitch | |||
| pitch += ((n_primary % 3) * 0x0500); // some variety. add an offset that changes after each primary stress | |||
| if(stress >= PRIMARY) | |||
| { | |||
| vowel_tab[ix] = PRIMARY_MARKED; | |||
| set_pitch(ix,pitch+0x100, -0x0900); | |||
| n_primary--; | |||
| } | |||
| // else | |||
| // if(stress >= SECONDARY) | |||
| // { | |||
| // set_pitch(ix,pitch,drops[stress]); | |||
| // } | |||
| else | |||
| { | |||
| if(ix > 0) | |||
| prev_stress = vowel_tab[ix-1] & 0x3f; // stress level of previous syllable | |||
| if(prev_stress >= PRIMARY) | |||
| { | |||
| // an unstressed syllable which follows a primary stress syllable | |||
| set_pitch(ix,pitch+0x0200, 0x0800); | |||
| } | |||
| else | |||
| { | |||
| stress = 0; // treat secondary stress the same as unstressed ?? | |||
| set_pitch(ix,pitch + n_unstressed*0x300, drops[stress]); | |||
| } | |||
| n_unstressed--; | |||
| } | |||
| ix++; | |||
| } | |||
| return(ix); | |||
| } /* end of calc_pitch_segmentX */ | |||
| static int calc_pitchesX(int *syllable_tab, int num, int sentence_tone) | |||
| /********************************************************************/ | |||
| /* Calculate pitch values for the vowels in this tone group */ | |||
| // EXPERMENTAL VERSION of calc_pitches() | |||
| { | |||
| int ix; | |||
| TONE_TABLE *t; | |||
| int drop; | |||
| t = &tone_table[tone_type]; | |||
| ix = vowel_ix; | |||
| /* body of tonic segment */ | |||
| /*************************/ | |||
| if(annotation) | |||
| ix = calc_pitch_segmentX(ix,tone_posn, t, PRIMARY_MARKED); | |||
| else | |||
| ix = calc_pitch_segmentX(ix,tone_posn, t, PRIMARY); | |||
| if(no_tonic) | |||
| return(0); | |||
| /* tonic syllable */ | |||
| /******************/ | |||
| if(number_tail == 0) | |||
| { | |||
| tone_pitch_env = t->pitch_env0; | |||
| drop = t->tonic_max0 - t->tonic_min0; | |||
| set_pitch(ix++,t->tonic_min0 << 8,drop << 8); | |||
| } | |||
| else | |||
| { | |||
| tone_pitch_env = t->pitch_env1; | |||
| drop = t->tonic_max1 - t->tonic_min1; | |||
| set_pitch(ix++,t->tonic_min1 << 8,drop << 8); | |||
| } | |||
| /* tail, after the tonic syllable */ | |||
| /**********************************/ | |||
| calc_pitch_segment2(ix,vowel_ix_top,t->tail_start,t->tail_end,0); | |||
| return(tone_pitch_env); | |||
| } /* end of calc_pitchesX */ | |||
| void Translator::CalcPitches_Tone(int clause_tone) | |||
| {//=============================================== | |||
| @@ -958,124 +854,143 @@ void Translator::CalcPitches_Tone(int clause_tone) | |||
| p->pitch2 = pitch_adjust + phoneme_tab[tone_ph]->end_type; | |||
| } | |||
| } | |||
| } // end of Translator::CalcPitches_Tone | |||
| void Translator::CalcPitches(int clause_tone) | |||
| void Translator::CalcPitches(int clause_type) | |||
| {//========================================== | |||
| // clause_tone: 0=. 1=, 2=?, 3=! 4=none | |||
| // clause_type: 0=. 1=, 2=?, 3=! 4=none | |||
| PHONEME_LIST *p; | |||
| SYLLABLE *syl; | |||
| int ix; | |||
| int x; | |||
| int st_ix; | |||
| int tonic_ix=0; | |||
| int tonic_env; | |||
| int max_stress=0; | |||
| int n_st; | |||
| int option; | |||
| int st_ix_changed = -1; | |||
| int syllable_tab[N_PHONEME_LIST]; | |||
| int group_tone; | |||
| int group_tone_emph; | |||
| int ph_start=0; | |||
| int st_start; | |||
| int count; | |||
| int n_primary; | |||
| int count_primary; | |||
| int ph_end=n_phoneme_list; | |||
| if(langopts.intonation == 1) | |||
| { | |||
| CalcPitches_Tone(clause_tone); | |||
| CalcPitches_Tone(clause_type); | |||
| return; | |||
| } | |||
| st_ix=0; | |||
| p = &phoneme_list[0]; | |||
| for(ix=0; ix<n_phoneme_list; ix++, p++) | |||
| option = option_tone1 & 0xf; | |||
| if(option > 4) | |||
| option = 0; | |||
| group_tone_emph = group_tone = punct_to_tone[option][clause_type]; | |||
| group_tone_emph = punct_to_tone[option][3]; // emphatic form of statement | |||
| if(clause_type == 4) | |||
| no_tonic = 1; /* incomplete clause, used for abbreviations such as Mr. Dr. Mrs. */ | |||
| else | |||
| no_tonic = 0; | |||
| n_st = 0; | |||
| n_primary = 0; | |||
| for(ix=0; ix<n_phoneme_list; ix++) | |||
| { | |||
| p = &phoneme_list[ix]; | |||
| if(p->synthflags & SFLAG_SYLLABLE) | |||
| { | |||
| syllable_tab[st_ix] = p->tone; | |||
| if(option_tone2 == 1) | |||
| { | |||
| // reduce number of full-stress words | |||
| if((p->tone == 4) && ((st_ix % 2) != 1)) | |||
| { | |||
| syllable_tab[st_ix] = 3; | |||
| st_ix_changed = st_ix; | |||
| } | |||
| } | |||
| if(option_tone2 == 2) | |||
| { | |||
| // reduce all full-stress words, except last | |||
| if(p->tone == 4) | |||
| { | |||
| syllable_tab[st_ix] = 3; | |||
| st_ix_changed = st_ix; | |||
| } | |||
| } | |||
| syllable_tab[n_st].flags = 0; | |||
| syllable_tab[n_st++].stress = p->tone; // stress level | |||
| st_ix++; | |||
| if(p->tone >= max_stress) | |||
| { | |||
| max_stress = p->tone; | |||
| tonic_ix = ix; | |||
| } | |||
| if(p->tone >= 4) | |||
| n_primary++; | |||
| } | |||
| } | |||
| syllable_tab[n_st].stress = 0; // extra 0 entry at the end | |||
| if(st_ix_changed >= 0) | |||
| syllable_tab[st_ix_changed] = 4; | |||
| if(n_st == 0) | |||
| return; // nothing to do | |||
| if(st_ix == 0) | |||
| return; // no vowels, nothing to do | |||
| st_start = 0; | |||
| count_primary=0; | |||
| for(st_ix=0; st_ix<n_st; st_ix++) | |||
| { | |||
| syl = &syllable_tab[st_ix]; | |||
| if(syl->stress >= 4) | |||
| count_primary++; | |||
| option = option_tone1 & 0xf; | |||
| if(option > 4) | |||
| option = 0; | |||
| if((syl->stress == 6) && (syllable_tab[st_ix+1].stress == 6)) | |||
| { | |||
| syllable_tab[st_ix].flags = 2; | |||
| syl->stress = 4; | |||
| } | |||
| if(syl->stress == 6) | |||
| { | |||
| // an emphasized syllable, end the tone group after the next primary stress | |||
| syllable_tab[st_ix].flags = 2; | |||
| tone_type = punct_to_tone[option][clause_tone]; /* unless changed by count_pitch_vowels */ | |||
| count = 0; | |||
| if((n_primary - count_primary) > 1) | |||
| count =1; | |||
| if(clause_tone == 4) | |||
| no_tonic = 1; /* incomplete clause, used for abbreviations such as Mr. Dr. Mrs. */ | |||
| else | |||
| no_tonic = 0; | |||
| for(ix=st_ix+1; ix<n_st; ix++) | |||
| { | |||
| if(syllable_tab[ix].stress > 4) | |||
| break; | |||
| if(syllable_tab[ix].stress == 4) | |||
| { | |||
| count++; | |||
| if(count > 1) | |||
| break; | |||
| } | |||
| } | |||
| /* transfer vowel data from ph_list to syllable_tab */ | |||
| vowel_tab = syllable_tab; | |||
| vowel_ix_top = st_ix; | |||
| count_pitch_vowels(st_start, ix, n_st); | |||
| if((ix < n_st) || (clause_type == 0)) | |||
| calc_pitches(st_start, ix, group_tone_emph); // split into > 1 tone groups, use emphatic tone | |||
| else | |||
| calc_pitches(st_start, ix, group_tone); | |||
| count_pitch_vowels(); | |||
| st_start = ix; | |||
| } | |||
| } | |||
| if((option_tone1 & 0xf0)== 0x10) | |||
| tonic_env = calc_pitchesX(syllable_tab,st_ix,clause_tone); | |||
| else | |||
| tonic_env = calc_pitches(syllable_tab,st_ix,clause_tone); | |||
| if(st_start < st_ix) | |||
| { | |||
| count_pitch_vowels(st_start, st_ix, n_st); | |||
| calc_pitches(st_start, st_ix, group_tone); | |||
| } | |||
| // unpack pitch data | |||
| st_ix=0; | |||
| p = &phoneme_list[0]; | |||
| for(ix=0; ix<n_phoneme_list; ix++, p++) | |||
| for(ix=ph_start; ix < ph_end; ix++) | |||
| { | |||
| p->tone = syllable_tab[st_ix] & 0x3f; | |||
| p = &phoneme_list[ix]; | |||
| p->tone = syllable_tab[st_ix].stress; | |||
| if(p->synthflags & SFLAG_SYLLABLE) | |||
| { | |||
| x = ((syllable_tab[st_ix] >> 8) & 0x1ff) - 72; | |||
| syl = &syllable_tab[st_ix]; | |||
| x = syl->pitch1 - 72; | |||
| if(x < 0) x = 0; | |||
| p->pitch1 = x; | |||
| x = ((syllable_tab[st_ix] >> 17) & 0x1ff) - 72; | |||
| x = syl->pitch2 - 72; | |||
| if(x < 0) x = 0; | |||
| p->pitch2 = x; | |||
| p->env = PITCHfall; | |||
| if(syllable_tab[st_ix] & 0x80) | |||
| if(syl->flags & 1) | |||
| { | |||
| // if(p->pitch1 > p->pitch2) | |||
| // p->env = PITCHfall; | |||
| // else | |||
| p->env = PITCHrise; | |||
| p->env = PITCHrise; | |||
| } | |||
| if(p->pitch1 > p->pitch2) | |||
| { | |||
| // swap so that pitch2 is the higher | |||
| @@ -1083,10 +998,18 @@ void Translator::CalcPitches(int clause_tone) | |||
| p->pitch1 = p->pitch2; | |||
| p->pitch2 = x; | |||
| } | |||
| if(ix==tonic_ix) p->env = tonic_env; | |||
| if(p->tone > 5) | |||
| p->env = syl->env; | |||
| if(syl->flags & 2) | |||
| { | |||
| p->tone |= 8; // emphasized | |||
| } | |||
| st_ix++; | |||
| } | |||
| } | |||
| } // end of Translator::CalcPitches | |||
| @@ -1614,6 +1614,7 @@ int Translator::ReadClause(FILE *f_in, char *buf, unsigned short *charix, int n_ | |||
| int punct; | |||
| int any_alnum = 0; | |||
| int self_closing; | |||
| int punct_data; | |||
| const char *p; | |||
| char buf2[40]; | |||
| wchar_t xml_buf[N_XML_BUF+1]; | |||
| @@ -1946,9 +1947,14 @@ if(option_ssml) parag=1; | |||
| } | |||
| } | |||
| punct_data = punct_attributes[punct]; | |||
| if(nl_count > 1) | |||
| { | |||
| if((punct_data == CLAUSE_QUESTION) || (punct_data == CLAUSE_EXCLAMATION)) | |||
| return(punct_data + 35); // with a longer pause | |||
| return(CLAUSE_PARAGRAPH); | |||
| return(punct_attributes[punct]); // only recognise punctuation if followed by a blank or bracket/quote | |||
| } | |||
| return(punct_data); // only recognise punctuation if followed by a blank or bracket/quote | |||
| } | |||
| } | |||
| @@ -269,13 +269,15 @@ void Translator::CalcLengths() | |||
| int end_of_clause; | |||
| int embedded_ix = 0; | |||
| int min_drop; | |||
| int emphasized; | |||
| unsigned char *pitch_env=NULL; | |||
| for(ix=1; ix<n_phoneme_list; ix++) | |||
| { | |||
| prev = &phoneme_list[ix-1]; | |||
| p = &phoneme_list[ix]; | |||
| stress = p->tone & 0xf; | |||
| stress = p->tone & 0x7; | |||
| emphasized = p->tone & 0x8; | |||
| next = &phoneme_list[ix+1]; | |||
| @@ -444,6 +446,9 @@ void Translator::CalcLengths() | |||
| else | |||
| p->amp = stress_amps[stress]; | |||
| if(emphasized) | |||
| p->amp = 25; | |||
| if(ix >= (n_phoneme_list-3)) | |||
| { | |||
| // last phoneme of a clause, limit its amplitude | |||
| @@ -499,11 +504,16 @@ void Translator::CalcLengths() | |||
| if(length_mod < 8) | |||
| length_mod = 8; // restrict how much lengths can be reduced | |||
| if(stress >= 6) | |||
| if(stress >= 7) | |||
| { | |||
| // tonic syllable, include a constant component so it doesn't decrease directly with speed | |||
| length_mod += 20; | |||
| } | |||
| else | |||
| if(emphasized) | |||
| { | |||
| length_mod += 20; | |||
| } | |||
| if((len = stress_lengths[stress]) == 0) | |||
| len = stress_lengths[6]; | |||
| @@ -542,8 +552,8 @@ if(p->type != phVOWEL) | |||
| if(pre_sonorant || pre_voiced) | |||
| { | |||
| // set pitch for pre-vocalic part | |||
| if(pitch_start - last_pitch > 9) | |||
| last_pitch = pitch_start - 9; | |||
| if(pitch_start - last_pitch > 8) // was 9 | |||
| last_pitch = pitch_start - 8; | |||
| prev->pitch1 = last_pitch; | |||
| prev->pitch2 = pitch_start; | |||
| if(last_pitch < pitch_start) | |||
| @@ -630,11 +630,6 @@ int main (int argc, char **argv) | |||
| exit(1); | |||
| } | |||
| { | |||
| espeak_VOICE *v; | |||
| v = espeak_GetCurrentVoice(); | |||
| printf("Voice id='%s' name='%s' langs={%x %x %x %x}\n",v->identifier,v->name,v->languages[0],v->languages[1],v->languages[2],v->languages[3]); | |||
| } | |||
| if(option_waveout || quiet) | |||
| { | |||
| if(quiet) | |||
| @@ -35,7 +35,7 @@ | |||
| #include "translate.h" | |||
| #include "wave.h" | |||
| const char *version_string = "1.29.24 12.Dec.07"; | |||
| const char *version_string = "1.29.25 14.Dec.07"; | |||
| const int version_phdata = 0x012924; | |||
| int option_device_number = -1; | |||
| @@ -37,7 +37,7 @@ | |||
| Translator_English::Translator_English() : Translator() | |||
| {//=================================== | |||
| // static int stress_lengths2[8] = {182,140, 220,220, 220,240, 248,270}; | |||
| static const short stress_lengths2[8] = {182,140, 220,220, 248,248, 275,275}; | |||
| static const short stress_lengths2[8] = {182,140, 220,220, 0,0, 248,275}; | |||
| memcpy(stress_lengths,stress_lengths2,sizeof(stress_lengths)); | |||
| langopts.stress_rule = 0; | |||
| @@ -111,8 +111,8 @@ Translator *SelectTranslator(const char *name) | |||
| case L('c','y'): // Welsh | |||
| { | |||
| static const short stress_lengths_cy[8] = {170,230, 190,190, 250, 250, 270,270}; | |||
| static const unsigned char stress_amps_cy[8] = {16,15, 18,18, 20,24, 24,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable | |||
| static const short stress_lengths_cy[8] = {170,230, 190,190, 0, 0, 250,270}; | |||
| static const unsigned char stress_amps_cy[8] = {16,15, 18,18, 0,0, 24,22 }; // 'diminished' is used to mark a quieter, final unstressed syllable | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_cy,stress_amps_cy); | |||
| @@ -136,7 +136,7 @@ Translator *SelectTranslator(const char *name) | |||
| case L('d','e'): | |||
| { | |||
| static const short stress_lengths_de[8] = {150,130, 190,190, 260, 260, 275,275}; | |||
| static const short stress_lengths_de[8] = {150,130, 190,190, 0, 0, 260,275}; | |||
| tr = new Translator(); | |||
| tr->langopts.stress_rule = 0; | |||
| tr->langopts.word_gap = 0x8; // don't use linking phonemes | |||
| @@ -156,8 +156,8 @@ Translator *SelectTranslator(const char *name) | |||
| case L('e','l'): // Greek | |||
| case L_grc: // Ancient Greek | |||
| { | |||
| static const short stress_lengths_el[8] = {155, 180, 210, 210, 270, 270, 300, 300}; | |||
| static const unsigned char stress_amps_el[8] = {15,12, 20,20, 20,24, 24,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable | |||
| static const short stress_lengths_el[8] = {155, 180, 210, 210, 0, 0, 270, 300}; | |||
| static const unsigned char stress_amps_el[8] = {15,12, 20,20, 20,24, 24,22 }; // 'diminished' is used to mark a quieter, final unstressed syllable | |||
| // character codes offset by 0x380 | |||
| static const char el_vowels[] = {0x10,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x35,0x37,0x39,0x3f,0x45,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0}; | |||
| @@ -199,8 +199,8 @@ Translator *SelectTranslator(const char *name) | |||
| case L('e','o'): | |||
| { | |||
| static const short stress_lengths_eo[8] = {145, 180, 200, 190, 300, 300, 320, 320}; | |||
| static const unsigned char stress_amps_eo[] = {16,14, 20,20, 20,24, 24,21 }; | |||
| static const short stress_lengths_eo[8] = {145, 180, 200, 190, 0, 0, 300, 320}; | |||
| static const unsigned char stress_amps_eo[] = {16,14, 20,20, 20,24, 24,22 }; | |||
| static const wchar_t eo_char_apostrophe[2] = {'l',0}; | |||
| tr = new Translator(); | |||
| @@ -222,8 +222,8 @@ Translator *SelectTranslator(const char *name) | |||
| case L('e','s'): // Spanish | |||
| { | |||
| static const short stress_lengths_es[8] = {170, 200, 180, 180, 220, 220, 250, 250}; | |||
| static const unsigned char stress_amps_es[8] = {16,12, 18,18, 20,22, 22,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable | |||
| static const short stress_lengths_es[8] = {170, 200, 180, 180, 0, 0, 220, 250}; | |||
| static const unsigned char stress_amps_es[8] = {16,12, 18,18, 20,22, 22,22 }; // 'diminished' is used to mark a quieter, final unstressed syllable | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_es,stress_amps_es); | |||
| @@ -245,8 +245,8 @@ Translator *SelectTranslator(const char *name) | |||
| case L('f','i'): // Finnish | |||
| { | |||
| static const short stress_lengths_fi[8] = {150,170, 200,200, 210,210, 250,240}; | |||
| static const unsigned char stress_amps_fi[8] = {18,16, 22,22, 20,22, 22,21 }; | |||
| static const unsigned char stress_amps_fi[8] = {18,16, 22,22, 20,22, 22,22 }; | |||
| static const short stress_lengths_fi[8] = {150,170, 200,200, 0,0, 210,250}; | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_fi,stress_amps_fi); | |||
| @@ -267,7 +267,7 @@ Translator *SelectTranslator(const char *name) | |||
| case L('f','r'): // french | |||
| { | |||
| static const short stress_lengths_fr[8] = {190, 170, 190, 200, 235, 235, 235, 235}; | |||
| static const short stress_lengths_fr[8] = {190, 170, 190, 200, 0, 0, 235, 235}; | |||
| static const unsigned char stress_amps_fr[8] = {16,14, 20,20, 20,24, 24,22 }; | |||
| tr = new Translator(); | |||
| @@ -284,8 +284,8 @@ Translator *SelectTranslator(const char *name) | |||
| case L('h','i'): | |||
| { | |||
| static const char dev_consonants2[] = {0x02,0x03,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f}; | |||
| static const short stress_lengths_hi[8] = {190, 190, 210, 210, 230, 230, 250, 250}; | |||
| static const unsigned char stress_amps_hi[8] = {17,14, 20,19, 20,24, 24,21 }; | |||
| static const short stress_lengths_hi[8] = {190, 190, 210, 210, 0, 0, 230, 250}; | |||
| static const unsigned char stress_amps_hi[8] = {17,14, 20,19, 20,24, 24,22 }; | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_hi,stress_amps_hi); | |||
| @@ -312,8 +312,8 @@ Translator *SelectTranslator(const char *name) | |||
| case L('b','s'): // Bosnian | |||
| case L('s','r'): // Serbian | |||
| { | |||
| static const unsigned char stress_amps_hr[8] = {16,16, 20,20, 20,24, 24,21 }; | |||
| static const short stress_lengths_hr[8] = {180,160, 200,200, 220,220, 230,230}; | |||
| static const unsigned char stress_amps_hr[8] = {16,16, 20,20, 20,24, 24,22 }; | |||
| static const short stress_lengths_hr[8] = {180,160, 200,200, 0,0, 220,230}; | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_hr,stress_amps_hr); | |||
| @@ -337,8 +337,8 @@ Translator *SelectTranslator(const char *name) | |||
| case L('h','u'): // Hungarian | |||
| { | |||
| static const unsigned char stress_amps_hu[8] = {17,17, 19,19, 20,24, 24,21 }; | |||
| static const short stress_lengths_hu[8] = {185,195, 195,190, 210,210, 220,220}; | |||
| static const unsigned char stress_amps_hu[8] = {17,17, 19,19, 20,24, 24,22 }; | |||
| static const short stress_lengths_hu[8] = {185,195, 195,190, 0,0, 210,220}; | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_hu,stress_amps_hu); | |||
| @@ -361,8 +361,8 @@ SetLengthMods(tr,3); // all equal | |||
| case L('i','s'): // Icelandic | |||
| { | |||
| static const unsigned char stress_amps_is[] = {16,16, 20,20, 20,24, 24,21 }; | |||
| static const short stress_lengths_is[8] = {180,160, 200,200, 240,240, 250,250}; | |||
| static const unsigned char stress_amps_is[] = {16,16, 20,20, 20,24, 24,22 }; | |||
| static const short stress_lengths_is[8] = {180,160, 200,200, 0,0, 240,250}; | |||
| static const wchar_t is_lettergroup_B[] = {'c','f','h','k','p','t','x',0xfe,0}; // voiceless conants, including 'þ' ?? 's' | |||
| tr = new Translator(); | |||
| @@ -384,8 +384,8 @@ SetLengthMods(tr,3); // all equal | |||
| case L('i','t'): // Italian | |||
| { | |||
| static const short stress_lengths_it[8] = {150, 140, 180, 180, 270, 270, 320, 320}; | |||
| static const unsigned char stress_amps_it[8] = {15,14, 19,19, 20,24, 24,21 }; | |||
| static const short stress_lengths_it[8] = {150, 140, 180, 180, 0, 0, 270, 320}; | |||
| static const unsigned char stress_amps_it[8] = {15,14, 19,19, 20,24, 24,22 }; | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_it,stress_amps_it); | |||
| @@ -421,8 +421,8 @@ SetLengthMods(tr,3); // all equal | |||
| { | |||
| static wchar_t vowels_cyrillic[] = {0x440, // also include 'р' [R] | |||
| 0x430,0x435,0x438,0x439,0x43e,0x443,0x44b,0x44d,0x44e,0x44f,0x450,0x451,0x456,0x457,0x45d,0x45e,0}; | |||
| static const unsigned char stress_amps_mk[8] = {16,16, 20,20, 20,24, 24,21 }; | |||
| static const short stress_lengths_mk[8] = {180,160, 200,200, 220,220, 230,230}; | |||
| static const unsigned char stress_amps_mk[8] = {16,16, 20,20, 20,24, 24,22 }; | |||
| static const short stress_lengths_mk[8] = {180,160, 200,200, 0,0, 220,230}; | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_mk,stress_amps_mk); | |||
| @@ -438,7 +438,7 @@ SetLengthMods(tr,3); // all equal | |||
| case L('n','l'): // Dutch | |||
| { | |||
| static const short stress_lengths_nl[8] = {160,135, 210,210, 260, 260, 280,280}; | |||
| static const short stress_lengths_nl[8] = {160,135, 210,210, 0, 0, 260,280}; | |||
| tr = new Translator(); | |||
| tr->langopts.stress_rule = 0; | |||
| @@ -454,8 +454,8 @@ SetLengthMods(tr,3); // all equal | |||
| case L('n','o'): // Norwegian | |||
| { | |||
| static const short stress_lengths_no[8] = {160,140, 200,190, 220,220, 240,240}; | |||
| static const unsigned char stress_amps_no[] = {16,16, 20,20, 20,24, 24,21 }; | |||
| static const unsigned char stress_amps_no[] = {16,16, 20,20, 20,24, 24,22 }; | |||
| static const short stress_lengths_no[8] = {160,140, 200,190, 0,0, 220,240}; | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_no,stress_amps_no); | |||
| @@ -467,8 +467,8 @@ SetLengthMods(tr,3); // all equal | |||
| case L('p','l'): // Polish | |||
| { | |||
| static const short stress_lengths_pl[8] = {160, 180, 175, 175, 260, 260, 290, 290}; | |||
| static const unsigned char stress_amps_pl[8] = {17,14, 19,19, 20,24, 24,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable | |||
| static const short stress_lengths_pl[8] = {160, 180, 175, 175, 0, 0, 260, 290}; | |||
| static const unsigned char stress_amps_pl[8] = {17,14, 19,19, 20,24, 24,22 }; // 'diminished' is used to mark a quieter, final unstressed syllable | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_pl,stress_amps_pl); | |||
| @@ -487,8 +487,8 @@ SetLengthMods(tr,3); // all equal | |||
| case L('p','t'): // Portuguese | |||
| { | |||
| static const short stress_lengths_pt[8] = {180, 125, 210, 210, 270, 270, 295, 295}; | |||
| static const unsigned char stress_amps_pt[8] = {16,13, 19,19, 20,24, 24,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable | |||
| static const short stress_lengths_pt[8] = {180, 125, 210, 210, 0, 0, 270, 295}; | |||
| static const unsigned char stress_amps_pt[8] = {16,13, 19,19, 20,24, 24,22 }; // 'diminished' is used to mark a quieter, final unstressed syllable | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_pt,stress_amps_pt); | |||
| tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable | |||
| @@ -504,8 +504,8 @@ SetLengthMods(tr,3); // all equal | |||
| case L('r','o'): // Romanian | |||
| { | |||
| static const short stress_lengths_ro[8] = {170, 170, 180, 180, 240, 240, 260, 260}; | |||
| static const unsigned char stress_amps_ro[8] = {15,13, 18,18, 20,22, 22,21 }; | |||
| static const short stress_lengths_ro[8] = {170, 170, 180, 180, 0, 0, 240, 260}; | |||
| static const unsigned char stress_amps_ro[8] = {15,13, 18,18, 20,22, 22,22 }; | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_ro,stress_amps_ro); | |||
| @@ -526,8 +526,8 @@ SetLengthMods(tr,3); // all equal | |||
| case L('s','k'): // Slovak | |||
| case L('c','s'): // Czech | |||
| { | |||
| static const short stress_lengths_sk[8] = {190,190, 210,210, 210,210, 210,210}; | |||
| static const unsigned char stress_amps_sk[8] = {16,16, 20,20, 20,24, 24,22 }; | |||
| static const short stress_lengths_sk[8] = {190,190, 210,210, 0,0, 210,210}; | |||
| static const char *sk_voiced = "bdgjlmnrvwzaeiouy"; | |||
| tr = new Translator(); | |||
| @@ -560,20 +560,21 @@ SetLengthMods(tr,3); // all equal | |||
| case L('s','v'): // Swedish | |||
| { | |||
| static const short stress_lengths_sv[8] = {160,135, 220,220, 250,250, 250,280}; | |||
| static const unsigned char stress_amps_sv[] = {16,16, 20,20, 20,24, 24,22 }; | |||
| static const short stress_lengths_sv[8] = {160,135, 220,220, 0,0, 250,280}; | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_sv,stress_amps_sv); | |||
| tr->langopts.stress_rule = 0; | |||
| SetLetterVowel(tr,'y'); | |||
| // SetLetterBits(tr,6,"eiyäö"); // soft vowels NOTE accented letters don't work in SetLetterBits | |||
| tr->langopts.numbers = 0x1109; | |||
| } | |||
| break; | |||
| case L('s','w'): // Swahili | |||
| { | |||
| static const short stress_lengths_sw[8] = {150, 160, 190, 190, 300, 300, 320, 320}; | |||
| static const short stress_lengths_sw[8] = {160, 170, 200, 200, 0, 0, 320, 340}; | |||
| static const unsigned char stress_amps_sw[] = {16,12, 19,19, 20,24, 24,22 }; | |||
| tr = new Translator(); | |||
| @@ -591,8 +592,8 @@ SetLengthMods(tr,3); // all equal | |||
| case L('t','r'): // Turkish | |||
| { | |||
| static const short stress_lengths_tr[8] = {180,150, 200,180, 230,230, 270,270}; | |||
| static const unsigned char stress_amps_tr[8] = {16,16, 20,20, 20,24, 24,21 }; | |||
| static const unsigned char stress_amps_tr[8] = {16,16, 20,20, 20,24, 24,22 }; | |||
| static const short stress_lengths_tr[8] = {180,150, 200,180, 0,0, 230,270}; | |||
| tr = new Translator(); | |||
| SetupTranslator(tr,stress_lengths_tr,stress_amps_tr); | |||
| @@ -607,7 +608,7 @@ SetLengthMods(tr,3); // all equal | |||
| case L('v','i'): // Vietnamese | |||
| { | |||
| static const short stress_lengths_vi[8] = {150, 150, 180, 180, 220, 220, 280, 280}; | |||
| static const short stress_lengths_vi[8] = {150, 150, 180, 180, 210, 220, 220, 280}; | |||
| static const unsigned char stress_amps_vi[] = {16,16, 16,16, 24,24, 24,22 }; | |||
| static wchar_t vowels_vi[] = { | |||
| 0x61, 0xe0, 0xe1, 0x1ea3, 0xe3, 0x1ea1, // a | |||
| @@ -641,7 +642,7 @@ SetLengthMods(tr,3); // all equal | |||
| case L('z','h'): | |||
| case L_zhy: | |||
| { | |||
| static const short stress_lengths_zh[8] = {230,150, 230,230, 230,230, 250,250}; | |||
| static const short stress_lengths_zh[8] = {230,150, 230,230, 230,0, 230,250}; | |||
| static const unsigned char stress_amps_zh[] = {22,16, 22,22, 22,22, 22,22 }; | |||
| tr = new Translator; | |||
| @@ -690,8 +691,8 @@ SetLengthMods(tr,3); // all equal | |||
| Translator_Russian::Translator_Russian() : Translator() | |||
| {//=================================== | |||
| static const short stress_lengths_ru[8] = {150,140, 220,220, 260,260, 280,280}; | |||
| static const unsigned char stress_amps_ru[] = {16,16, 18,18, 20,24, 24,22 }; | |||
| static const short stress_lengths_ru[8] = {150,140, 220,220, 0,0, 260,280}; | |||
| // character codes offset by 0x420 | |||
| @@ -944,7 +945,7 @@ Translator_Afrikaans::Translator_Afrikaans() : Translator() | |||
| {//========================================= | |||
| // Initialise options for this language | |||
| static const short stress_lengths2[8] = {170,140, 220,220, 250, 250, 270,270}; | |||
| static const short stress_lengths2[8] = {170,140, 220,220, 0, 0, 250,270}; | |||
| langopts.stress_rule = 0; | |||
| langopts.vowel_pause = 0x30; | |||
| langopts.param[LOPT_DIERESES] = 1; | |||
| @@ -53,7 +53,6 @@ int option_punctuation = 0; | |||
| int option_sayas = 0; | |||
| int option_sayas2 = 0; // used in translate_clause() | |||
| int option_emphasis = 0; // 0=normal, 1=normal, 2=weak, 3=moderate, 4=strong | |||
| int word_emphasis = 0; // set if emphasis level 3 or 4 | |||
| int option_emphasize_allcaps = 0; | |||
| int option_ssml = 0; | |||
| int option_phoneme_input = 1; // allow [[phonemes]] in input | |||
| @@ -71,6 +70,7 @@ int count_words; | |||
| int clause_start_char; | |||
| int clause_start_word; | |||
| int new_sentence; | |||
| int word_emphasis = 0; // set if emphasis level 3 or 4 | |||
| int prev_clause_pause=0; | |||
| int max_clause_pause = 0; | |||
| @@ -341,11 +341,10 @@ unsigned char *length_mod_tabs[6] = { | |||
| /* index by 0=. 1=, 2=?, 3=! 4=none */ | |||
| static unsigned char punctuation_to_tone[4][5] = { | |||
| {0,1,1,2,0}, | |||
| {3,4,4,5,3}, | |||
| {6,7,7,8,6}, | |||
| {9,10,10,11,9} }; | |||
| {0,1,2,3,0}, | |||
| {0,1,2,3,0}, | |||
| {0,1,2,3,0}, | |||
| {0,1,2,3,0} }; | |||
| void SetLengthMods(Translator *tr, int value) | |||
| @@ -396,7 +395,7 @@ Translator::Translator() | |||
| {//===================== | |||
| int ix; | |||
| static const unsigned char stress_amps2[] = {16,16, 20,20, 20,24, 24,21 }; | |||
| static const short stress_lengths2[8] = {182,140, 220,220, 250,260, 280,280}; | |||
| static const short stress_lengths2[8] = {182,140, 220,220, 220,240, 260,280}; | |||
| static const wchar_t empty_wstring[1] = {0}; | |||
| charset_a0 = charsets[1]; // ISO-8859-1, this is for when the input is not utf8 | |||
| @@ -452,7 +451,7 @@ Translator::Translator() | |||
| langopts.decimal_sep = '.'; | |||
| memcpy(punct_to_tone,punctuation_to_tone,sizeof(punct_to_tone)); | |||
| punct_to_tone[0][3] = 0; // exclamation, use period until we can improve the exclamation intonation | |||
| // punct_to_tone[0][3] = 0; // exclamation, use period until we can improve the exclamation intonation | |||
| } | |||
| @@ -1025,10 +1024,9 @@ strcpy(phonemes2,phonemes); | |||
| if(wflags & FLAG_EMPHASIZED) | |||
| { | |||
| // A word is indicated in the source text as stressed | |||
| // we need to improve the intonation module to deal better with a clauses tonic | |||
| // stress being early in the clause, before enabling this | |||
| // Give it stress level 6 (for the intonation module) | |||
| ChangeWordStress(this,word_phonemes,6); | |||
| dictionary_flags[0] |= FLAG_PAUSE1; // precede by short pause | |||
| } | |||
| else | |||
| if(wtab[dictionary_skipwords].flags & FLAG_LAST_WORD) | |||
| @@ -1350,8 +1348,8 @@ int Translator::TranslateWord2(char *word, WORD_TAB *wtab, int pre_pause, int ne | |||
| } | |||
| } | |||
| if((option_emphasis >= 3) && (pre_pause < 2)) | |||
| pre_pause = 2; | |||
| if((option_emphasis >= 3) && (pre_pause < 1)) | |||
| pre_pause = 1; | |||
| } | |||
| plist2 = &ph_list2[n_ph_list2]; | |||
| @@ -232,32 +232,42 @@ extern const int param_defaults[N_SPEECH_PARAM]; | |||
| // 1=remove [:] from unstressed syllables, 2= remove from unstressed or non-penultimate syllables | |||
| // bit 4=0, if stress < 4, bit 4=1, if not the highest stress in the word | |||
| #define LOPT_IT_LENGTHEN 2 | |||
| // 1=german | |||
| #define LOPT_PREFIXES 3 | |||
| // non-zero, change voiced/unoiced to match last consonant in a cluster | |||
| // bit 1=LANG=ru, don't propagate over [v] | |||
| // bit 2=don't propagate acress word boundaries | |||
| // bit 3=LANG=pl, propagate over liquids and nasals | |||
| #define LOPT_REGRESSIVE_VOICING 4 | |||
| // 0=default, 1=no check, other allow this character as an extra initial letter (default is 's') | |||
| #define LOPT_UNPRONOUNCABLE 5 | |||
| // select length_mods tables, (length_mod_tab) + (length_mod_tab0 * 100) | |||
| #define LOPT_LENGTH_MODS 6 | |||
| // increase this to prevent sonorants being shortened before shortened (eg. unstressed) vowels | |||
| #define LOPT_SONORANT_MIN 7 | |||
| // bit 0=Italian "syntactic doubling" of consoants in the word after a word marked with $double attribute | |||
| // bit 1=also after a word which ends with a stressed vowel | |||
| #define LOPT_IT_DOUBLING 8 | |||
| // max. amplitude for vowel at the end of a clause | |||
| #define LOPT_MAXAMP_EOC 9 | |||
| // bit 0=reduce even if phonemes are specified in the **_list file | |||
| // bit 1=don't reduce the strongest vowel in a word which is marked 'unstressed' | |||
| #define LOPT_REDUCE 10 | |||
| // LANG=cs,sk combine some prepositions with the following word, if the combination has N or fewer syllables | |||
| // bits 0-3 N syllables | |||
| // bit 4=only if the second word has $alt attribute | |||
| // bit 5=not if the second word is end-of-sentence | |||
| #define LOPT_COMBINE_WORDS 11 | |||
| // change [t] when followed by unstressed vowel | |||
| #define LOPT_REDUCE_T 12 | |||
| @@ -329,7 +339,7 @@ typedef struct { | |||
| char spelling_stress; // 0=default, 1=stress first letter | |||
| char tone_numbers; | |||
| char ideographs; // treat as separate words | |||
| char textmode; // the meaning of FLAG_TEXTMODE is reversed | |||
| char textmode; // the meaning of FLAG_TEXTMODE is reversed (to save data when *_list file is compiled) | |||
| int testing; // testing options: bit 1= specify stressed syllable in the form: "outdoor/2" | |||
| const unsigned int *replace_chars; // characters to be substitutes | |||
| } LANGUAGE_OPTIONS; | |||
| @@ -1386,7 +1386,7 @@ char const *SelectVoice(espeak_VOICE *voice_select) | |||
| { | |||
| variant_name = ExtractVoiceVariantName(NULL,vp->variant); | |||
| sprintf(voice_id,"%s+%s",vp->identifier,&variant_name[3]); | |||
| return(variant_name); | |||
| return(voice_id); | |||
| } | |||
| return(vp->identifier); | |||
| @@ -787,7 +787,7 @@ int GetAmplitude(void) | |||
| int amp; | |||
| // normal, none, reduced, moderate, strong | |||
| static const unsigned char amp_emphasis[5] = {16, 16, 8, 16, 26}; | |||
| static const unsigned char amp_emphasis[5] = {16, 16, 10, 16, 22}; | |||
| amp = (embedded_value[EMBED_A])*60/100; | |||
| general_amplitude = amp * amp_emphasis[embedded_value[EMBED_F]] / 16; | |||