[1.41.32]

lang=hu, ordinal number fixes
--punct, changes to intonation of punctuation names.
Add language option: don't stress second part of hyphenated words.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@230 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2009-11-09 13:11:13 +00:00
parent 075bfe9006
commit f2eed5229e
51 changed files with 2553 additions and 1633 deletions
+1 -3
View File
@@ -568,12 +568,10 @@ step=1; // TEST
}
else
{
dict_line[length++] = 80 + multiple_words + multiple_numeric_hyphen; // if numeric, count a hyphen as an extra word
dict_line[length++] = 80 + multiple_words;
ix = multiple_string_end - multiple_string;
if(multiple_numeric_hyphen)
{
// the first part is numeric, so keep the hyphen to match on
dict_line[length++] = '-';
dict_line[length++] = ' ';
}
memcpy(&dict_line[length],multiple_string,ix);
+1 -1
View File
@@ -13,7 +13,7 @@ extern void debug_time(const char* text);
#else
#ifdef PLATFORM_WINDOWS
#ifdef NO_VARIADIC_MACROS
#define SHOW(format) // VC6 doesn't allow "..."
#else
#define SHOW(format,...)
+21 -10
View File
@@ -1030,7 +1030,7 @@ void ChangeWordStress(Translator *tr, char *word, int new_stress)
void SetWordStress(Translator *tr, char *output, unsigned int &dictionary_flags, int tonic, int prev_stress)
void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int prev_stress)
{//=========================================================================================================
/* Guess stress pattern of word. This is language specific
@@ -1099,11 +1099,11 @@ void SetWordStress(Translator *tr, char *output, unsigned int &dictionary_flags,
max_output = output + (N_WORD_PHONEMES-3); /* check for overrun */
// any stress position marked in the xx_list dictionary ?
stressed_syllable = dictionary_flags & 0x7;
if(dictionary_flags & 0x8)
stressed_syllable = dictionary_flags[0] & 0x7;
if(dictionary_flags[0] & 0x8)
{
// this indicates a word without a primary stress
stressed_syllable = dictionary_flags & 0x3;
stressed_syllable = dictionary_flags[0] & 0x3;
unstressed_word = 1;
}
@@ -1113,7 +1113,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int &dictionary_flags,
{
// option: don't stress monosyllables except at end-of-clause
vowel_stress[1] = 1;
dictionary_flags |= FLAG_STRESS_END2;
dictionary_flags[0] |= FLAG_STRESS_END2;
}
// heavy or light syllables
@@ -1350,7 +1350,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int &dictionary_flags,
}
break;
case 7: // LANG=tr, the last syllable for any vowel markes explicitly as unstressed
case 7: // LANG=tr, the last syllable for any vowel marked explicitly as unstressed
if(stressed_syllable == 0)
{
stressed_syllable = vowel_count - 1;
@@ -2575,10 +2575,15 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
#endif
// is it a bracket ?
if(letter == 0xe000+'(')
{
if(pre_pause < tr->langopts.param2[LOPT_BRACKET_PAUSE])
pre_pause = tr->langopts.param2[LOPT_BRACKET_PAUSE]; // a bracket, aleady spoken by AnnouncePunctuation()
}
if(IsBracket(letter))
{
if(pre_pause < 4)
pre_pause = 4;
if(pre_pause < tr->langopts.param[LOPT_BRACKET_PAUSE])
pre_pause = tr->langopts.param[LOPT_BRACKET_PAUSE];
}
// no match, try removing the accent and re-translating the word
@@ -3162,6 +3167,12 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
continue;
}
}
if(dictionary_flags & FLAG_ALT2_TRANS)
{
// language specific
if((tr->translator_name == L('h','u')) && !(tr->prev_dict_flags & FLAG_ALT_TRANS))
continue;
}
if(flags != NULL)
{
@@ -3256,7 +3267,7 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
// set the skip words flag
flags[0] |= FLAG_SKIPWORDS;
dictionary_skipwords = length;
return(1);
return(flags[0]);
}
}
@@ -3356,7 +3367,7 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
return(0);
}
return(1);
return(flags[0]);
}
ph_out[0] = 0;
+92 -19
View File
@@ -20,7 +20,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef NEED_GETOPT
#include <getopt.h>
#endif
#include <time.h>
#include <sys/stat.h>
@@ -294,6 +296,21 @@ static int SynthCallback(short *wav, int numsamples, espeak_EVENT *events)
}
#ifdef NEED_GETOPT
struct option {
char *name;
int has_arg;
int *flag;
int val;
};
int optind;
static int optional_argument;
static const char *arg_opts = "abfgklpsvw"; // which options have arguments
static char *opt_string="";
#define no_argument 0
#define required_argument 1
#define optional_argument 2
#endif
int main (int argc, char **argv)
//==============================
@@ -330,6 +347,7 @@ int main (int argc, char **argv)
int option_index = 0;
int c;
int ix;
char *optarg2;
int value;
int flag_stdin = 0;
int flag_compile = 0;
@@ -361,6 +379,59 @@ int main (int argc, char **argv)
filename[0] = 0;
option_punctlist[0] = 0;
#ifdef NEED_GETOPT
optind = 1;
opt_string = "";
while(optind < argc)
{
int len;
char *p;
if((c = *opt_string) == 0)
{
opt_string = argv[optind];
if(opt_string[0] != '-')
break;
optind++;
opt_string++;
c = *opt_string;
}
opt_string++;
p = optarg2 = opt_string;
if(c == '-')
{
opt_string="";
for(ix=0; ;ix++)
{
if(long_options[ix].name == 0)
break;
len = strlen(long_options[ix].name);
if(memcmp(long_options[ix].name,p,len)==0)
{
c = long_options[ix].val;
optarg2 = NULL;
if((long_options[ix].has_arg != 0) && (p[len]=='='))
{
optarg2 = &p[len+1];
}
break;
}
}
}
else
if(strchr(arg_opts,c) != NULL)
{
opt_string="";
if(optarg2[0]==0)
{
// the option's value is in the next argument
optarg2 = argv[optind++];
}
}
#else
while(true)
{
c = getopt_long (argc, argv, "a:b:f:g:hk:l:mp:qs:v:w:xXz",
@@ -369,12 +440,14 @@ int main (int argc, char **argv)
/* Detect the end of the options. */
if (c == -1)
break;
optarg2 = optarg;
#endif
switch (c)
{
case 'b':
// input character encoding, 8bit, 16bit, UTF8
if((sscanf(optarg,"%d",&value) == 1) && (value <= 4))
if((sscanf(optarg2,"%d",&value) == 1) && (value <= 4))
synth_flags |= value;
else
synth_flags |= espeakCHARS_8BIT;
@@ -387,7 +460,7 @@ int main (int argc, char **argv)
break;
case 'k':
option_capitals = atoi(optarg);
option_capitals = atoi(optarg2);
break;
case 'x':
@@ -403,7 +476,7 @@ int main (int argc, char **argv)
break;
case 'p':
pitch = atoi(optarg);
pitch = atoi(optarg2);
break;
case 'q':
@@ -411,32 +484,32 @@ int main (int argc, char **argv)
break;
case 'f':
strncpy0(filename,optarg,sizeof(filename));
strncpy0(filename,optarg2,sizeof(filename));
break;
case 'l':
option_linelength = atoi(optarg);
option_linelength = atoi(optarg2);
break;
case 'a':
volume = atoi(optarg);
volume = atoi(optarg2);
break;
case 's':
speed = atoi(optarg);
speed = atoi(optarg2);
break;
case 'g':
wordgap = atoi(optarg);
wordgap = atoi(optarg2);
break;
case 'v':
strncpy0(voicename,optarg,sizeof(voicename));
strncpy0(voicename,optarg2,sizeof(voicename));
break;
case 'w':
option_waveout = 1;
strncpy0(wavefile,optarg,sizeof(filename));
strncpy0(wavefile,optarg2,sizeof(filename));
break;
case 'z': // remove pause from the end of a sentence
@@ -454,17 +527,17 @@ int main (int argc, char **argv)
case 0x101: // --compile-debug
case 0x102: // --compile
strncpy0(voicename,optarg,sizeof(voicename));
strncpy0(voicename,optarg2,sizeof(voicename));
flag_compile = c;
quiet = 1;
break;
case 0x103: // --punct
option_punctuation = 1;
if(optarg != NULL)
if(optarg2 != NULL)
{
ix = 0;
while((ix < N_PUNCTLIST) && ((option_punctlist[ix] = optarg[ix]) != 0)) ix++;
while((ix < N_PUNCTLIST) && ((option_punctlist[ix] = optarg2[ix]) != 0)) ix++;
option_punctlist[N_PUNCTLIST-1] = 0;
option_punctuation = 2;
}
@@ -472,24 +545,24 @@ int main (int argc, char **argv)
case 0x104: // --voices
espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,0,data_path,0);
DisplayVoices(stdout,optarg);
DisplayVoices(stdout,optarg2);
exit(0);
case 0x106: // -- split
if(optarg == NULL)
if(optarg2 == NULL)
samples_split = 30; // default 30 minutes
else
samples_split = atoi(optarg);
samples_split = atoi(optarg2);
break;
case 0x107: // --path
data_path = optarg;
data_path = optarg2;
break;
case 0x108: // --phonout
if((f_phonemes_out = fopen(optarg,"w")) == NULL)
if((f_phonemes_out = fopen(optarg2,"w")) == NULL)
{
fprintf(stderr,"Can't write to: %s\n",optarg);
fprintf(stderr,"Can't write to: %s\n",optarg2);
}
break;
-25
View File
@@ -366,31 +366,6 @@ void MyFrame::OnQuit(wxCommandEvent& event)
}
#ifdef deleted
void MyFrame::OnAbout(wxCommandEvent& event)
{//=========================================
int result;
char buf[300];
wxString url_docs;
switch(event.GetId())
{
case MENU_ABOUT:
sprintf(buf,about_string,espeak_Info(NULL));
(void)wxMessageBox(wxString(buf,wxConvLocal), _T("About eSpeak Editor"));
break;
case MENU_DOCS:
sprintf(buf,"%s/docs/docindex.html",path_home);
url_docs = wxString(buf,wxConvLocal);
result = wxLaunchDefaultBrowser(url_docs);
if(result == 0)
wxLogStatus(_T("Failed to launch browser"));
break;
}
}
#endif
class HtmlWindow: public wxHtmlWindow
{
+1 -1
View File
@@ -275,7 +275,7 @@ static TONE_HEAD tone_head_table[N_TONE_HEAD_TABLE] = {
};
static TONE_NUCLEUS tone_nucleus_table[N_TONE_NUCLEUS_TABLE] = {
{PITCHfall, 30, 5, PITCHfall, 32, 9, NULL, 12, 7, 0}, // 0 statement
{PITCHfall, 29, 4, PITCHfall, 32, 9, NULL, 12, 6, 0}, // 0 statement
{PITCHfrise, 35, 8, PITCHfrise2, 35,10, NULL, 15, 23, 0}, // 1 comma
{PITCHfrise, 39,10, PITCHfrise2, 36,10, NULL, 15, 28, 0}, // 2 question
// {PITCHfall, 41, 4, PITCHfall, 41,27, NULL, 16, 4, T_EMPH}, // 3 exclamation
+185 -119
View File
@@ -65,6 +65,9 @@
#define M_MIDDLE_DOT M_DOT_ABOVE // duplicate of M_DOT_ABOVE
#define M_IMPLOSIVE M_HOOK
static int n_digit_lookup;
static char *digit_lookup;
typedef struct {
const char *name;
int flags;
@@ -783,6 +786,8 @@ static int CheckDotOrdinal(Translator *tr, char *word, WORD_TAB *wtab, int lower
} // end of CheckDotOrdinal
int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
{//=========================================================================
int c;
@@ -995,6 +1000,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
int found;
int ix;
int units;
int tens;
int used_and=0;
int found_ordinal = 0;
int next_phtype;
@@ -1004,143 +1010,167 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
char ph_digits[50];
char ph_and[12];
// is there a special pronunciation for this 2-digit number
units = value % 10;
tens = value / 10;
found = 0;
ph_ordinal[0] = 0;
if(control & 8)
if((control & 2) && (n_digit_lookup == 2))
{
sprintf(string,"_%df",value);
found = Lookup(tr, string, ph_digits);
}
else
if(control & 1)
{
strcpy(ph_ordinal, ph_ordinal2);
if(control & 4)
{
sprintf(string,"_%dox",value); // LANG=hu, special word for 1. 2. when there are no higher digits
found = Lookup(tr, string, ph_digits);
}
if(found == 0)
{
sprintf(string,"_%do",value);
found = Lookup(tr, string, ph_digits);
}
found_ordinal = found;
}
if(found == 0)
{
if((value == 1) && (control & 2))
{
if(Lookup(tr, "_1a", ph_out) != 0) // LANG=de, "eins"
return(0);
}
sprintf(string,"_%d",value);
found = Lookup(tr, string, ph_digits);
}
// no, speak as tens+units
if((control & 0x10) && (value < 10))
{
// speak leading zero
Lookup(tr, "_0", ph_tens);
// pronunciation of the final 2 digits has already been found
strcpy(ph_out, digit_lookup);
}
else
{
if(found)
if(digit_lookup[0] == 0)
{
ph_tens[0] = 0;
// is there a special pronunciation for this 2-digit number
if(control & 8)
{
sprintf(string,"_%df",value);
found = Lookup(tr, string, ph_digits);
}
else
if(control & 1)
{
strcpy(ph_ordinal, ph_ordinal2);
if(control & 4)
{
sprintf(string,"_%dox",value); // LANG=hu, special word for 1. 2. when there are no higher digits
found = Lookup(tr, string, ph_digits);
}
if(found == 0)
{
sprintf(string,"_%do",value);
found = Lookup(tr, string, ph_digits);
}
found_ordinal = found;
}
if(found == 0)
{
if((value == 1) && (control & 2))
{
if(Lookup(tr, "_1a", ph_out) != 0) // LANG=de, "eins"
return(0);
}
sprintf(string,"_%d",value);
found = Lookup(tr, string, ph_digits);
}
}
// no, speak as tens+units
if((control & 0x10) && (value < 10))
{
// speak leading zero
Lookup(tr, "_0", ph_tens);
}
else
{
units = (value % 10);
if((control & 1) && ((units == 0) || (tr->langopts.numbers & NUM_SWAP_TENS)))
if(found)
{
sprintf(string,"_%dXo",value / 10);
if(Lookup(tr, string, ph_tens) != 0)
{
found_ordinal = 1;
}
ph_tens[0] = 0;
}
if(found_ordinal == 0)
else
{
sprintf(string,"_%dX",value / 10);
Lookup(tr, string, ph_tens);
}
if((ph_tens[0] == 0) && (tr->langopts.numbers & NUM_VIGESIMAL))
{
// tens not found, (for example) 73 is 60+13
units = (value % 20);
sprintf(string,"_%dX",(value / 10) & 0xfe);
Lookup(tr, string, ph_tens);
}
ph_digits[0] = 0;
if(units > 0)
{
found = 0;
if(control & 8)
if((control & 1) && ((units == 0) || (tr->langopts.numbers & NUM_SWAP_TENS)))
{
// is there a variant form of this number?
sprintf(string,"_%df",units);
found = Lookup(tr, string, ph_digits);
}
if((control & 1) && ((tr->langopts.numbers & NUM_SWAP_TENS) == 0))
{
// ordinal
sprintf(string,"_%do",units);
if((found = Lookup(tr, string, ph_digits)) != 0)
sprintf(string,"_%dXo", tens);
if(Lookup(tr, string, ph_tens) != 0)
{
found_ordinal = 1;
}
}
if(found == 0)
if(found_ordinal == 0)
{
sprintf(string,"_%d",units);
Lookup(tr, string, ph_digits);
sprintf(string,"_%dX", tens);
Lookup(tr, string, ph_tens);
}
if((ph_tens[0] == 0) && (tr->langopts.numbers & NUM_VIGESIMAL))
{
// tens not found, (for example) 73 is 60+13
units = (value % 20);
sprintf(string,"_%dX", tens & 0xfe);
Lookup(tr, string, ph_tens);
}
ph_digits[0] = 0;
if(units > 0)
{
found = 0;
if((control & 2) && (digit_lookup[0] != 0))
{
// we have an entry for this digit (possibly together with the next word)
strcpy(ph_digits, digit_lookup);
found_ordinal = 1;
ph_ordinal[0] = 0;
}
else
{
if(control & 8)
{
// is there a variant form of this number?
sprintf(string,"_%df",units);
found = Lookup(tr, string, ph_digits);
}
if((control & 1) && ((tr->langopts.numbers & NUM_SWAP_TENS) == 0))
{
// ordinal
sprintf(string,"_%do",units);
if((found = Lookup(tr, string, ph_digits)) != 0)
{
found_ordinal = 1;
}
}
if(found == 0)
{
sprintf(string,"_%d",units);
Lookup(tr, string, ph_digits);
}
}
}
}
}
}
if((control & 1) && (found_ordinal == 0) && (ph_ordinal[0] == 0))
{
if((value >= 20) && (((value % 10) == 0) || (tr->langopts.numbers & NUM_SWAP_TENS)))
Lookup(tr, "_ord20", ph_ordinal);
if(ph_ordinal[0] == 0)
Lookup(tr, "_ord", ph_ordinal);
}
if((tr->langopts.numbers & (NUM_SWAP_TENS | NUM_AND_UNITS)) && (ph_tens[0] != 0) && (ph_digits[0] != 0))
{
Lookup(tr, "_0and", ph_and);
if(tr->langopts.numbers & NUM_SWAP_TENS)
sprintf(ph_out,"%s%s%s%s",ph_digits, ph_and, ph_tens, ph_ordinal);
else
sprintf(ph_out,"%s%s%s%s",ph_tens, ph_and, ph_digits, ph_ordinal);
used_and = 1;
}
else
{
if(tr->langopts.numbers & NUM_SINGLE_VOWEL)
{
// remove vowel from the end of tens if units starts with a vowel (LANG=Italian)
if(((ix = strlen(ph_tens)-1) >= 0) && (ph_digits[0] != 0))
{
if((next_phtype = phoneme_tab[(unsigned int)(ph_digits[0])]->type) == phSTRESS)
next_phtype = phoneme_tab[(unsigned int)(ph_digits[1])]->type;
if((phoneme_tab[(unsigned int)(ph_tens[ix])]->type == phVOWEL) && (next_phtype == phVOWEL))
ph_tens[ix] = 0;
}
if((control & 1) && (found_ordinal == 0) && (ph_ordinal[0] == 0))
{
if((value >= 20) && (((value % 10) == 0) || (tr->langopts.numbers & NUM_SWAP_TENS)))
Lookup(tr, "_ord20", ph_ordinal);
if(ph_ordinal[0] == 0)
Lookup(tr, "_ord", ph_ordinal);
}
if((tr->langopts.numbers & (NUM_SWAP_TENS | NUM_AND_UNITS)) && (ph_tens[0] != 0) && (ph_digits[0] != 0))
{
Lookup(tr, "_0and", ph_and);
if(tr->langopts.numbers & NUM_SWAP_TENS)
sprintf(ph_out,"%s%s%s%s",ph_digits, ph_and, ph_tens, ph_ordinal);
else
sprintf(ph_out,"%s%s%s%s",ph_tens, ph_and, ph_digits, ph_ordinal);
used_and = 1;
}
else
{
if(tr->langopts.numbers & NUM_SINGLE_VOWEL)
{
// remove vowel from the end of tens if units starts with a vowel (LANG=Italian)
if(((ix = strlen(ph_tens)-1) >= 0) && (ph_digits[0] != 0))
{
if((next_phtype = phoneme_tab[(unsigned int)(ph_digits[0])]->type) == phSTRESS)
next_phtype = phoneme_tab[(unsigned int)(ph_digits[1])]->type;
if((phoneme_tab[(unsigned int)(ph_tens[ix])]->type == phVOWEL) && (next_phtype == phVOWEL))
ph_tens[ix] = 0;
}
}
sprintf(ph_out,"%s%s%s",ph_tens, ph_digits, ph_ordinal);
}
sprintf(ph_out,"%s%s%s",ph_tens, ph_digits, ph_ordinal);
}
if(tr->langopts.numbers & NUM_SINGLE_STRESS)
@@ -1357,17 +1387,21 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
char ph_append[50];
char ph_buf[200];
char ph_buf2[50];
char ph_zeros[50];
char suffix[20];
char buf_digit_lookup[50];
static const char str_pause[2] = {phonPAUSE_NOLINK,0};
*flags = 0;
digit_lookup = buf_digit_lookup;
for(ix=0; isdigit(word[ix]); ix++) ;
n_digits = ix;
value = this_value = atoi(word);
ph_ordinal2[0] = 0;
ph_zeros[0] = 0;
ordinal = CheckDotOrdinal(tr, &word[ix], wtab, 1);
@@ -1377,11 +1411,11 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
ix++;
hyphen = 0;
p = suffix;
if(word[ix] == '-')
if(wtab[0].flags & FLAG_HYPHEN_AFTER)
{
*p++ = '-';
hyphen = 1;
ix += 2;
ix++;
}
while((word[ix] != 0) && (word[ix] != ' ') && (ix < (sizeof(suffix)-1)))
{
@@ -1397,7 +1431,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
// this is an ordinal suffix
ordinal = 2;
flags[0] |= FLAG_SKIPWORDS;
dictionary_skipwords = 1 + hyphen;
dictionary_skipwords = 1;
}
}
}
@@ -1431,7 +1465,17 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
}
else
{
return(0); // number string with leading zero, speak as individual digits
if(n_digits > 3)
{
flags[0] &= ~FLAG_SKIPWORDS;
return(0); // long number string with leading zero, speak as individual digits
}
// speak leading zeros
for(ix=0; (word[ix] == '0') && (ix < (n_digits-1)); ix++)
{
Lookup(tr, "_0", &ph_zeros[strlen(ph_zeros)]);
}
}
}
@@ -1504,11 +1548,33 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
Lookup(tr, "_.", ph_append);
}
n_digit_lookup = 0;
buf_digit_lookup[0] = 0;
if(thousandplex == 0)
{
char *p2;
// look for combinations of the number with the next word
p = word;
while(isdigit(p[1])) p++; // just use the last digit
if(isdigit(p[-1]))
{
p2 = p - 1;
if(LookupDictList(tr, &p2, buf_digit_lookup, flags, FLAG_SUFX, wtab)) // lookup 2 digits
n_digit_lookup = 2;
}
if((buf_digit_lookup[0] == 0) && (*p != '0'))
{
// not found, lookup only the last digit
if(LookupDictList(tr, &p, buf_digit_lookup, flags, FLAG_SUFX, wtab)) // don't match '0', or entries with $only
n_digit_lookup = 1;
}
}
LookupNum3(tr, value, ph_buf, suppress_null, thousandplex, prev_thousands | ordinal);
if((thousandplex > 0) && (tr->langopts.numbers2 & 0x200))
sprintf(ph_out,"%s%s%s",ph_append,ph_buf2,ph_buf); // say "thousands" before its number
sprintf(ph_out,"%s%s%s%s",ph_zeros,ph_append,ph_buf2,ph_buf); // say "thousands" before its number
else
sprintf(ph_out,"%s%s%s",ph_buf2,ph_buf,ph_append);
sprintf(ph_out,"%s%s%s%s",ph_zeros,ph_buf2,ph_buf,ph_append);
while(decimal_point)
@@ -1603,7 +1669,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
if((tr->langopts.numbers & NUM_NOPAUSE) && (next_char == ' '))
utf8_in(&next_char,p);
if(!iswalpha(next_char))
if(!iswalpha(next_char) && !(wtab[0].flags & FLAG_HYPHEN_AFTER))
strcat(ph_out,str_pause); // don't add pause for 100s, 6th, etc.
}
+23 -23
View File
@@ -104,16 +104,16 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST2 *plist_out)
if(((pl = &ph_list2[k])->sourceix != 0) && (k > ix))
break;
pl->stress &= 0xf;
pl->stresslevel &= 0xf;
if(phoneme_tab[pl->phcode]->type == phVOWEL)
{
n_syllables++;
if(pl->stress > max_stress)
if(pl->stresslevel > max_stress)
{
syllable_stressed = n_syllables;
max_stress = pl->stress;
max_stress = pl->stresslevel;
max_stress_posn = k;
}
}
@@ -137,7 +137,7 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST2 *plist_out)
flags |= 8;
ch.flags = flags | word_end;
ch.stress = plist2->stress;
ch.stress = plist2->stresslevel;
ch.stress_highest = max_stress;
ch.n_vowels = n_syllables;
ch.vowel_this = syllable;
@@ -156,13 +156,13 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST2 *plist_out)
if((replace_flags & 1) && (word_end == 0))
continue; // this replacement only occurs at the end of a word
if((replace_flags & 2) && ((plist2->stress & 0x7) > 3))
if((replace_flags & 2) && ((plist2->stresslevel & 0x7) > 3))
continue; // this replacement doesn't occur in stressed syllables
// substitute the replacement phoneme
plist2->phcode = replace_phonemes[k].new_ph;
if((plist2->stress > 1) && (phoneme_tab[plist2->phcode]->phflags & phUNSTRESSED))
plist2->stress = 0; // the replacement must be unstressed
if((plist2->stresslevel > 1) && (phoneme_tab[plist2->phcode]->phflags & phUNSTRESSED))
plist2->stresslevel = 0; // the replacement must be unstressed
break;
}
}
@@ -214,8 +214,8 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
for(j = n_ph_list2-3; j>=0; j--)
{
// start with the last phoneme (before the terminating pauses) and move forwards
if((plist2[j].stress & 0x7f) > max_stress)
max_stress = plist2[j].stress & 0x7f;
if((plist2[j].stresslevel & 0x7f) > max_stress)
max_stress = plist2[j].stresslevel & 0x7f;
if(plist2[j].sourceix != 0)
break;
}
@@ -226,10 +226,10 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
{
if(plist2[j].synthflags & SFLAG_PROMOTE_STRESS) // dictionary flags indicated that this stress can be promoted
{
plist2[j].stress = 4; // promote to stressed
plist2[j].stresslevel = 4; // promote to stressed
break;
}
if(plist2[j].stress >= 4)
if(plist2[j].stresslevel >= 4)
{
// found a stressed syllable, so stop looking
break;
@@ -344,7 +344,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
if(plist2->phcode == phonSWITCH)
{
// change phoneme table
SelectPhonemeTable(plist2->tone_number);
SelectPhonemeTable(plist2->tone_ph);
switched_language ^= SFLAG_SWITCHED_LANG;
}
next = phoneme_tab[(plist2+1)->phcode]; // the phoneme after this one
@@ -363,8 +363,8 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
if(ph_list3[k].sourceix)
break; // start of the next word
if(ph_list3[k].stress > word_stress)
word_stress = ph_list3[k].stress;
if(ph_list3[k].stresslevel > word_stress)
word_stress = ph_list3[k].stresslevel;
}
}
@@ -373,7 +373,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
if(ph->type == phVOWEL)
{
// check for consecutive unstressed syllables
if(plist2->stress == 0)
if(plist2->stresslevel == 0)
{
// an unstressed vowel
unstress_count++;
@@ -388,7 +388,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
}
else
{
plist2->stress = 1; // change stress to 'diminished'
plist2->stresslevel = 1; // change stress to 'diminished'
}
}
}
@@ -455,7 +455,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
{
plist2->synthflags |= SFLAG_SYLLABLE;
if(ph2->type != phVOWEL)
plist2->stress = 0; // change from non-vowel to vowel, make sure it's unstressed
plist2->stresslevel = 0; // change from non-vowel to vowel, make sure it's unstressed
}
else
plist2->synthflags &= ~SFLAG_SYLLABLE;
@@ -465,7 +465,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
{
if((ph->mnemonic == 't') && (plist2->sourceix == 0) && ((prev->type == phVOWEL) || (prev->mnemonic == 'n')))
{
if(((plist2+1)->sourceix == 0) && ((plist2+1)->stress < 3) && (next->type == phVOWEL))
if(((plist2+1)->sourceix == 0) && ((plist2+1)->stresslevel < 3) && (next->type == phVOWEL))
{
ph = phoneme_tab[phonT_REDUCED];
}
@@ -483,13 +483,13 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
if(ph->type == phVOWEL)
{
stress_level = plist2->stress;
stress_level = plist2->stresslevel;
}
else
{
// consonant, get stress from the following vowel
if(next->type == phVOWEL)
stress_level = (plist2+1)->stress;
stress_level = (plist2+1)->stresslevel;
else
break;
}
@@ -562,7 +562,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
insert_ph = phonPAUSE_VSHORT;
}
if(((plist2+1)->stress >= 4) && (tr->langopts.vowel_pause & 0x100))
if(((plist2+1)->stresslevel >= 4) && (tr->langopts.vowel_pause & 0x100))
{
// pause before a words which starts with a stressed vowel
insert_ph = phonPAUSE_SHORT;
@@ -628,8 +628,8 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
phlist[ix].type = ph->type;
phlist[ix].env = PITCHfall; // default, can be changed in the "intonation" module
phlist[ix].synthflags = plist2->synthflags | switched_language;
phlist[ix].stresslevel = plist2->stress & 0xf;
phlist[ix].tone_ph = plist2->tone_number;
phlist[ix].stresslevel = plist2->stresslevel & 0xf;
phlist[ix].tone_ph = plist2->tone_ph;
phlist[ix].sourceix = 0;
if(plist2->sourceix != 0)
+105 -54
View File
@@ -63,9 +63,6 @@ int count_characters = 0;
static int sayas_mode;
static int ssml_ignore_l_angle = 0;
static const char *punct_stop = ".:!?"; // pitch fall if followed by space
static const char *punct_close = ")]}>;'\""; // always pitch fall unless followed by alnum
// alter tone for announce punctuation or capitals
//static const char *tone_punct_on = "\0016T"; // add reverberation, lower pitch
//static const char *tone_punct_off = "\001T\001P";
@@ -121,7 +118,7 @@ static const unsigned int punct_attributes [] = { 0,
CLAUSE_COMMA, CLAUSE_PERIOD, CLAUSE_QUESTION, CLAUSE_EXCLAMATION, CLAUSE_COLON, CLAUSE_SEMICOLON,
CLAUSE_SEMICOLON, // en-dash
CLAUSE_SEMICOLON, // em-dash
CLAUSE_SEMICOLON, // elipsis
CLAUSE_SEMICOLON + PUNCT_SAY_NAME, // elipsis
CLAUSE_QUESTION, // Greek question mark
CLAUSE_SEMICOLON, // Greek semicolon
@@ -574,7 +571,7 @@ static const char *LookupSpecial(Translator *tr, const char *string, char* text_
if(LookupDictList(tr,&string1,phonemes,flags,0,NULL))
{
SetWordStress(tr, phonemes, flags[0], -1, 0);
SetWordStress(tr, phonemes, flags, -1, 0);
DecodePhonemes(phonemes,phonemes2);
sprintf(text_out,"[[%s]]",phonemes2);
option_phoneme_input |= 2;
@@ -584,8 +581,8 @@ static const char *LookupSpecial(Translator *tr, const char *string, char* text_
}
static const char *LookupCharName(Translator *tr, int c)
{//=====================================================
static const char *LookupCharName(Translator *tr, int c, int only)
{//===============================================================
// Find the phoneme string (in ascii) to speak the name of character c
// Used for punctuation characters and symbols
@@ -606,20 +603,28 @@ static const char *LookupCharName(Translator *tr, int c)
ix = utf8_out(c,&single_letter[2]);
single_letter[2+ix]=0;
string = &single_letter[1];
if(LookupDictList(tr, &string, phonemes, flags, 0, NULL) == 0)
if(only)
{
// try _* then *
string = &single_letter[2];
LookupDictList(tr, &string, phonemes, flags, 0, NULL);
}
else
{
string = &single_letter[1];
if(LookupDictList(tr, &string, phonemes, flags, 0, NULL) == 0)
{
// now try the rules
single_letter[1] = ' ';
TranslateRules(tr, &single_letter[2], phonemes, sizeof(phonemes), NULL,0,NULL);
// try _* then *
string = &single_letter[2];
if(LookupDictList(tr, &string, phonemes, flags, 0, NULL) == 0)
{
// now try the rules
single_letter[1] = ' ';
TranslateRules(tr, &single_letter[2], phonemes, sizeof(phonemes), NULL,0,NULL);
}
}
}
if((phonemes[0] == 0) && (tr->translator_name != L('e','n')))
if((only==0) && (phonemes[0] == 0) && (tr->translator_name != L('e','n')))
{
// not found, try English
SetTranslator2("en");
@@ -644,20 +649,21 @@ static const char *LookupCharName(Translator *tr, int c)
{
if(lang_name)
{
SetWordStress(translator2, phonemes, flags[0], -1, 0);
SetWordStress(translator2, phonemes, flags, -1, 0);
DecodePhonemes(phonemes,phonemes2);
sprintf(buf,"[[_^_%s %s _^_%s]]","en",phonemes2,WordToString2(tr->translator_name));
SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
}
else
{
SetWordStress(tr, phonemes, flags[0], -1, 0);
SetWordStress(tr, phonemes, flags, -1, 0);
DecodePhonemes(phonemes,phonemes2);
sprintf(buf,"[[%s]] ",phonemes2);
}
option_phoneme_input |= 2;
}
else
if(only == 0)
{
strcpy(buf,"[[(X1)(X1)(X1)]]");
option_phoneme_input |= 2;
@@ -835,6 +841,8 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output
const char *punctname;
int found = 0;
int soundicon;
int attributes;
int short_pause;
int c2;
int len;
int bufix1;
@@ -852,10 +860,10 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output
found = 1;
}
else
if((punctname = LookupCharName(tr, c1)) != NULL)
if((punctname = LookupCharName(tr, c1, 0)) != NULL)
{
found = 1;
if((*bufix==0) || (end_clause==0))
if((*bufix==0) || (end_clause ==0) || (tr->langopts.param[LOPT_ANNOUNCE_PUNCT] & 2))
{
punct_count=1;
while(c2 == c1)
@@ -919,14 +927,24 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output
if(c1 == '-')
return(CLAUSE_NONE); // no pause
if(bufix1 > 0)
return(CLAUSE_SHORTCOMMA);
if((strchr_w(punct_close,c1) != NULL) && !iswalnum(c2))
return(CLAUSE_SHORTFALL+4);
if(iswspace(c2) && strchr_w(punct_stop,c1)!=NULL)
return(punct_attributes[lookupwchar(punct_chars,c1)]);
attributes = punct_attributes[lookupwchar(punct_chars,c1)];
short_pause = CLAUSE_SHORTFALL;
if((attributes & CLAUSE_BITS_INTONATION) == 0x1000)
short_pause = CLAUSE_SHORTCOMMA;
if((bufix1 > 0) && !(tr->langopts.param[LOPT_ANNOUNCE_PUNCT] & 2))
{
if((attributes & ~0x8000) == CLAUSE_SEMICOLON)
return(CLAUSE_SHORTFALL);
return(short_pause);
}
if(attributes & CLAUSE_BIT_SENTENCE)
return(attributes);
return(CLAUSE_SHORTCOMMA);
return(short_pause);
} // end of AnnouncePunctuation
#define SSML_SPEAK 1
@@ -1936,6 +1954,7 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
int c2; // next character
int cprev=' '; // previous character
int cprev2=' ';
int c_next;
int parag;
int ix = 0;
int j;
@@ -1948,7 +1967,7 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
int found;
int any_alnum = 0;
int self_closing;
int punct_data;
int punct_data = 0;
int is_end_clause;
int announced_punctuation;
int stressed_word = 0;
@@ -2340,6 +2359,18 @@ if(option_ssml) parag=1;
{
is_end_clause = 0;
if((c1 == '.') && (c2 == '.'))
{
while((c_next = GetC()) == '.')
{
// 3 or more dots, replace by elipsis
c1 = 0x2026;
c2 = ' ';
}
UngetC(c_next);
}
punct_data = 0;
if((punct = lookupwchar(punct_chars,c1)) != 0)
{
punct_data = punct_attributes[punct];
@@ -2371,17 +2402,23 @@ if(option_ssml) parag=1;
}
}
if((punct_data & PUNCT_SAY_NAME) && (announced_punctuation == 0))
{
// used for elipsis (and 3 dots) if a pronunciation for elipsis is given in *_list
char *p2;
p2 = &buf[ix];
sprintf(p2,"%s",LookupCharName(tr, c1, 1));
if(p2[0] != 0)
{
ix += strlen(p2);
announced_punctuation = c1;
punct_data = punct_data & ~CLAUSE_BITS_INTONATION; // change intonation type to 0 (full-stop)
}
}
if(is_end_clause)
{
int c_next;
if((c1 == '.') && (cprev == '.'))
{
c1 = 0x2026;
punct = 9; // elipsis
}
nl_count = 0;
c_next = c2;
@@ -2395,26 +2432,39 @@ if(option_ssml) parag=1;
}
}
if((nl_count==0) && (c1 == '.'))
if(nl_count==0)
{
if((tr->langopts.numbers & NUM_ORDINAL_DOT) &&
(iswdigit(cprev) || (IsRomanU(cprev) && (IsRomanU(cprev2) || iswspace(cprev2))))) // lang=hu
if(c1 == '.')
{
// dot after a number indicates an ordinal number
if(!iswdigit(cprev) || iswlower(c_next) || (c_next == '<'))
is_end_clause = 0; // only if followed by lower-case, (or if there is a XML tag)
if((tr->langopts.numbers & NUM_ORDINAL_DOT) &&
(iswdigit(cprev) || (IsRomanU(cprev) && (IsRomanU(cprev2) || iswspace(cprev2))))) // lang=hu
{
// dot after a number indicates an ordinal number
if(!iswdigit(cprev) || iswlower(c_next) || (c_next == '<'))
is_end_clause = 0; // only if followed by lower-case, (or if there is a XML tag)
}
else
if(iswlower(c_next))
{
// next word has no capital letter, this dot is probably from an abbreviation
c1 = ' ';
is_end_clause = 0;
}
if(any_alnum==0)
{
// no letters or digits yet, so probably not a sentence terminator
// Here, dot is followed by space or bracket
c1 = ' ';
is_end_clause = 0;
}
}
else
if(iswlower(c_next))
{
// next word has no capital letter, this dot is probably from an abbreviation
c1 = ' ';
is_end_clause = 0;
}
if(any_alnum==0)
{
c1 = ' '; // no letters or digits yet, so probably not a sentence terminator
is_end_clause = 0;
if(any_alnum==0)
{
// no letters or digits yet, so probably not a sentence terminator
is_end_clause = 0;
}
}
}
@@ -2424,7 +2474,6 @@ if(option_ssml) parag=1;
buf[ix] = ' ';
buf[ix+1] = 0;
punct_data = punct_attributes[punct];
if(nl_count > 1)
{
if((punct_data == CLAUSE_QUESTION) || (punct_data == CLAUSE_EXCLAMATION))
@@ -2449,12 +2498,14 @@ if(option_ssml) parag=1;
if(c1 == announced_punctuation)
{
// const unsigned short keep_punctuation[] = {
// '\'', '-', 0x92, 0xb4, 0x2019, 0x2032, 0 };
// This character has already been announced, so delete it so that it isn't spoken a second time.
// Unless it's a hyphen or apostrophe (which is used by TranslateClause() )
if(!IsBracket(c1))
if(IsBracket(c1))
{
c1 = 0xe000 + '('; // Unicode private useage area. So TranslateRules() knows the bracket name has been spoken
}
else
if(c1 != '-')
{
c1 = ' ';
}
+6
View File
@@ -27,6 +27,12 @@
#define ARCH_BIG
#endif
#ifdef __QNX__
#define NEED_GETOPT
#define NO_VARIADIC_MACROS
#endif
#define PLATFORM_POSIX
#define PATHSEP '/'
// USE_PORTAUDIO or USE_PULSEAUDIO are now defined in the makefile
+1 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.41.18 19.Oct.09";
const char *version_string = "1.41.32 09.Nov.09";
const int version_phdata = 0x014118;
int option_device_number = -1;
+7
View File
@@ -1276,6 +1276,13 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
else
{
DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,0);
if((p->newword == 0) && (next2->newword == 0))
{
if((next->type == phVFRICATIVE) && (p->ph->mnemonic !='d'))
DoPause(20,0);
if((next->type == phFRICATIVE) || (next->type == phNASAL))
DoPause(12,0);
}
}
break;
+4 -2
View File
@@ -154,6 +154,8 @@ static Translator* NewTranslator(void)
tr->langopts.param[LOPT_SONORANT_MIN] = 95;
tr->langopts.param[LOPT_MAXAMP_EOC] = 19;
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 's'; // don't count this character at start of word
tr->langopts.param[LOPT_BRACKET_PAUSE] = 4; // pause at bracket
tr->langopts.param2[LOPT_BRACKET_PAUSE] = 2; // pauses when announcing bracket names
tr->langopts.max_initial_consonants = 3;
tr->langopts.replace_chars = NULL;
tr->langopts.ascii_language = ""; // Non-Latin alphabet languages, use this language to speak Latin words, default is English
@@ -576,10 +578,10 @@ Translator *SelectTranslator(const char *name)
tr->langopts.vowel_pause = 0x20;
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.stress_flags = 0x8036;
tr->langopts.stress_flags = 0x8036 | STRS_HYPEN_UNSTRESS;
tr->langopts.unstressed_wd1 = 2;
// tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x4; // don't propagate over word boundaries
tr->langopts.param[LOPT_IT_DOUBLING] = 1;
tr->langopts.param[LOPT_ANNOUNCE_PUNCT] = 2; // don't break clause before announcing . ? !
// tr->langopts.param[LOPT_COMBINE_WORDS] = 9; // combine some prepositions with the following word
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_5 | NUM_ROMAN | NUM_ROMAN_ORDINAL | NUM_ROMAN_CAPITALS | NUM_ORDINAL_DOT | NUM_OMIT_1_HUNDRED;
+37 -25
View File
@@ -75,6 +75,7 @@ static int embedded_flag = 0; // there are embedded commands to be applied to
static int prev_clause_pause=0;
static int max_clause_pause = 0;
static int any_stressed_words;
int pre_pause;
@@ -1100,7 +1101,7 @@ strcpy(phonemes2,phonemes);
{
char *p;
// German, keep a secondary stress on the stem
SetWordStress(tr, phonemes, dictionary_flags[0], 3, 0);
SetWordStress(tr, phonemes, dictionary_flags, 3, 0);
// reduce all but the first primary stress
ix=0;
@@ -1116,22 +1117,22 @@ strcpy(phonemes2,phonemes);
}
strcpy(word_phonemes,prefix_phonemes);
strcat(word_phonemes,phonemes);
SetWordStress(tr, word_phonemes, dictionary_flags[0], -1, 0);
SetWordStress(tr, word_phonemes, dictionary_flags, -1, 0);
}
else
{
// stress position affects the whole word, including prefix
strcpy(word_phonemes,prefix_phonemes);
strcat(word_phonemes,phonemes);
SetWordStress(tr, word_phonemes, dictionary_flags[0], -1, tr->prev_last_stress);
SetWordStress(tr, word_phonemes, dictionary_flags, -1, tr->prev_last_stress);
}
}
else
{
if(prefix_phonemes[0] == 0)
SetWordStress(tr, phonemes, dictionary_flags[0], -1, tr->prev_last_stress);
SetWordStress(tr, phonemes, dictionary_flags, -1, tr->prev_last_stress);
else
SetWordStress(tr, phonemes, dictionary_flags[0], -1, 0);
SetWordStress(tr, phonemes, dictionary_flags, -1, 0);
strcpy(word_phonemes,prefix_phonemes);
strcat(word_phonemes,phonemes);
}
@@ -1149,6 +1150,11 @@ strcpy(phonemes2,phonemes);
dictionary_flags[0] &= ~FLAG_PAUSE1;
}
if((wflags & FLAG_HYPHEN) && (tr->langopts.stress_flags & STRS_HYPEN_UNSTRESS))
{
ChangeWordStress(tr,word_phonemes,3);
}
else
if(wflags & FLAG_EMPHASIZED2)
{
// A word is indicated in the source text as stressed
@@ -1165,7 +1171,7 @@ strcpy(phonemes2,phonemes);
if(dictionary_flags[0] & (FLAG_STRESS_END | FLAG_STRESS_END2))
ChangeWordStress(tr,word_phonemes,4);
else
if(dictionary_flags[0] & FLAG_UNSTRESS_END)
if((dictionary_flags[0] & FLAG_UNSTRESS_END) && (any_stressed_words))
ChangeWordStress(tr,word_phonemes,3);
}
@@ -1227,7 +1233,7 @@ strcpy(phonemes2,phonemes);
tr->expect_past--;
}
if((word_length == 1) && iswalpha(first_char) && (first_char != 'i'))
if((word_length == 1) && (tr->translator_name == L('e','n')) && iswalpha(first_char) && (first_char != 'i'))
{
// English Specific !!!!
// any single letter before a dot is an abbreviation, except 'I'
@@ -1247,8 +1253,8 @@ strcpy(phonemes2,phonemes);
static void SetPlist2(PHONEME_LIST2 *p, unsigned char phcode)
{//==========================================================
p->phcode = phcode;
p->stress = 0;
p->tone_number = 0;
p->stresslevel = 0;
p->tone_ph = 0;
p->synthflags = embedded_flag;
p->sourceix = 0;
embedded_flag = 0;
@@ -1602,7 +1608,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
{
// this word uses a different phoneme table
SetPlist2(&ph_list2[n_ph_list2],phonSWITCH);
ph_list2[n_ph_list2++].tone_number = switch_phonemes; // temporary phoneme table number
ph_list2[n_ph_list2++].tone_ph = switch_phonemes; // temporary phoneme table number
}
// remove initial pause from a word if it follows a hyphen
@@ -1622,7 +1628,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
ph_list2[n_ph_list2].phcode = ph_code;
ph_list2[n_ph_list2].sourceix = 0;
ph_list2[n_ph_list2].synthflags = embedded_flag;
ph_list2[n_ph_list2++].tone_number = *p++;
ph_list2[n_ph_list2++].tone_ph = *p++;
}
else
if(ph->type == phSTRESS)
@@ -1637,7 +1643,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
// for tone languages, the tone number for a syllable follows the vowel
if(prev_vowel >= 0)
{
ph_list2[prev_vowel].tone_number = ph_code;
ph_list2[prev_vowel].tone_ph = ph_code;
}
else
{
@@ -1651,7 +1657,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
// mark the previous phoneme as a syllabic consonant
prev_vowel = n_ph_list2-1;
ph_list2[prev_vowel].synthflags |= SFLAG_SYLLABLE;
ph_list2[prev_vowel].stress = next_stress;
ph_list2[prev_vowel].stresslevel = next_stress;
}
else
if(ph_code == phonLENGTHEN)
@@ -1678,7 +1684,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
else
{
ph_list2[n_ph_list2].phcode = ph_code;
ph_list2[n_ph_list2].tone_number = 0;
ph_list2[n_ph_list2].tone_ph = 0;
ph_list2[n_ph_list2].synthflags = embedded_flag | found_dict_flag;
embedded_flag = 0;
ph_list2[n_ph_list2].sourceix = srcix;
@@ -1689,8 +1695,13 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
stress = next_stress;
next_stress = 0;
if(stress >= 4)
{
any_stressed_words = 1;
}
if((prev_vowel >= 0) && (n_ph_list2-1) != prev_vowel)
ph_list2[n_ph_list2-1].stress = stress; // set stress for previous consonant
ph_list2[n_ph_list2-1].stresslevel = stress; // set stress for previous consonant
ph_list2[n_ph_list2].synthflags |= SFLAG_SYLLABLE;
prev_vowel = n_ph_list2;
@@ -1702,7 +1713,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
}
if(next_tone != 0)
{
ph_list2[n_ph_list2].tone_number = next_tone;
ph_list2[n_ph_list2].tone_ph = next_tone;
next_tone=0;
}
}
@@ -1720,7 +1731,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
}
}
ph_list2[n_ph_list2].stress = stress;
ph_list2[n_ph_list2].stresslevel = stress;
n_ph_list2++;
first_phoneme = 0;
}
@@ -1742,7 +1753,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
// this word uses a different phoneme table, now switch back
SelectPhonemeTable(voice->phoneme_tab_ix);
SetPlist2(&ph_list2[n_ph_list2],phonSWITCH);
ph_list2[n_ph_list2++].tone_number = voice->phoneme_tab_ix; // original phoneme table number
ph_list2[n_ph_list2++].tone_ph = voice->phoneme_tab_ix; // original phoneme table number
}
@@ -2021,6 +2032,7 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
embedded_read = 0;
option_phoneme_input &= ~2; // clear bit 1 (temporary indication)
pre_pause = 0;
any_stressed_words = 0;
if((clause_start_char = count_characters) < 0)
clause_start_char = 0;
@@ -2390,7 +2402,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
else
if(c=='-')
{
if(IsAlpha(prev_in) && IsAlpha(next_in))
if((IsAlpha(prev_in) || iswdigit(prev_in)) && IsAlpha(next_in))
{
// '-' between two letters is a hyphen, treat as a space
word_flags |= FLAG_HYPHEN;
@@ -2683,17 +2695,17 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
}
word = pw;
// include the next few characters, in case there are an ordinal indicator
// include the next few characters, in case there are an ordinal indicator or other suffix
pn[0] = ' ';
memcpy(pn+1, pw, 8);
pn[8] = 0;
memcpy(pn+1, pw, 16);
pn[16] = 0;
for(pw = &number_buf[1]; pw < pn;)
{
// keep wflags for each part, for FLAG_HYPHEN_AFTER
dict_flags = TranslateWord2(tr, pw, &words[ix], words[ix].pre_pause,0 );
while(*pw++ != ' ');
words[ix].pre_pause = 0;
words[ix].flags = 0;
}
}
else
@@ -2730,7 +2742,7 @@ 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)
ix += dictionary_skipwords; // dictionary indicates skip next word(s)
}
}
@@ -2740,7 +2752,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
PHONEME_LIST2 *p2;
p2 = &ph_list2[n_ph_list2 + ix];
p2->phcode = phonPAUSE;
p2->stress = 0;
p2->stresslevel = 0;
p2->sourceix = source_index;
p2->synthflags = 0;
}
+23 -13
View File
@@ -76,9 +76,9 @@
#define FLAG_VERB_EXT 0x100 /* extend the 'verb follows' */
#define FLAG_CAPITAL 0x200 /* pronunciation if initial letter is upper case */
#define FLAG_ALLCAPS 0x400 // only if the word is all capitals
#define BITNUM_FLAG_ALLCAPS 0x2a
#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_ALLCAPS 0x2a
#define BITNUM_FLAG_HYPHENATED 0x2c
@@ -164,29 +164,30 @@
// Punctuation types returned by ReadClause()
// bits 0-7 pause x 10mS, bits 12-14 intonation type,
// bit 15- don't need space after the punctuation
// 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)
// bit 21= speak the name of the punctuation character
#define CLAUSE_BIT_SENTENCE 0x80000
#define CLAUSE_BIT_CLAUSE 0x40000
#define CLAUSE_BIT_VOICE 0x20000
#define CLAUSE_BITS_INTONATION 0x7000
#define PUNCT_IN_WORD 0x100000
#define PUNCT_SAY_NAME 0x200000
#define CLAUSE_NONE 0 + 0x04000
#define CLAUSE_PARAGRAPH 70 + 0x80000
#define CLAUSE_EOF 35 + 0x90000
#define CLAUSE_EOF 40 + 0x90000
#define CLAUSE_VOICE 0 + 0x24000
#define CLAUSE_PERIOD 35 + 0x80000
#define CLAUSE_PERIOD 40 + 0x80000
#define CLAUSE_COMMA 20 + 0x41000
#define CLAUSE_SHORTCOMMA 4 + 0x41000
#define CLAUSE_SHORTFALL 4 + 0x40000
#define CLAUSE_QUESTION 35 + 0x82000
#define CLAUSE_EXCLAMATION 40 + 0x83000
#define CLAUSE_QUESTION 40 + 0x82000
#define CLAUSE_EXCLAMATION 45 + 0x83000
#define CLAUSE_COLON 30 + 0x40000
#ifdef PLATFORM_RISCOS
#define CLAUSE_SEMICOLON 30 + 0x40000
#else
#define CLAUSE_SEMICOLON 30 + 0x41000
#endif
#define SAYAS_CHARS 0x12
#define SAYAS_GLYPHS 0x13
@@ -225,8 +226,8 @@ typedef struct{
// a clause translated into phoneme codes (first stage)
typedef struct {
unsigned char phcode;
unsigned char stress;
unsigned char tone_number;
unsigned char stresslevel;
unsigned char tone_ph;
unsigned char synthflags;
unsigned short sourceix;
} PHONEME_LIST2;
@@ -242,7 +243,7 @@ extern const int param_defaults[N_SPEECH_PARAM];
#define N_LOPTS 16
#define N_LOPTS 18
#define LOPT_DIERESES 1
// 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
@@ -296,6 +297,12 @@ extern const int param_defaults[N_SPEECH_PARAM];
// Call ApplySpecialAttributes() if $alt or $alt2 is set for a word
#define LOPT_ALT 15
// pause for bracket (default=4), pause when annoucing bracket names (default=2)
#define LOPT_BRACKET_PAUSE 16
// bit 1, don't break clause before annoucning . ? !
#define LOPT_ANNOUNCE_PUNCT 17
// stress_rule
#define STRESSPOSN_1L 0 // 1st syllable
@@ -314,6 +321,7 @@ typedef struct {
int vowel_pause;
int stress_rule; // 1=first syllable, 2=penultimate, 3=last
#define STRS_HYPEN_UNSTRESS 0x100000
// bit0=don't stress monosyllables, except at end of clause
// bit1=don't set diminished stress,
// bit2=mark unstressed final syllables as diminished
@@ -329,11 +337,13 @@ typedef struct {
// 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
// bit19=stress on final syllable if it has a long vowel, but previous syllable has a short vowel
// bit20= hyphenated words, 2nd part is unstressed
int stress_flags;
int unstressed_wd1; // stress for $u word of 1 syllable
int unstressed_wd2; // stress for $u word of >1 syllable
int param[N_LOPTS];
int param2[N_LOPTS];
unsigned char *length_mods;
unsigned char *length_mods0;
@@ -605,7 +615,7 @@ void CalcPitches(Translator *tr, int clause_tone);
int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy);
int Unpronouncable(Translator *tr, char *word);
void SetWordStress(Translator *tr, char *output, unsigned int &dictionary_flags, int tonic, int prev_stress);
void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int prev_stress);
int TranslateRules(Translator *tr, char *p, char *phonemes, int size, char *end_phonemes, int end_flags, unsigned int *dict_flags);
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);
+22 -23
View File
@@ -113,12 +113,12 @@ enum {
typedef struct {
const char *mnem;
int data;
} keywtab_t;
static MNEM_TAB options_tab[] = {
{"reduce_t", LOPT_REDUCE_T},
{"bracket", LOPT_BRACKET_PAUSE},
{NULL, -1} };
static keywtab_t keyword_tab[] = {
static MNEM_TAB keyword_tab[] = {
{"name", V_NAME},
{"language", V_LANGUAGE},
{"gender", V_GENDER},
@@ -373,11 +373,12 @@ void VoiceReset(int tone_only)
static int breath_widths[N_PEAKS] = {0,200,200,400,400,400,600,600,600};
// default is: pitch 82,118
// voice->pitch_base = 0x49000; // default, 73 << 12;
// voice->pitch_range = 0x0f30; // default = 0x1000
voice->pitch_base = 0x47000;
voice->pitch_range = 3996;
// default is: pitch 78,120
voice->pitch_base = 0x45000;
voice->pitch_range = 4536;
// default is: pitch 80,117
// voice->pitch_base = 0x47000;
// voice->pitch_range = 3996;
voice->formant_factor = 256;
@@ -503,12 +504,12 @@ voice_t *LoadVoice(const char *vname, int control)
// bit 4 1 = vname = full path
FILE *f_voice = NULL;
keywtab_t *k;
char *p;
int key;
int ix;
int n;
int value;
int value2;
int error = 0;
int langix = 0;
int tone_only = control & 2;
@@ -527,6 +528,7 @@ voice_t *LoadVoice(const char *vname, int control)
char translator_name[40];
char new_dictionary[40];
char phonemes_name[40];
char option_name[40];
const char *language_type;
char buf[200];
char path_voices[sizeof(path_home)+12];
@@ -631,15 +633,7 @@ voice_t *LoadVoice(const char *vname, int control)
if(buf[0] == 0) continue;
key = 0;
for(k=keyword_tab; k->mnem != NULL; k++)
{
if(strcmp(buf,k->mnem)==0)
{
key = k->data;
break;
}
}
key = LookupMnem(keyword_tab, buf);
switch(key)
{
@@ -804,10 +798,15 @@ voice_t *LoadVoice(const char *vname, int control)
break;
case V_OPTION:
if(sscanf(p,"%d %d",&ix,&value) == 2)
value2 = 0;
if((sscanf(p,"%s %d %d",option_name,&value,&value2) >= 2) && ((ix = LookupMnem(options_tab, option_name)) >= 0))
{
if((ix >= 0) && (ix < N_LOPTS))
langopts->param[ix] = value;
langopts->param[ix] = value;
langopts->param2[ix] = value2;
}
else
{
fprintf(stderr,"Bad voice option: %s %s\n",buf,p);
}
break;