mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-10-31 13:38:47 +00:00
Remove braces around single-line if/while/for/etc. and related cleanup.
This commit is contained in:
+5
-10
@@ -141,9 +141,8 @@ void DisplayVoices(FILE *f_out, char *language)
|
||||
voice_select.gender = 0;
|
||||
voice_select.name = NULL;
|
||||
voices = espeak_ListVoices(&voice_select);
|
||||
} else {
|
||||
} else
|
||||
voices = espeak_ListVoices(NULL);
|
||||
}
|
||||
|
||||
fprintf(f_out, "Pty Language Age/Gender VoiceName File Other Languages\n");
|
||||
|
||||
@@ -169,9 +168,8 @@ void DisplayVoices(FILE *f_out, char *language)
|
||||
}
|
||||
fprintf(f_out, "%2d %-12s%s%c %-20s %-13s ",
|
||||
p[0], lang_name, age_buf, genders[v->gender], buf, v->identifier);
|
||||
} else {
|
||||
} else
|
||||
fprintf(f_out, "(%s %d)", lang_name, p[0]);
|
||||
}
|
||||
count++;
|
||||
p += len+2;
|
||||
}
|
||||
@@ -421,9 +419,8 @@ int main(int argc, char **argv)
|
||||
c = long_options[ix].val;
|
||||
optarg2 = NULL;
|
||||
|
||||
if ((long_options[ix].has_arg != 0) && (p[len] == '=')) {
|
||||
if ((long_options[ix].has_arg != 0) && (p[len] == '='))
|
||||
optarg2 = &p[len+1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -562,9 +559,8 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 0x108: // --phonout
|
||||
if ((f_phonemes_out = fopen(optarg2, "w")) == NULL) {
|
||||
if ((f_phonemes_out = fopen(optarg2, "w")) == NULL)
|
||||
fprintf(stderr, "Can't write to: %s\n", optarg2);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x109: // --pho
|
||||
@@ -704,9 +700,8 @@ int main(int argc, char **argv)
|
||||
p_text = argv[optind];
|
||||
} else {
|
||||
f_text = stdin;
|
||||
if (flag_stdin == 0) {
|
||||
if (flag_stdin == 0)
|
||||
flag_stdin = 2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
filesize = GetFileLength(filename);
|
||||
|
||||
+55
-109
@@ -492,11 +492,10 @@ static void DecompilePhoneme(FILE *f_out, PHONEME_TAB *ph, int compile_phoneme)
|
||||
|
||||
return;
|
||||
|
||||
if (compile_phoneme) {
|
||||
if (compile_phoneme)
|
||||
fprintf(f_out, "\nPhoneme %s (%d)\n", WordToString(ph->mnemonic), ph->code);
|
||||
} else {
|
||||
else
|
||||
fprintf(f_out, "\nProcedure %s\n", proc_names[n_procs]);
|
||||
}
|
||||
|
||||
pc = prog_buf;
|
||||
while (pc < prog_out) {
|
||||
@@ -772,9 +771,8 @@ static void CompileReport(void)
|
||||
|
||||
fprintf(f_report, "\n%d phoneme tables\n", n_phoneme_tabs);
|
||||
fprintf(f_report, " new total\n");
|
||||
for (ix = 0; ix < n_phoneme_tabs; ix++) {
|
||||
for (ix = 0; ix < n_phoneme_tabs; ix++)
|
||||
fprintf(f_report, "%8s %3d %4d\n", phoneme_tab_list2[ix].name, phoneme_tab_list2[ix].n_phonemes, n_phcodes_list[ix]+1);
|
||||
}
|
||||
fputc('\n', f_report);
|
||||
|
||||
fprintf(f_report, "Data file Used by\n");
|
||||
@@ -814,9 +812,8 @@ static void CompileReport(void)
|
||||
// a procedure, not a phoneme
|
||||
procedure_num = atoi(WordToString(prev_mnemonic));
|
||||
fprintf(f_report, " %s %s", phoneme_tab_list2[prev_table = list[ix]->ph_table].name, proc_names[procedure_num]);
|
||||
} else {
|
||||
} else
|
||||
fprintf(f_report, " [%s] %s", WordToString(prev_mnemonic), phoneme_tab_list2[prev_table = list[ix]->ph_table].name);
|
||||
}
|
||||
fputc('\n', f_report);
|
||||
}
|
||||
|
||||
@@ -951,9 +948,8 @@ static int LookupPhoneme(const char *string, int control)
|
||||
return 1;
|
||||
|
||||
ix = strlen(string);
|
||||
if ((ix == 0) || (ix > 4)) {
|
||||
if ((ix == 0) || (ix > 4))
|
||||
error("Bad phoneme name '%s'", string);
|
||||
}
|
||||
word = StringToWord(string);
|
||||
|
||||
// don't use phoneme number 0, reserved for string terminator
|
||||
@@ -968,9 +964,8 @@ static int LookupPhoneme(const char *string, int control)
|
||||
if (phoneme_tab2[ix].mnemonic == word)
|
||||
return ix;
|
||||
|
||||
if ((use == 0) && (phoneme_tab2[ix].mnemonic == 0)) {
|
||||
if ((use == 0) && (phoneme_tab2[ix].mnemonic == 0))
|
||||
use = ix;
|
||||
}
|
||||
}
|
||||
|
||||
if (use == 0) {
|
||||
@@ -1037,13 +1032,11 @@ static int NextItem(int type)
|
||||
if ((c2 = get_char()) == '/') {
|
||||
// comment, ignore to end of line
|
||||
while (!feof(f_in) && ((c = get_char()) != '\n')) ;
|
||||
} else {
|
||||
} else
|
||||
unget_char(c2);
|
||||
}
|
||||
}
|
||||
if (!isspace(c)) {
|
||||
if (!isspace(c))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (feof(f_in))
|
||||
return -2;
|
||||
@@ -1067,9 +1060,8 @@ static int NextItem(int type)
|
||||
}
|
||||
item_string[ix] = 0;
|
||||
|
||||
while (isspace(c)) {
|
||||
while (isspace(c))
|
||||
c = get_char();
|
||||
}
|
||||
|
||||
item_terminator = ' ';
|
||||
if ((c == ')') || (c == '(') || (c == ','))
|
||||
@@ -1081,9 +1073,8 @@ static int NextItem(int type)
|
||||
if (!feof(f_in))
|
||||
unget_char(c);
|
||||
|
||||
if (type == tSTRING) {
|
||||
if (type == tSTRING)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((type == tNUMBER) || (type == tSIGNEDNUMBER)) {
|
||||
acc = 0;
|
||||
@@ -1121,9 +1112,8 @@ static int NextItem(int type)
|
||||
item_type = -1;
|
||||
return -1; // keyword not found
|
||||
}
|
||||
if (type == tPHONEMEMNEM) {
|
||||
if (type == tPHONEMEMNEM)
|
||||
return LookupPhoneme(item_string, 2);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1155,18 +1145,16 @@ static int NextItemBrackets(int type, int control)
|
||||
int value;
|
||||
|
||||
if ((control & 1) == 0) {
|
||||
if (!NextItem(tOPENBRACKET)) {
|
||||
if (!NextItem(tOPENBRACKET))
|
||||
error("Expected '('", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
value = NextItem(type);
|
||||
if ((control & 2) && (item_terminator == ','))
|
||||
return value;
|
||||
|
||||
if (item_terminator != ')') {
|
||||
if (item_terminator != ')')
|
||||
error("Expected ')'", NULL);
|
||||
}
|
||||
return value;
|
||||
|
||||
}
|
||||
@@ -1360,9 +1348,8 @@ int LoadSpect(const char *path, int control)
|
||||
total = 0;
|
||||
for (frame = 0; frame < spectseq->numframes; frame++) {
|
||||
if (spectseq->frames[frame]->keyframe) {
|
||||
if (seq_out.n_frames == 1) {
|
||||
if (seq_out.n_frames == 1)
|
||||
frame_vowelbreak = frame;
|
||||
}
|
||||
if (spectseq->frames[frame]->markers & 0x2) {
|
||||
// marker 1 is set
|
||||
marker1_set = 1;
|
||||
@@ -1442,9 +1429,8 @@ int LoadSpect(const char *path, int control)
|
||||
|
||||
if (klatt_flag) {
|
||||
// additional klatt parameters
|
||||
for (ix = 0; ix < 5; ix++) {
|
||||
for (ix = 0; ix < 5; ix++)
|
||||
fr_out->klattp2[ix] = fr->klatt_param[ix+5];
|
||||
}
|
||||
|
||||
for (peak = 0; peak < 7; peak++) {
|
||||
fr_out->klatt_ap[ix] = fr->peaks[peak].klt_ap;
|
||||
@@ -1519,9 +1505,8 @@ static int LoadWavefile(FILE *f, const char *fname)
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
strcpy(fname_temp, "/tmp/espeakXXXXXX");
|
||||
if ((fd_temp = mkstemp(fname_temp)) >= 0) {
|
||||
if ((fd_temp = mkstemp(fname_temp)) >= 0)
|
||||
close(fd_temp);
|
||||
}
|
||||
#else
|
||||
strcpy(fname_temp, tmpnam(NULL));
|
||||
#endif
|
||||
@@ -1535,9 +1520,8 @@ static int LoadWavefile(FILE *f, const char *fname)
|
||||
}
|
||||
|
||||
sprintf(command, "sox \"%s/../phsource/%s.wav\" -r %d -c1 -t wav %s\n", path_home, fname2, samplerate_native, fname_temp);
|
||||
if (system(command) != 0) {
|
||||
if (system(command) != 0)
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
|
||||
if (failed || (GetFileLength(fname_temp) <= 0)) {
|
||||
@@ -1548,9 +1532,8 @@ static int LoadWavefile(FILE *f, const char *fname)
|
||||
if (sr1 != samplerate_native) {
|
||||
sprintf(msg, "Can't resample (%d to %d): %s", sr1, samplerate_native, fname);
|
||||
error("%s", msg);
|
||||
} else {
|
||||
} else
|
||||
error("WAV file is not mono: %s", fname);
|
||||
}
|
||||
remove(fname_temp);
|
||||
return 0;
|
||||
}
|
||||
@@ -1647,9 +1630,8 @@ static int LoadEnvelope(FILE *f, const char *fname)
|
||||
displ = ftell(f_phdata);
|
||||
|
||||
fseek(f, 12, SEEK_SET);
|
||||
if (fread(buf, 128, 1, f) == 0) {
|
||||
if (fread(buf, 128, 1, f) == 0)
|
||||
error("Failed to read envelope: %s", fname);
|
||||
}
|
||||
fwrite(buf, 128, 1, f_phdata);
|
||||
|
||||
if (n_envelopes < N_ENVELOPES) {
|
||||
@@ -1808,9 +1790,8 @@ static int LoadDataFile(const char *path, int control)
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
if (addr > 0) {
|
||||
if (addr > 0)
|
||||
fprintf(f_phcontents, "%c 0x%.5x %s\n", type_code, addr & 0x7fffff, path);
|
||||
}
|
||||
}
|
||||
|
||||
// add this item to the hash table
|
||||
@@ -1963,9 +1944,9 @@ int CompileIf(int elif)
|
||||
key = key << 8;
|
||||
|
||||
data = NextItemBrackets(tPROPERTIES, 0);
|
||||
if (data >= 0) {
|
||||
if (data >= 0)
|
||||
word = key + data + 0x700;
|
||||
} else {
|
||||
else {
|
||||
data = LookupPhoneme(item_string, 2);
|
||||
word = key + data;
|
||||
}
|
||||
@@ -1982,9 +1963,8 @@ int CompileIf(int elif)
|
||||
brackets = 3;
|
||||
} while (item_terminator == ',');
|
||||
word = i_StressLevel | bitmap;
|
||||
} else {
|
||||
} else
|
||||
word = key;
|
||||
}
|
||||
} else {
|
||||
error("Unexpected keyword '%s'", item_string);
|
||||
|
||||
@@ -2019,9 +1999,6 @@ int CompileIf(int elif)
|
||||
}
|
||||
}
|
||||
|
||||
if (finish != 1) {
|
||||
}
|
||||
|
||||
if (elif == 0) {
|
||||
if_level++;
|
||||
if_stack[if_level].p_else = NULL;
|
||||
@@ -2053,9 +2030,8 @@ void FillThen(int add)
|
||||
}
|
||||
prog_out--;
|
||||
} else {
|
||||
if (offset > MAX_JUMP) {
|
||||
if (offset > MAX_JUMP)
|
||||
error("IF block is too long", NULL);
|
||||
}
|
||||
*p = i_JUMP_FALSE + offset;
|
||||
}
|
||||
if_stack[if_level].p_then = NULL;
|
||||
@@ -2075,19 +2051,17 @@ int CompileElse(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (if_stack[if_level].returned == 0) {
|
||||
if (if_stack[if_level].returned == 0)
|
||||
FillThen(1);
|
||||
} else {
|
||||
else
|
||||
FillThen(0);
|
||||
}
|
||||
|
||||
if (if_stack[if_level].returned == 0) {
|
||||
ref = prog_out;
|
||||
*prog_out++ = 0;
|
||||
|
||||
if ((p = if_stack[if_level].p_else) != NULL) {
|
||||
if ((p = if_stack[if_level].p_else) != NULL)
|
||||
*ref = ref - p; // backwards offset to the previous else
|
||||
}
|
||||
if_stack[if_level].p_else = ref;
|
||||
}
|
||||
|
||||
@@ -2126,9 +2100,8 @@ int CompileEndif(void)
|
||||
chain = *p; // a chain of previous else links
|
||||
|
||||
offset = prog_out - p;
|
||||
if (offset > MAX_JUMP) {
|
||||
if (offset > MAX_JUMP)
|
||||
error("IF block is too long", NULL);
|
||||
}
|
||||
*p = i_JUMP + offset;
|
||||
|
||||
p -= chain;
|
||||
@@ -2165,9 +2138,8 @@ static PHONEME_TAB_LIST *FindPhonemeTable(const char *string)
|
||||
int ix;
|
||||
|
||||
for (ix = 0; ix < n_phoneme_tabs; ix++) {
|
||||
if (strcmp(phoneme_tab_list2[ix].name, string) == 0) {
|
||||
if (strcmp(phoneme_tab_list2[ix].name, string) == 0)
|
||||
return &phoneme_tab_list2[ix];
|
||||
}
|
||||
}
|
||||
error("Unknown phoneme table: '%s'", string);
|
||||
return NULL;
|
||||
@@ -2184,26 +2156,22 @@ static PHONEME_TAB *FindPhoneme(const char *string)
|
||||
char buf[200];
|
||||
|
||||
// is this the name of a phoneme which is in scope
|
||||
if ((strlen(string) <= 4) && ((ix = LookupPhoneme(string, 0)) != -1)) {
|
||||
if ((strlen(string) <= 4) && ((ix = LookupPhoneme(string, 0)) != -1))
|
||||
return &phoneme_tab2[ix];
|
||||
}
|
||||
|
||||
// no, treat the name as phonemetable/phoneme
|
||||
strcpy(buf, string);
|
||||
if ((phname = strchr(buf, '/')) != 0) {
|
||||
if ((phname = strchr(buf, '/')) != 0)
|
||||
*phname++ = 0;
|
||||
}
|
||||
|
||||
phtab = FindPhonemeTable(buf);
|
||||
if (phtab == NULL) {
|
||||
if (phtab == NULL)
|
||||
return NULL; // phoneme table not found
|
||||
}
|
||||
|
||||
mnem = StringToWord(phname);
|
||||
for (ix = 1; ix < 256; ix++) {
|
||||
if (mnem == phtab->phoneme_tab_ptr[ix].mnemonic) {
|
||||
if (mnem == phtab->phoneme_tab_ptr[ix].mnemonic)
|
||||
return &phtab->phoneme_tab_ptr[ix];
|
||||
}
|
||||
}
|
||||
|
||||
error("Phoneme reference not found: '%s'", string);
|
||||
@@ -2398,13 +2366,12 @@ int CompilePhoneme(int compile_phoneme)
|
||||
|
||||
case i_SET_LENGTH:
|
||||
value = NextItemMax(511);
|
||||
if (phoneme_out->type == phVOWEL) {
|
||||
if (phoneme_out->type == phVOWEL)
|
||||
value = (value * vowel_length_factor)/100;
|
||||
}
|
||||
|
||||
if (after_if == 0) {
|
||||
if (after_if == 0)
|
||||
phoneme_out->std_length = value/2;
|
||||
} else {
|
||||
else {
|
||||
*prog_out++ = (i_SET_LENGTH << 8) + value/2;
|
||||
DecThenCount();
|
||||
}
|
||||
@@ -2469,9 +2436,8 @@ int CompilePhoneme(int compile_phoneme)
|
||||
value = strlen(&ipa_buf[start]); // number of UTF-8 bytes
|
||||
|
||||
*prog_out++ = (i_IPA_NAME << 8) + value;
|
||||
for (ix = 0; ix < value; ix += 2) {
|
||||
for (ix = 0; ix < value; ix += 2)
|
||||
*prog_out++ = (ipa_buf[ix+start] << 8) + (ipa_buf[ix+start+1] & 0xff);
|
||||
}
|
||||
DecThenCount();
|
||||
break;
|
||||
}
|
||||
@@ -2496,13 +2462,10 @@ int CompilePhoneme(int compile_phoneme)
|
||||
phcode = NextItem(tPHONEMEMNEM);
|
||||
if (phcode == -1)
|
||||
phcode = LookupPhoneme(item_string, 1);
|
||||
if (phoneme_out->type == phVOWEL) {
|
||||
if (phoneme_out->type == phVOWEL)
|
||||
phoneme_out->end_type = phcode;
|
||||
} else {
|
||||
if (phcode != phoneme_out->start_type) {
|
||||
error("endtype must equal starttype for consonants", NULL);
|
||||
}
|
||||
}
|
||||
else if (phcode != phoneme_out->start_type)
|
||||
error("endtype must equal starttype for consonants", NULL);
|
||||
break;
|
||||
|
||||
case kVOICINGSWITCH:
|
||||
@@ -2603,12 +2566,10 @@ int CompilePhoneme(int compile_phoneme)
|
||||
case kENDPHONEME:
|
||||
case kENDPROCEDURE:
|
||||
endphoneme = 1;
|
||||
if (if_level > 0) {
|
||||
if (if_level > 0)
|
||||
error("Missing ENDIF", NULL);
|
||||
}
|
||||
if ((prog_out > prog_buf) && (if_stack[0].returned == 0)) {
|
||||
if ((prog_out > prog_buf) && (if_stack[0].returned == 0))
|
||||
*prog_out++ = i_RETURN;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2616,9 +2577,8 @@ int CompilePhoneme(int compile_phoneme)
|
||||
}
|
||||
}
|
||||
|
||||
if (endphoneme != 1) {
|
||||
if (endphoneme != 1)
|
||||
error("'endphoneme' not expected here", NULL);
|
||||
}
|
||||
|
||||
if (compile_phoneme) {
|
||||
if (phoneme_out->type == phINVALID) {
|
||||
@@ -2642,9 +2602,8 @@ int CompilePhoneme(int compile_phoneme)
|
||||
|
||||
phoneme_out->phflags |= phLOCAL; // declared in this phoneme table
|
||||
|
||||
if (phoneme_out->type == phDELETED) {
|
||||
if (phoneme_out->type == phDELETED)
|
||||
phoneme_out->mnemonic = 0x01; // will not be recognised
|
||||
}
|
||||
}
|
||||
|
||||
DecompilePhoneme(f_errors, phoneme_out, compile_phoneme);
|
||||
@@ -2660,9 +2619,8 @@ int CompilePhoneme(int compile_phoneme)
|
||||
fwrite(&phoneme_prog_log, 1, sizeof(phoneme_prog_log), f_prog_log);
|
||||
}
|
||||
|
||||
if (compile_phoneme == 0) {
|
||||
if (compile_phoneme == 0)
|
||||
proc_addr[n_procs++] = ftell(f_phindex) / sizeof(USHORT);
|
||||
}
|
||||
fwrite(prog_buf, sizeof(USHORT), prog_out - prog_buf, f_phindex);
|
||||
}
|
||||
|
||||
@@ -2808,9 +2766,8 @@ static void StartPhonemeTable(const char *name)
|
||||
if (ix == n_phoneme_tabs) {
|
||||
error("Can't find base phonemetable '%s'", item_string);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
ReservePhCodes();
|
||||
}
|
||||
|
||||
n_phoneme_tabs++;
|
||||
}
|
||||
@@ -2838,9 +2795,8 @@ static void CompileEquivalents()
|
||||
strcpy(foreign_table_name, item_string);
|
||||
|
||||
if ((foreign_table = SelectPhonemeTableName(foreign_table_name)) < 0) {
|
||||
if (strcmp(foreign_table_name, "NULL") != 0) {
|
||||
if (strcmp(foreign_table_name, "NULL") != 0)
|
||||
error("Unknown phoneme table '%s'", foreign_table_name);
|
||||
}
|
||||
foreign_error = 1;
|
||||
foreign_phoneme = 0;
|
||||
}
|
||||
@@ -2889,9 +2845,8 @@ static void CompileEquivalents()
|
||||
}
|
||||
}
|
||||
|
||||
for (ix = 1; ix < n_names; ix++) {
|
||||
for (ix = 1; ix < n_names; ix++)
|
||||
phcode[ix] = LookupPhoneme(names[ix], 1);
|
||||
}
|
||||
|
||||
// only write a translation if it has an effect
|
||||
if ((n_names > 2) || (phcode[0] != phcode[1])) {
|
||||
@@ -2960,9 +2915,8 @@ static void CompilePhonemeFiles()
|
||||
strncpy0(current_fname, item_string, sizeof(current_fname));
|
||||
linenum = 1;
|
||||
|
||||
} else {
|
||||
} else
|
||||
error("Missing file: %s", item_string);
|
||||
}
|
||||
break;
|
||||
|
||||
case kPHONEMETABLE:
|
||||
@@ -3070,9 +3024,8 @@ static espeak_ng_STATUS CompilePhonemeData2(const char *source, FILE *log)
|
||||
sprintf(fname, "%s/%s", path_home, "phontab");
|
||||
f_phtab = fopen_log(f_errors, fname, "wb");
|
||||
|
||||
if (f_phdata == NULL || f_phindex == NULL || f_phtab == NULL) {
|
||||
if (f_phdata == NULL || f_phindex == NULL || f_phtab == NULL)
|
||||
return ENE_WRITE_ERROR;
|
||||
}
|
||||
|
||||
sprintf(fname, "%s/../phsource/compile_prog_log", path_home);
|
||||
f_prog_log = fopen_log(f_errors, fname, "wb");
|
||||
@@ -3110,9 +3063,8 @@ static espeak_ng_STATUS CompilePhonemeData2(const char *source, FILE *log)
|
||||
if (resample_count > 0) {
|
||||
fprintf(f_errors, "\n%d WAV files resampled to %d Hz\n", resample_count, samplerate_native);
|
||||
fprintf(log, "Compiled phonemes: %d errors, %d files resampled to %d Hz.\n", error_count, resample_count, samplerate_native);
|
||||
} else {
|
||||
} else
|
||||
fprintf(log, "Compiled phonemes: %d errors.\n", error_count);
|
||||
}
|
||||
|
||||
if (f_errors != stderr)
|
||||
fclose(f_errors);
|
||||
@@ -3218,9 +3170,8 @@ espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log)
|
||||
while (isspace(*p)) p++;
|
||||
|
||||
ix = 0;
|
||||
while ((ix < (int)(sizeof(name) - 1)) && !isspace(*p)) {
|
||||
while ((ix < (int)(sizeof(name) - 1)) && !isspace(*p))
|
||||
name[ix++] = *p++;
|
||||
}
|
||||
name[ix] = 0;
|
||||
|
||||
found = 0;
|
||||
@@ -3265,8 +3216,6 @@ espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log)
|
||||
switch (keyword)
|
||||
{
|
||||
case kTUNE:
|
||||
if (compiling_tune) {
|
||||
}
|
||||
compiling_tune = 1;
|
||||
done_split = 0;
|
||||
|
||||
@@ -3286,12 +3235,10 @@ espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == 2) {
|
||||
if (found == 2)
|
||||
error("Duplicate tune name: '%s'", new_tune.name);
|
||||
}
|
||||
if (found == 0) {
|
||||
if (found == 0)
|
||||
error("Bad tune name: '%s;", new_tune.name);
|
||||
}
|
||||
break;
|
||||
|
||||
case kENDTUNE:
|
||||
@@ -3420,9 +3367,8 @@ espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log)
|
||||
}
|
||||
|
||||
for (ix = 0; ix < n_preset_tunes; ix++) {
|
||||
if (tune_data[ix].name[0] == 0) {
|
||||
if (tune_data[ix].name[0] == 0)
|
||||
error("Tune '%s' not defined", preset_tune_names[ix]);
|
||||
}
|
||||
}
|
||||
fwrite(tune_data, n_tune_names, sizeof(TUNE), f_out);
|
||||
free(tune_data);
|
||||
|
||||
@@ -262,9 +262,8 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
|
||||
match_type = 0;
|
||||
buf_pre[0] = 0;
|
||||
|
||||
for (ix = 0; ix < group_length; ix++) {
|
||||
for (ix = 0; ix < group_length; ix++)
|
||||
buf[ix] = group_chars[ix];
|
||||
}
|
||||
buf[ix] = 0;
|
||||
|
||||
p = &buf[strlen(buf)];
|
||||
@@ -332,9 +331,9 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
|
||||
strcpy(p, suffix);
|
||||
p += strlen(suffix);
|
||||
c = ' ';
|
||||
} else if (rb == RULE_LETTERGP) {
|
||||
} else if (rb == RULE_LETTERGP)
|
||||
c = symbols_lg[*rule++ - 'A'];
|
||||
} else if (rb == RULE_LETTERGP2) {
|
||||
else if (rb == RULE_LETTERGP2) {
|
||||
value = *rule++ - 'A';
|
||||
p[0] = 'L';
|
||||
p[1] = (value / 10) + '0';
|
||||
@@ -462,15 +461,14 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
|
||||
flagnum = LookupMnem(mnem_flags, mnemptr);
|
||||
if (flagnum > 0) {
|
||||
if (flagnum == 200) {
|
||||
if (flagnum == 200)
|
||||
text_mode = 1;
|
||||
} else if (flagnum == 201) {
|
||||
else if (flagnum == 201)
|
||||
text_mode = 0;
|
||||
} else if (flagnum == BITNUM_FLAG_TEXTMODE) {
|
||||
else if (flagnum == BITNUM_FLAG_TEXTMODE)
|
||||
text_not_phonemes = 1;
|
||||
} else {
|
||||
else
|
||||
flag_codes[n_flag_codes++] = flagnum;
|
||||
}
|
||||
} else {
|
||||
fprintf(f_log, "%5d: Unknown keyword: %s\n", linenum, mnemptr);
|
||||
error_count++;
|
||||
@@ -496,9 +494,8 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
|
||||
case 1:
|
||||
if ((c == '-') && multiple_words) {
|
||||
if (IsDigit09(word[0])) {
|
||||
if (IsDigit09(word[0]))
|
||||
multiple_numeric_hyphen = 1;
|
||||
}
|
||||
flag_codes[n_flag_codes++] = BITNUM_FLAG_HYPHENATED;
|
||||
c = ' ';
|
||||
}
|
||||
@@ -508,9 +505,8 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
if (multiple_words) {
|
||||
multiple_string = multiple_string_end = p+1;
|
||||
step = 2;
|
||||
} else {
|
||||
} else
|
||||
step = 3;
|
||||
}
|
||||
} else if (c == ')') {
|
||||
if (multiple_words) {
|
||||
p[0] = 0;
|
||||
@@ -525,9 +521,9 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (isspace2(c)) {
|
||||
if (isspace2(c))
|
||||
multiple_words++;
|
||||
} else if (c == ')') {
|
||||
else if (c == ')') {
|
||||
p[0] = ' '; // terminate extra string
|
||||
multiple_string_end = p+1;
|
||||
step = 3;
|
||||
@@ -554,9 +550,8 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
p++;
|
||||
}
|
||||
|
||||
if (word[0] == 0) {
|
||||
if (word[0] == 0)
|
||||
return 0; /* blank line */
|
||||
}
|
||||
|
||||
if (text_mode)
|
||||
text_not_phonemes = 1;
|
||||
@@ -577,15 +572,13 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
error_need_dictionary++;
|
||||
fprintf(f_log, "%5d: Need to compile dictionary again\n", linenum);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
// this is replacement text, so don't encode as phonemes. Restrict the length of the replacement word
|
||||
strncpy0(encoded_ph, phonetic, N_WORD_BYTES-4);
|
||||
}
|
||||
} else {
|
||||
EncodePhonemes(phonetic, encoded_ph, &bad_phoneme);
|
||||
if (strchr(encoded_ph, phonSWITCH) != 0) {
|
||||
if (strchr(encoded_ph, phonSWITCH) != 0)
|
||||
flag_codes[n_flag_codes++] = BITNUM_FLAG_ONLY_S; // don't match on suffixes (except 's') when switching languages
|
||||
}
|
||||
|
||||
// check for errors in the phonemes codes
|
||||
if (bad_phoneme != 0) {
|
||||
@@ -596,9 +589,8 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
}
|
||||
}
|
||||
|
||||
if (text_not_phonemes != translator->langopts.textmode) {
|
||||
if (text_not_phonemes != translator->langopts.textmode)
|
||||
flag_codes[n_flag_codes++] = BITNUM_FLAG_TEXTMODE;
|
||||
}
|
||||
|
||||
|
||||
if (sscanf(word, "U+%x", &wc) == 1) {
|
||||
@@ -617,23 +609,20 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
ix = utf8_in(&c2, p);
|
||||
if (c2 == 0)
|
||||
break;
|
||||
if (iswupper2(c2)) {
|
||||
if (iswupper2(c2))
|
||||
utf8_out(towlower2(c2), p);
|
||||
} else {
|
||||
else
|
||||
all_upper_case = 0;
|
||||
}
|
||||
p += ix;
|
||||
}
|
||||
if (all_upper_case) {
|
||||
if (all_upper_case)
|
||||
flag_codes[n_flag_codes++] = BITNUM_FLAG_ALLCAPS;
|
||||
}
|
||||
}
|
||||
|
||||
len_word = strlen(word);
|
||||
|
||||
if (translator->transpose_min > 0) {
|
||||
if (translator->transpose_min > 0)
|
||||
len_word = TransposeAlphabet(translator, word);
|
||||
}
|
||||
|
||||
*hash = HashDictionary(word);
|
||||
len_phonetic = strlen(encoded_ph);
|
||||
@@ -652,9 +641,8 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
strcpy(&dict_line[(len_word)+2], encoded_ph);
|
||||
}
|
||||
|
||||
for (ix = 0; ix < n_flag_codes; ix++) {
|
||||
for (ix = 0; ix < n_flag_codes; ix++)
|
||||
dict_line[ix+length] = flag_codes[ix];
|
||||
}
|
||||
length += n_flag_codes;
|
||||
|
||||
if ((multiple_string != NULL) && (multiple_words > 0)) {
|
||||
@@ -664,9 +652,8 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
} else {
|
||||
dict_line[length++] = 80 + multiple_words;
|
||||
ix = multiple_string_end - multiple_string;
|
||||
if (multiple_numeric_hyphen) {
|
||||
if (multiple_numeric_hyphen)
|
||||
dict_line[length++] = ' '; // ???
|
||||
}
|
||||
memcpy(&dict_line[length], multiple_string, ix);
|
||||
length += ix;
|
||||
}
|
||||
@@ -865,9 +852,8 @@ static void copy_rule_string(char *string, int *state_out)
|
||||
c = c2 * 16 + c3;
|
||||
literal = 1;
|
||||
p++;
|
||||
} else {
|
||||
} else
|
||||
hexdigit_input = 0;
|
||||
}
|
||||
}
|
||||
if ((state == 1) || (state == 3)) {
|
||||
// replace special characters (note: 'E' is reserved for a replaced silent 'e')
|
||||
@@ -960,9 +946,8 @@ static void copy_rule_string(char *string, int *state_out)
|
||||
// pre-rule, put the group number before the RULE_LETTERGP command
|
||||
output[ix++] = c;
|
||||
c = RULE_LETTERGP2;
|
||||
} else {
|
||||
} else
|
||||
output[ix++] = RULE_LETTERGP2;
|
||||
}
|
||||
break;
|
||||
|
||||
case '$':
|
||||
@@ -1199,9 +1184,8 @@ static char *compile_rule(char *input)
|
||||
// omit '_' at the beginning of the pre-string and imply it by using RULE_PRE_ATSTART
|
||||
c = RULE_PRE_ATSTART;
|
||||
start = 1;
|
||||
} else {
|
||||
} else
|
||||
c = RULE_PRE;
|
||||
}
|
||||
output[len++] = c;
|
||||
|
||||
// output PRE string in reverse order
|
||||
@@ -1574,17 +1558,15 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
|
||||
// group character is given as a character code (max 16 bits)
|
||||
p = (unsigned char *)group_name;
|
||||
|
||||
if (char_code > 0x100) {
|
||||
if (char_code > 0x100)
|
||||
*p++ = (char_code >> 8);
|
||||
}
|
||||
*p++ = char_code;
|
||||
*p = 0;
|
||||
} else {
|
||||
if (translator->letter_bits_offset > 0) {
|
||||
utf8_in(&wc, group_name);
|
||||
if (((ix = (wc - translator->letter_bits_offset)) >= 0) && (ix < 128)) {
|
||||
if (((ix = (wc - translator->letter_bits_offset)) >= 0) && (ix < 128))
|
||||
group3_ix = ix+1; // not zero
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1606,9 +1588,9 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
|
||||
case 1: // .group
|
||||
prule = compile_rule(buf);
|
||||
if (prule != NULL) {
|
||||
if (n_rules < N_RULES) {
|
||||
if (n_rules < N_RULES)
|
||||
rules[n_rules++] = prule;
|
||||
} else {
|
||||
else {
|
||||
if (err_n_rules == 0) {
|
||||
fprintf(stderr, "\nExceeded limit of rules (%d) in group '%s'\n", N_RULES, group_name);
|
||||
error_count++;
|
||||
@@ -1672,9 +1654,8 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
|
||||
n_groups3++;
|
||||
fputc(1, f_out);
|
||||
fputc(rgroup[gp].group3_ix, f_out);
|
||||
} else {
|
||||
} else
|
||||
fprintf(f_out, "%s", prev_rgroup_name = rgroup[gp].name);
|
||||
}
|
||||
fputc(0, f_out);
|
||||
}
|
||||
|
||||
@@ -1682,9 +1663,6 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
|
||||
c = fgetc(f_temp);
|
||||
fputc(c, f_out);
|
||||
}
|
||||
|
||||
if (different) {
|
||||
}
|
||||
}
|
||||
fputc(RULE_GROUP_END, f_out);
|
||||
fputc(0, f_out);
|
||||
|
||||
@@ -132,9 +132,8 @@ espeak_ng_STATUS espeak_ng_CompileMbrolaVoice(const char *filepath, FILE *log)
|
||||
Write4Bytes(f_out, mbrola_ctrl);
|
||||
|
||||
pw_end = (int *)(&data[count+1]);
|
||||
for (pw = (int *)data; pw < pw_end; pw++) {
|
||||
for (pw = (int *)data; pw < pw_end; pw++)
|
||||
Write4Bytes(f_out, *pw);
|
||||
}
|
||||
fclose(f_out);
|
||||
fprintf(log, "Mbrola translation file: %s -- %d phonemes\n", buf, count);
|
||||
return ENS_OK;
|
||||
|
||||
@@ -42,13 +42,11 @@ void debug_enter(const char *text)
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
if (!fd_log) {
|
||||
if (!fd_log)
|
||||
debug_init();
|
||||
}
|
||||
|
||||
if (fd_log) {
|
||||
if (fd_log)
|
||||
fprintf(fd_log, "%03d.%03dms > ENTER %s\n", (int)(tv.tv_sec%1000), (int)(tv.tv_usec/1000), text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,12 +54,10 @@ void debug_show(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
if (!fd_log) {
|
||||
if (!fd_log)
|
||||
debug_init();
|
||||
}
|
||||
if (fd_log) {
|
||||
if (fd_log)
|
||||
vfprintf(fd_log, format, args);
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
@@ -71,12 +67,10 @@ void debug_time(const char *text)
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
if (!fd_log) {
|
||||
if (!fd_log)
|
||||
debug_init();
|
||||
}
|
||||
if (fd_log) {
|
||||
if (fd_log)
|
||||
fprintf(fd_log, "%03d.%03dms > %s\n", (int)(tv.tv_sec%1000), (int)(tv.tv_usec/1000), text);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+72
-123
@@ -156,9 +156,8 @@ static void InitGroups(Translator *tr)
|
||||
if (p[0] == RULE_REPLACEMENTS) {
|
||||
pw = (unsigned int *)(((intptr_t)p+4) & ~3); // advance to next word boundary
|
||||
tr->langopts.replace_chars = pw;
|
||||
while (pw[0] != 0) {
|
||||
while (pw[0] != 0)
|
||||
pw += 2; // find the end of the replacement list, each entry is 2 words.
|
||||
}
|
||||
p = (char *)(pw+1);
|
||||
|
||||
#ifdef ARCH_BIG
|
||||
@@ -176,9 +175,8 @@ static void InitGroups(Translator *tr)
|
||||
if (p[0] == RULE_LETTERGP2) {
|
||||
ix = p[1] - 'A';
|
||||
p += 2;
|
||||
if ((ix >= 0) && (ix < N_LETTER_GROUPS)) {
|
||||
if ((ix >= 0) && (ix < N_LETTER_GROUPS))
|
||||
tr->letterGroups[ix] = p;
|
||||
}
|
||||
} else {
|
||||
len = strlen(p);
|
||||
p_name = p;
|
||||
@@ -186,11 +184,11 @@ static void InitGroups(Translator *tr)
|
||||
c2 = p_name[1];
|
||||
|
||||
p += (len+1);
|
||||
if (len == 1) {
|
||||
if (len == 1)
|
||||
tr->groups1[c] = p;
|
||||
} else if (len == 0) {
|
||||
else if (len == 0)
|
||||
tr->groups1[0] = p;
|
||||
} else if (c == 1) {
|
||||
else if (c == 1) {
|
||||
// index by offset from letter base
|
||||
tr->groups3[c2 - 1] = p;
|
||||
} else {
|
||||
@@ -204,9 +202,8 @@ static void InitGroups(Translator *tr)
|
||||
}
|
||||
|
||||
// skip over all the rules in this group
|
||||
while (*p != RULE_GROUP_END) {
|
||||
while (*p != RULE_GROUP_END)
|
||||
p += (strlen(p) + 1);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
@@ -240,9 +237,8 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
|
||||
|
||||
f = fopen(fname, "rb");
|
||||
if ((f == NULL) || (size <= 0)) {
|
||||
if (no_error == 0) {
|
||||
if (no_error == 0)
|
||||
fprintf(stderr, "Can't read dictionary file: '%s'\n", fname);
|
||||
}
|
||||
if (f != NULL)
|
||||
fclose(f);
|
||||
return 1;
|
||||
@@ -276,15 +272,13 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
|
||||
|
||||
for (hash = 0; hash < N_HASH_DICT; hash++) {
|
||||
tr->dict_hashtab[hash] = p;
|
||||
while ((length = *p) != 0) {
|
||||
while ((length = *p) != 0)
|
||||
p += length;
|
||||
}
|
||||
p++; // skip over the zero which terminates the list for this hash value
|
||||
}
|
||||
|
||||
if ((tr->dict_min_size > 0) && (size < (unsigned int)tr->dict_min_size)) {
|
||||
if ((tr->dict_min_size > 0) && (size < (unsigned int)tr->dict_min_size))
|
||||
fprintf(stderr, "Full dictionary is not installed for '%s'\n", name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -330,9 +324,8 @@ const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme)
|
||||
*bad_phoneme = 0;
|
||||
|
||||
// skip initial blanks
|
||||
while (isspace(*p)) {
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
}
|
||||
|
||||
while (((c = *p) != 0) && !isspace(c)) {
|
||||
consumed = 0;
|
||||
@@ -379,9 +372,8 @@ const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme)
|
||||
|
||||
if (max_ph == 0) {
|
||||
// not recognised, report and ignore
|
||||
if (bad_phoneme != NULL) {
|
||||
if (bad_phoneme != NULL)
|
||||
utf8_in(bad_phoneme, p);
|
||||
}
|
||||
*outptr++ = 0;
|
||||
return p+1;
|
||||
}
|
||||
@@ -404,9 +396,8 @@ const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme)
|
||||
*p_lang = 0; // don't need "en", it's assumed by default
|
||||
return p;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
*outptr++ = '|'; // more phonemes follow, terminate language string with separator
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -445,9 +436,8 @@ void DecodePhonemes(const char *inptr, char *outptr)
|
||||
mnem = mnem >> 8;
|
||||
}
|
||||
if (phcode == phonSWITCH) {
|
||||
while (isalpha(*inptr)) {
|
||||
while (isalpha(*inptr))
|
||||
*outptr++ = *inptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -497,11 +487,10 @@ char *WritePhMnemonic(char *phon_out, PHONEME_TAB *ph, PHONEME_LIST *plist, int
|
||||
// has an ipa name been defined for this phoneme ?
|
||||
phdata.ipa_string[0] = 0;
|
||||
|
||||
if (plist == NULL) {
|
||||
if (plist == NULL)
|
||||
InterpretPhoneme2(ph->code, &phdata);
|
||||
} else {
|
||||
else
|
||||
InterpretPhoneme(NULL, 0, plist, &phdata, NULL);
|
||||
}
|
||||
|
||||
p = phdata.ipa_string;
|
||||
if (*p == 0x20) {
|
||||
@@ -546,9 +535,8 @@ char *WritePhMnemonic(char *phon_out, PHONEME_TAB *ph, PHONEME_LIST *plist, int
|
||||
c = ipa1[c-0x20];
|
||||
|
||||
ix += utf8_out(c, &phon_out[ix]);
|
||||
} else {
|
||||
} else
|
||||
phon_out[ix++] = c;
|
||||
}
|
||||
first = 0;
|
||||
}
|
||||
|
||||
@@ -619,9 +607,8 @@ const char *GetTranslatedPhonemeString(int phoneme_mode)
|
||||
if ((!plist->newword) || (separate_phonemes == ' ')) {
|
||||
if ((separate_phonemes != 0) && (ix > 1)) {
|
||||
utf8_in(&c, phon_buf2);
|
||||
if ((c < 0x2b0) || (c > 0x36f)) { // not if the phoneme starts with a superscript letter
|
||||
if ((c < 0x2b0) || (c > 0x36f)) // not if the phoneme starts with a superscript letter
|
||||
buf += utf8_out(separate_phonemes, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -634,13 +621,11 @@ const char *GetTranslatedPhonemeString(int phoneme_mode)
|
||||
c = 0x2cc; // ipa, secondary stress
|
||||
if (stress > 3)
|
||||
c = 0x02c8; // ipa, primary stress
|
||||
} else {
|
||||
} else
|
||||
c = stress_chars[stress];
|
||||
}
|
||||
|
||||
if (c != 0) {
|
||||
if (c != 0)
|
||||
buf += utf8_out(c, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,25 +635,22 @@ const char *GetTranslatedPhonemeString(int phoneme_mode)
|
||||
p += utf8_in(&c, p);
|
||||
if (use_tie != 0) {
|
||||
// look for non-inital alphabetic character, but not diacritic, superscript etc.
|
||||
if ((count > 0) && !(flags & (1 << (count-1))) && ((c < 0x2b0) || (c > 0x36f)) && iswalpha2(c)) {
|
||||
if ((count > 0) && !(flags & (1 << (count-1))) && ((c < 0x2b0) || (c > 0x36f)) && iswalpha2(c))
|
||||
buf += utf8_out(use_tie, buf);
|
||||
}
|
||||
}
|
||||
buf += utf8_out(c, buf);
|
||||
count++;
|
||||
}
|
||||
|
||||
if (plist->ph->code != phonSWITCH) {
|
||||
if (plist->synthflags & SFLAG_LENGTHEN) {
|
||||
if (plist->synthflags & SFLAG_LENGTHEN)
|
||||
buf = WritePhMnemonic(buf, phoneme_tab[phonLENGTHEN], NULL, use_ipa, NULL);
|
||||
}
|
||||
if ((plist->synthflags & SFLAG_SYLLABLE) && (plist->type != phVOWEL)) {
|
||||
// syllablic consonant
|
||||
buf = WritePhMnemonic(buf, phoneme_tab[phonSYLLABIC], NULL, use_ipa, NULL);
|
||||
}
|
||||
if (plist->tone_ph > 0) {
|
||||
if (plist->tone_ph > 0)
|
||||
buf = WritePhMnemonic(buf, phoneme_tab[plist->tone_ph], NULL, use_ipa, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
len = buf - phon_buf;
|
||||
@@ -711,9 +693,8 @@ static int IsLetterGroup(Translator *tr, char *word, int group, int pre)
|
||||
if (pre) {
|
||||
len = strlen(p);
|
||||
w = word - len + 1;
|
||||
} else {
|
||||
} else
|
||||
w = word;
|
||||
}
|
||||
while ((*p == *w) && (*w != 0)) {
|
||||
w++;
|
||||
p++;
|
||||
@@ -1108,9 +1089,8 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
}
|
||||
|
||||
max_stress = max_stress_input = GetVowelStress(tr, phonetic, vowel_stress, &vowel_count, &stressed_syllable, 1);
|
||||
if ((max_stress < 0) && dictionary_flags) {
|
||||
if ((max_stress < 0) && dictionary_flags)
|
||||
max_stress = 0;
|
||||
}
|
||||
|
||||
// heavy or light syllables
|
||||
ix = 1;
|
||||
@@ -1151,9 +1131,8 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
// stress on second syllable
|
||||
if ((stressed_syllable == 0) && (vowel_count > 2)) {
|
||||
stressed_syllable = 2;
|
||||
if (max_stress == 0) {
|
||||
if (max_stress == 0)
|
||||
vowel_stress[stressed_syllable] = 4;
|
||||
}
|
||||
max_stress = 4;
|
||||
}
|
||||
break;
|
||||
@@ -1191,18 +1170,16 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
} else {
|
||||
if ((mnem == 's') && (phoneme_tab[final_ph2]->type == phNASAL)) {
|
||||
// -ns stress remains on penultimate syllable
|
||||
} else if (((phoneme_tab[final_ph]->type != phNASAL) && (mnem != 's')) || (phoneme_tab[final_ph2]->type != phVOWEL)) {
|
||||
} else if (((phoneme_tab[final_ph]->type != phNASAL) && (mnem != 's')) || (phoneme_tab[final_ph2]->type != phVOWEL))
|
||||
stressed_syllable = vowel_count - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stressflags & S_FINAL_LONG) {
|
||||
// stress on last syllable if it has a long vowel, but previous syllable has a short vowel
|
||||
if (vowel_length[vowel_count - 1] > vowel_length[vowel_count - 2]) {
|
||||
if (vowel_length[vowel_count - 1] > vowel_length[vowel_count - 2])
|
||||
stressed_syllable = vowel_count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((vowel_stress[stressed_syllable] == 0) || (vowel_stress[stressed_syllable] == 1)) {
|
||||
@@ -1249,9 +1226,8 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
if (stressed_syllable < 1)
|
||||
stressed_syllable = 1;
|
||||
|
||||
if (max_stress == 0) {
|
||||
if (max_stress == 0)
|
||||
vowel_stress[stressed_syllable] = 4;
|
||||
}
|
||||
max_stress = 4;
|
||||
}
|
||||
break;
|
||||
@@ -1394,9 +1370,8 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
|
||||
if ((stressflags & S_INITIAL_2) && (vowel_stress[1] < 0)) {
|
||||
// If there is only one syllable before the primary stress, give it a secondary stress
|
||||
if ((vowel_count > 3) && (vowel_stress[2] >= 4)) {
|
||||
if ((vowel_count > 3) && (vowel_stress[2] >= 4))
|
||||
vowel_stress[1] = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1479,11 +1454,10 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
if ((tr->langopts.vowel_pause & 0x30) && (ph->type == phVOWEL)) {
|
||||
// word starts with a vowel
|
||||
|
||||
if ((tr->langopts.vowel_pause & 0x20) && (vowel_stress[1] >= 4)) {
|
||||
if ((tr->langopts.vowel_pause & 0x20) && (vowel_stress[1] >= 4))
|
||||
*output++ = phonPAUSE_NOLINK; // not to be replaced by link
|
||||
} else {
|
||||
else
|
||||
*output++ = phonPAUSE_VSHORT; // break, but no pause
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1492,9 +1466,9 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
if ((ph = phoneme_tab[phcode]) == NULL)
|
||||
continue;
|
||||
|
||||
if (ph->type == phPAUSE) {
|
||||
if (ph->type == phPAUSE)
|
||||
tr->prev_last_stress = 0;
|
||||
} else if (((ph->type == phVOWEL) && !(ph->phflags & phNONSYLLABIC)) || (*p == phonSYLLABIC)) {
|
||||
else if (((ph->type == phVOWEL) && !(ph->phflags & phNONSYLLABIC)) || (*p == phonSYLLABIC)) {
|
||||
// a vowel, or a consonant followed by a syllabic consonant marker
|
||||
|
||||
v_stress = vowel_stress[v];
|
||||
@@ -1523,9 +1497,8 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
*output++ = stress_phonemes[v_stress]; // mark stress of all vowels except 1 (unstressed)
|
||||
|
||||
|
||||
if (vowel_stress[v] > max_stress) {
|
||||
if (vowel_stress[v] > max_stress)
|
||||
max_stress = vowel_stress[v];
|
||||
}
|
||||
|
||||
if ((*p == phonLENGTHEN) && ((opt_length = tr->langopts.param[LOPT_IT_LENGTHEN]) & 1)) {
|
||||
// remove lengthen indicator from non-stressed syllables
|
||||
@@ -1577,9 +1550,8 @@ void AppendPhonemes(Translator *tr, char *string, int size, const char *ph)
|
||||
int length;
|
||||
|
||||
length = strlen(ph) + strlen(string);
|
||||
if (length >= size) {
|
||||
if (length >= size)
|
||||
return;
|
||||
}
|
||||
|
||||
/* any stressable vowel ? */
|
||||
unstress_mark = 0;
|
||||
@@ -1718,9 +1690,8 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
if (rb == RULE_LINENUM)
|
||||
match.phonemes += 2; // skip over line number
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
match.phonemes = "";
|
||||
}
|
||||
rule--; // so we are still pointing at the 0
|
||||
failed = 2; // matched OK
|
||||
break;
|
||||
@@ -1826,9 +1797,9 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
break;
|
||||
|
||||
case RULE_NOTVOWEL:
|
||||
if (IsLetter(tr, letter_w, 0) || ((letter_w == ' ') && (word_flags & FLAG_SUFFIX_VOWEL))) {
|
||||
if (IsLetter(tr, letter_w, 0) || ((letter_w == ' ') && (word_flags & FLAG_SUFFIX_VOWEL)))
|
||||
failed = 1;
|
||||
} else {
|
||||
else {
|
||||
add_points = (20-distance_right);
|
||||
post_ptr += letter_xbytes;
|
||||
}
|
||||
@@ -1863,9 +1834,9 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
|
||||
case RULE_DOLLAR:
|
||||
command = *rule++;
|
||||
if (command == DOLLAR_UNPR) {
|
||||
if (command == DOLLAR_UNPR)
|
||||
match.end_type = SUFX_UNPRON; // $unpron
|
||||
} else if (command == DOLLAR_NOPREFIX) { // $noprefix
|
||||
else if (command == DOLLAR_NOPREFIX) { // $noprefix
|
||||
if (word_flags & FLAG_PREFIX_REMOVED)
|
||||
failed = 1; // a prefix has been removed
|
||||
else
|
||||
@@ -1895,9 +1866,9 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
break;
|
||||
|
||||
case '-':
|
||||
if ((letter == '-') || ((letter == ' ') && (word_flags & FLAG_HYPHEN_AFTER))) {
|
||||
if ((letter == '-') || ((letter == ' ') && (word_flags & FLAG_HYPHEN_AFTER)))
|
||||
add_points = (22-distance_right); // one point more than match against space
|
||||
} else
|
||||
else
|
||||
failed = 1;
|
||||
break;
|
||||
|
||||
@@ -1956,9 +1927,8 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
p2 = p;
|
||||
p += utf8_in(&letter_w, p);
|
||||
}
|
||||
if (letter_w == rule_w) {
|
||||
if (letter_w == rule_w)
|
||||
post_ptr = p2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2158,9 +2128,9 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
break;
|
||||
|
||||
case '-':
|
||||
if ((letter == '-') || ((letter == ' ') && (word_flags & FLAG_HYPHEN))) {
|
||||
if ((letter == '-') || ((letter == ' ') && (word_flags & FLAG_HYPHEN)))
|
||||
add_points = (22-distance_right); // one point more than match against space
|
||||
} else
|
||||
else
|
||||
failed = 1;
|
||||
break;
|
||||
|
||||
@@ -2168,11 +2138,9 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
if (letter == rb) {
|
||||
if (letter == RULE_SPACE)
|
||||
add_points = 4;
|
||||
else {
|
||||
if ((letter & 0xc0) != 0x80) {
|
||||
// not for non-initial UTF-8 bytes
|
||||
add_points = (21-distance_left);
|
||||
}
|
||||
else if ((letter & 0xc0) != 0x80) {
|
||||
// not for non-initial UTF-8 bytes
|
||||
add_points = (21-distance_left);
|
||||
}
|
||||
} else
|
||||
failed = 1;
|
||||
@@ -2276,9 +2244,8 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
char wordbuf[120];
|
||||
unsigned int ix;
|
||||
|
||||
for (ix = 0; ((c = p_start[ix]) != ' ') && (c != 0) && (ix < (sizeof(wordbuf)-1)); ix++) {
|
||||
for (ix = 0; ((c = p_start[ix]) != ' ') && (c != 0) && (ix < (sizeof(wordbuf)-1)); ix++)
|
||||
wordbuf[ix] = c;
|
||||
}
|
||||
wordbuf[ix] = 0;
|
||||
if (word_flags & FLAG_UNPRON_TEST)
|
||||
fprintf(f_trans, "Unpronouncable? '%s'\n", wordbuf);
|
||||
@@ -2457,9 +2424,8 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((option_phonemes & espeakPHONEMES_TRACE) && ((word_flags & FLAG_NO_TRACE) == 0)) {
|
||||
if ((option_phonemes & espeakPHONEMES_TRACE) && ((word_flags & FLAG_NO_TRACE) == 0))
|
||||
fprintf(f_trans, "\n");
|
||||
}
|
||||
|
||||
match1.end_type &= ~SUFX_UNPRON;
|
||||
|
||||
@@ -2555,13 +2521,13 @@ int TransposeAlphabet(Translator *tr, char *text)
|
||||
p += utf8_in(&c, p);
|
||||
if (c != 0) {
|
||||
if ((c >= min) && (c <= max)) {
|
||||
if (map == NULL) {
|
||||
if (map == NULL)
|
||||
buf[bufix++] = c - offset;
|
||||
} else {
|
||||
else {
|
||||
// get the code from the transpose map
|
||||
if (map[c - min] > 0) {
|
||||
if (map[c - min] > 0)
|
||||
buf[bufix++] = map[c - min];
|
||||
} else {
|
||||
else {
|
||||
all_alpha = 0;
|
||||
break;
|
||||
}
|
||||
@@ -2608,9 +2574,8 @@ int TransposeAlphabet(Translator *tr, char *text)
|
||||
ix = p2 - buf;
|
||||
memcpy(text, buf, ix);
|
||||
return ix | 0x40; // bit 6 indicates compressed characters
|
||||
} else {
|
||||
return strlen(text);
|
||||
}
|
||||
return strlen(text);
|
||||
}
|
||||
|
||||
|
||||
@@ -2650,9 +2615,8 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
|
||||
char word_buf[N_WORD_BYTES+1];
|
||||
char dict_flags_buf[80];
|
||||
|
||||
if (wtab != NULL) {
|
||||
if (wtab != NULL)
|
||||
wflags = wtab->flags;
|
||||
}
|
||||
|
||||
lookup_symbol = flags[1] & FLAG_LOOKUP_SYMBOL;
|
||||
word1 = word;
|
||||
@@ -2660,9 +2624,8 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
|
||||
strncpy0(word_buf, word, N_WORD_BYTES);
|
||||
wlen = TransposeAlphabet(tr, word_buf); // bit 6 indicates compressed characters
|
||||
word = word_buf;
|
||||
} else {
|
||||
} else
|
||||
wlen = strlen(word);
|
||||
}
|
||||
|
||||
hash = HashDictionary(word);
|
||||
p = tr->dict_hashtab[hash];
|
||||
@@ -2728,9 +2691,8 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
|
||||
// or has an embedded command, such as MARK
|
||||
if (wtab != NULL) {
|
||||
for (ix = 0; ix <= skipwords; ix++) {
|
||||
if (wtab[ix].flags & FLAG_EMPHASIZED2) {
|
||||
if (wtab[ix].flags & FLAG_EMPHASIZED2)
|
||||
condition_failed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2751,11 +2713,10 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
|
||||
dictionary_flags = (dictionary_flags & ~0xf) | (flag & 0xf);
|
||||
if ((flag & 0xc) == 0xc)
|
||||
dictionary_flags |= FLAG_STRESS_END;
|
||||
} else if (flag >= 32) {
|
||||
} else if (flag >= 32)
|
||||
dictionary_flags2 |= (1L << (flag-32));
|
||||
} else {
|
||||
else
|
||||
dictionary_flags |= (1L << flag);
|
||||
}
|
||||
}
|
||||
|
||||
if (condition_failed) {
|
||||
@@ -2784,19 +2745,16 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
|
||||
}
|
||||
|
||||
if (dictionary_flags2 & FLAG_HYPHENATED) {
|
||||
if (!(wflags & FLAG_HYPHEN_AFTER)) {
|
||||
if (!(wflags & FLAG_HYPHEN_AFTER))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (dictionary_flags2 & FLAG_CAPITAL) {
|
||||
if (!(wflags & FLAG_FIRST_UPPER)) {
|
||||
if (!(wflags & FLAG_FIRST_UPPER))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (dictionary_flags2 & FLAG_ALLCAPS) {
|
||||
if (!(wflags & FLAG_ALL_UPPER)) {
|
||||
if (!(wflags & FLAG_ALL_UPPER))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (dictionary_flags & FLAG_NEEDS_DOT) {
|
||||
if (!(wflags & FLAG_HAS_DOT))
|
||||
@@ -2892,18 +2850,16 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
|
||||
memcpy(word_buf, word2, word_end-word2);
|
||||
word_buf[word_end-word2-1] = 0;
|
||||
fprintf(f_trans, "Found: '%s %s\n", word1, word_buf);
|
||||
} else {
|
||||
} else
|
||||
fprintf(f_trans, "Found: '%s", word1);
|
||||
}
|
||||
print_dictionary_flags(flags, dict_flags_buf, sizeof(dict_flags_buf));
|
||||
fprintf(f_trans, "' [%s] %s\n", ph_decoded, dict_flags_buf);
|
||||
}
|
||||
}
|
||||
|
||||
ix = utf8_in(&c, word);
|
||||
if ((word[ix] == 0) && !IsAlpha(c)) {
|
||||
if ((word[ix] == 0) && !IsAlpha(c))
|
||||
flags[0] |= FLAG_MAX3;
|
||||
}
|
||||
return word_end;
|
||||
|
||||
}
|
||||
@@ -2943,9 +2899,8 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
|
||||
if (length > 0) {
|
||||
// found an abbreviation containing dots
|
||||
nbytes = 0;
|
||||
while (((c = word2[nbytes]) != 0) && (c != ' ')) {
|
||||
while (((c = word2[nbytes]) != 0) && (c != ' '))
|
||||
nbytes++;
|
||||
}
|
||||
memcpy(&word[length], word2, nbytes);
|
||||
word[length+nbytes] = 0;
|
||||
found = LookupDict2(tr, word, word2, ph_out, flags, end_flags, wtab);
|
||||
@@ -2974,16 +2929,14 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
|
||||
if (flags[0] & FLAG_MAX3) {
|
||||
if (strcmp(ph_out, tr->phonemes_repeat) == 0) {
|
||||
tr->phonemes_repeat_count++;
|
||||
if (tr->phonemes_repeat_count > 3) {
|
||||
if (tr->phonemes_repeat_count > 3)
|
||||
ph_out[0] = 0;
|
||||
}
|
||||
} else {
|
||||
strncpy0(tr->phonemes_repeat, ph_out, sizeof(tr->phonemes_repeat));
|
||||
tr->phonemes_repeat_count = 1;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
tr->phonemes_repeat_count = 0;
|
||||
}
|
||||
|
||||
|
||||
if ((found == 0) && (flags[1] & FLAG_ACCENT)) {
|
||||
@@ -3062,9 +3015,8 @@ int Lookup(Translator *tr, const char *word, char *ph_out)
|
||||
|
||||
flags[0] = 0;
|
||||
flags[1] = FLAG_LOOKUP_SYMBOL;
|
||||
if ((flags0 = LookupDictList(tr, &word1, ph_out, flags, FLAG_ALLOW_TEXTMODE, NULL)) != 0) {
|
||||
if ((flags0 = LookupDictList(tr, &word1, ph_out, flags, FLAG_ALLOW_TEXTMODE, NULL)) != 0)
|
||||
flags0 = flags[0];
|
||||
}
|
||||
|
||||
if (flags[0] & FLAG_TEXTMODE) {
|
||||
say_as = option_sayas;
|
||||
@@ -3176,9 +3128,8 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
||||
|
||||
for (i = 0; (p = add_e_exceptions[i]) != NULL; i++) {
|
||||
len = strlen(p);
|
||||
if (memcmp(p, &word_end[1-len], len) == 0) {
|
||||
if (memcmp(p, &word_end[1-len], len) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (p == NULL)
|
||||
end_flags |= FLAG_SUFX_E_ADDED; // no exception found
|
||||
@@ -3191,16 +3142,14 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (tr->langopts.suffix_add_e != 0) {
|
||||
} else if (tr->langopts.suffix_add_e != 0)
|
||||
end_flags |= FLAG_SUFX_E_ADDED;
|
||||
}
|
||||
|
||||
if (end_flags & FLAG_SUFX_E_ADDED) {
|
||||
utf8_out(tr->langopts.suffix_add_e, &word_end[1]);
|
||||
|
||||
if (option_phonemes & espeakPHONEMES_TRACE) {
|
||||
if (option_phonemes & espeakPHONEMES_TRACE)
|
||||
fprintf(f_trans, "add e\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,14 +37,12 @@ t_espeak_command *create_espeak_text(const void *text, size_t size, unsigned int
|
||||
t_espeak_text *data = NULL;
|
||||
t_espeak_command *a_command = (t_espeak_command *)malloc(sizeof(t_espeak_command));
|
||||
|
||||
if (!text || !size || !a_command) {
|
||||
if (!text || !size || !a_command)
|
||||
goto text_error;
|
||||
}
|
||||
|
||||
a_text = malloc(size+1);
|
||||
if (!a_text) {
|
||||
if (!a_text)
|
||||
goto text_error;
|
||||
}
|
||||
memcpy(a_text, text, size);
|
||||
|
||||
a_command->type = ET_TEXT;
|
||||
@@ -64,12 +62,10 @@ t_espeak_command *create_espeak_text(const void *text, size_t size, unsigned int
|
||||
|
||||
text_error:
|
||||
if (a_error) {
|
||||
if (a_text) {
|
||||
if (a_text)
|
||||
free(a_text);
|
||||
}
|
||||
if (a_command) {
|
||||
if (a_command)
|
||||
free(a_command);
|
||||
}
|
||||
a_command = NULL;
|
||||
}
|
||||
|
||||
@@ -85,9 +81,8 @@ t_espeak_command *create_espeak_terminated_msg(unsigned int unique_identifier, v
|
||||
t_espeak_terminated_msg *data = NULL;
|
||||
t_espeak_command *a_command = (t_espeak_command *)malloc(sizeof(t_espeak_command));
|
||||
|
||||
if (!a_command) {
|
||||
if (!a_command)
|
||||
goto msg_error;
|
||||
}
|
||||
|
||||
a_command->type = ET_TERMINATED_MSG;
|
||||
a_command->state = CS_UNDEFINED;
|
||||
@@ -100,9 +95,8 @@ t_espeak_command *create_espeak_terminated_msg(unsigned int unique_identifier, v
|
||||
|
||||
msg_error:
|
||||
if (a_error) {
|
||||
if (a_command) {
|
||||
if (a_command)
|
||||
free(a_command);
|
||||
}
|
||||
a_command = NULL;
|
||||
}
|
||||
|
||||
@@ -121,14 +115,12 @@ t_espeak_command *create_espeak_mark(const void *text, size_t size, const char *
|
||||
t_espeak_mark *data = NULL;
|
||||
t_espeak_command *a_command = (t_espeak_command *)malloc(sizeof(t_espeak_command));
|
||||
|
||||
if (!text || !size || !index_mark || !a_command) {
|
||||
if (!text || !size || !index_mark || !a_command)
|
||||
goto mark_error;
|
||||
}
|
||||
|
||||
a_text = malloc(size);
|
||||
if (!a_text) {
|
||||
if (!a_text)
|
||||
goto mark_error;
|
||||
}
|
||||
memcpy(a_text, text, size);
|
||||
|
||||
a_index_mark = strdup(index_mark);
|
||||
@@ -147,16 +139,13 @@ t_espeak_command *create_espeak_mark(const void *text, size_t size, const char *
|
||||
|
||||
mark_error:
|
||||
if (a_error) {
|
||||
if (a_text) {
|
||||
if (a_text)
|
||||
free(a_text);
|
||||
}
|
||||
if (a_command) {
|
||||
if (a_command)
|
||||
free(a_command);
|
||||
}
|
||||
a_command = NULL;
|
||||
if (a_index_mark) {
|
||||
if (a_index_mark)
|
||||
free(a_index_mark);
|
||||
}
|
||||
}
|
||||
|
||||
SHOW("ET_MARK malloc text=%x, command=%x (uid=%d)\n", a_text, a_command, data->unique_identifier);
|
||||
@@ -170,9 +159,8 @@ t_espeak_command *create_espeak_key(const char *key_name, void *user_data)
|
||||
int a_error = 1;
|
||||
t_espeak_command *a_command = (t_espeak_command *)malloc(sizeof(t_espeak_command));
|
||||
|
||||
if (!key_name || !a_command) {
|
||||
if (!key_name || !a_command)
|
||||
goto key_error;
|
||||
}
|
||||
|
||||
a_command->type = ET_KEY;
|
||||
a_command->state = CS_UNDEFINED;
|
||||
@@ -183,9 +171,8 @@ t_espeak_command *create_espeak_key(const char *key_name, void *user_data)
|
||||
|
||||
key_error:
|
||||
if (a_error) {
|
||||
if (a_command) {
|
||||
if (a_command)
|
||||
free(a_command);
|
||||
}
|
||||
a_command = NULL;
|
||||
}
|
||||
|
||||
@@ -199,9 +186,8 @@ t_espeak_command *create_espeak_char(wchar_t character, void *user_data)
|
||||
ENTER("create_espeak_char");
|
||||
int a_error = 1;
|
||||
t_espeak_command *a_command = (t_espeak_command *)malloc(sizeof(t_espeak_command));
|
||||
if (!a_command) {
|
||||
if (!a_command)
|
||||
goto char_error;
|
||||
}
|
||||
|
||||
a_command->type = ET_CHAR;
|
||||
a_command->state = CS_UNDEFINED;
|
||||
@@ -212,9 +198,8 @@ t_espeak_command *create_espeak_char(wchar_t character, void *user_data)
|
||||
|
||||
char_error:
|
||||
if (a_error) {
|
||||
if (a_command) {
|
||||
if (a_command)
|
||||
free(a_command);
|
||||
}
|
||||
a_command = NULL;
|
||||
}
|
||||
|
||||
@@ -229,9 +214,8 @@ t_espeak_command *create_espeak_parameter(espeak_PARAMETER parameter, int value,
|
||||
int a_error = 1;
|
||||
t_espeak_parameter *data = NULL;
|
||||
t_espeak_command *a_command = (t_espeak_command *)malloc(sizeof(t_espeak_command));
|
||||
if (!a_command) {
|
||||
if (!a_command)
|
||||
goto param_error;
|
||||
}
|
||||
|
||||
a_command->type = ET_PARAMETER;
|
||||
a_command->state = CS_UNDEFINED;
|
||||
@@ -243,9 +227,8 @@ t_espeak_command *create_espeak_parameter(espeak_PARAMETER parameter, int value,
|
||||
|
||||
param_error:
|
||||
if (a_error) {
|
||||
if (a_command) {
|
||||
if (a_command)
|
||||
free(a_command);
|
||||
}
|
||||
a_command = NULL;
|
||||
}
|
||||
|
||||
@@ -260,27 +243,23 @@ t_espeak_command *create_espeak_punctuation_list(const wchar_t *punctlist)
|
||||
int a_error = 1;
|
||||
t_espeak_command *a_command = (t_espeak_command *)malloc(sizeof(t_espeak_command));
|
||||
|
||||
if (!punctlist || !a_command) {
|
||||
if (!punctlist || !a_command)
|
||||
goto list_error;
|
||||
}
|
||||
|
||||
a_command->type = ET_PUNCTUATION_LIST;
|
||||
a_command->state = CS_UNDEFINED;
|
||||
|
||||
{
|
||||
size_t len = (wcslen(punctlist) + 1)*sizeof(wchar_t);
|
||||
wchar_t *a_list = (wchar_t *)malloc(len);
|
||||
memcpy(a_list, punctlist, len);
|
||||
a_command->u.my_punctuation_list = a_list;
|
||||
}
|
||||
size_t len = (wcslen(punctlist) + 1)*sizeof(wchar_t);
|
||||
wchar_t *a_list = (wchar_t *)malloc(len);
|
||||
memcpy(a_list, punctlist, len);
|
||||
a_command->u.my_punctuation_list = a_list;
|
||||
|
||||
a_error = 0;
|
||||
|
||||
list_error:
|
||||
if (a_error) {
|
||||
if (a_command) {
|
||||
if (a_command)
|
||||
free(a_command);
|
||||
}
|
||||
a_command = NULL;
|
||||
}
|
||||
|
||||
@@ -296,9 +275,8 @@ t_espeak_command *create_espeak_voice_name(const char *name)
|
||||
int a_error = 1;
|
||||
t_espeak_command *a_command = (t_espeak_command *)malloc(sizeof(t_espeak_command));
|
||||
|
||||
if (!name || !a_command) {
|
||||
if (!name || !a_command)
|
||||
goto name_error;
|
||||
}
|
||||
|
||||
a_command->type = ET_VOICE_NAME;
|
||||
a_command->state = CS_UNDEFINED;
|
||||
@@ -307,9 +285,8 @@ t_espeak_command *create_espeak_voice_name(const char *name)
|
||||
|
||||
name_error:
|
||||
if (a_error) {
|
||||
if (a_command) {
|
||||
if (a_command)
|
||||
free(a_command);
|
||||
}
|
||||
a_command = NULL;
|
||||
}
|
||||
|
||||
@@ -324,36 +301,30 @@ t_espeak_command *create_espeak_voice_spec(espeak_VOICE *voice)
|
||||
int a_error = 1;
|
||||
t_espeak_command *a_command = (t_espeak_command *)malloc(sizeof(t_espeak_command));
|
||||
|
||||
if (!voice || !a_command) {
|
||||
if (!voice || !a_command)
|
||||
goto spec_error;
|
||||
}
|
||||
|
||||
a_command->type = ET_VOICE_SPEC;
|
||||
a_command->state = CS_UNDEFINED;
|
||||
{
|
||||
espeak_VOICE *data = &(a_command->u.my_voice_spec);
|
||||
memcpy(data, voice, sizeof(espeak_VOICE));
|
||||
|
||||
if (voice->name) {
|
||||
data->name = strdup(voice->name);
|
||||
}
|
||||
espeak_VOICE *data = &(a_command->u.my_voice_spec);
|
||||
memcpy(data, voice, sizeof(espeak_VOICE));
|
||||
|
||||
if (voice->languages) {
|
||||
data->languages = strdup(voice->languages);
|
||||
}
|
||||
if (voice->name)
|
||||
data->name = strdup(voice->name);
|
||||
|
||||
if (voice->identifier) {
|
||||
data->identifier = strdup(voice->identifier);
|
||||
}
|
||||
if (voice->languages)
|
||||
data->languages = strdup(voice->languages);
|
||||
|
||||
a_error = 0;
|
||||
}
|
||||
if (voice->identifier)
|
||||
data->identifier = strdup(voice->identifier);
|
||||
|
||||
a_error = 0;
|
||||
|
||||
spec_error:
|
||||
if (a_error) {
|
||||
if (a_command) {
|
||||
if (a_command)
|
||||
free(a_command);
|
||||
}
|
||||
a_command = NULL;
|
||||
}
|
||||
|
||||
@@ -377,12 +348,10 @@ int delete_espeak_command(t_espeak_command *the_command)
|
||||
break;
|
||||
|
||||
case ET_MARK:
|
||||
if (the_command->u.my_mark.text) {
|
||||
if (the_command->u.my_mark.text)
|
||||
free(the_command->u.my_mark.text);
|
||||
}
|
||||
if (the_command->u.my_mark.index_mark) {
|
||||
if (the_command->u.my_mark.index_mark)
|
||||
free((void *)(the_command->u.my_mark.index_mark));
|
||||
}
|
||||
break;
|
||||
|
||||
case ET_TERMINATED_MSG:
|
||||
@@ -401,9 +370,8 @@ int delete_espeak_command(t_espeak_command *the_command)
|
||||
break;
|
||||
|
||||
case ET_KEY:
|
||||
if (the_command->u.my_key.key_name) {
|
||||
if (the_command->u.my_key.key_name)
|
||||
free((void *)(the_command->u.my_key.key_name));
|
||||
}
|
||||
break;
|
||||
|
||||
case ET_CHAR:
|
||||
@@ -412,32 +380,27 @@ int delete_espeak_command(t_espeak_command *the_command)
|
||||
break;
|
||||
|
||||
case ET_PUNCTUATION_LIST:
|
||||
if (the_command->u.my_punctuation_list) {
|
||||
if (the_command->u.my_punctuation_list)
|
||||
free((void *)(the_command->u.my_punctuation_list));
|
||||
}
|
||||
break;
|
||||
|
||||
case ET_VOICE_NAME:
|
||||
if (the_command->u.my_voice_name) {
|
||||
if (the_command->u.my_voice_name)
|
||||
free((void *)(the_command->u.my_voice_name));
|
||||
}
|
||||
break;
|
||||
|
||||
case ET_VOICE_SPEC:
|
||||
{
|
||||
espeak_VOICE *data = &(the_command->u.my_voice_spec);
|
||||
|
||||
if (data->name) {
|
||||
if (data->name)
|
||||
free((void *)data->name);
|
||||
}
|
||||
|
||||
if (data->languages) {
|
||||
if (data->languages)
|
||||
free((void *)data->languages);
|
||||
}
|
||||
|
||||
if (data->identifier) {
|
||||
if (data->identifier)
|
||||
free((void *)data->identifier);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -457,9 +420,8 @@ void process_espeak_command(t_espeak_command *the_command)
|
||||
|
||||
SHOW("command=0x%x\n", the_command);
|
||||
|
||||
if (the_command == NULL) {
|
||||
if (the_command == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
the_command->state = CS_PROCESSED;
|
||||
|
||||
|
||||
+23
-45
@@ -105,9 +105,9 @@ static void event_display(espeak_EVENT *event)
|
||||
ENTER("event_display");
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (event == NULL) {
|
||||
if (event == NULL)
|
||||
SHOW("event_display > event=%s\n", "NULL");
|
||||
} else {
|
||||
else {
|
||||
static const char *label[] = {
|
||||
"LIST_TERMINATED",
|
||||
"WORD",
|
||||
@@ -137,9 +137,8 @@ static espeak_EVENT *event_copy(espeak_EVENT *event)
|
||||
{
|
||||
ENTER("event_copy");
|
||||
|
||||
if (event == NULL) {
|
||||
if (event == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
espeak_EVENT *a_event = (espeak_EVENT *)malloc(sizeof(espeak_EVENT));
|
||||
if (a_event) {
|
||||
@@ -149,9 +148,8 @@ static espeak_EVENT *event_copy(espeak_EVENT *event)
|
||||
{
|
||||
case espeakEVENT_MARK:
|
||||
case espeakEVENT_PLAY:
|
||||
if (event->id.name) {
|
||||
if (event->id.name)
|
||||
a_event->id.name = strdup(event->id.name);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -225,9 +223,8 @@ static int event_delete(espeak_EVENT *event)
|
||||
|
||||
event_display(event);
|
||||
|
||||
if (event == NULL) {
|
||||
if (event == NULL)
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
@@ -237,9 +234,8 @@ static int event_delete(espeak_EVENT *event)
|
||||
|
||||
case espeakEVENT_MARK:
|
||||
case espeakEVENT_PLAY:
|
||||
if (event->id.name) {
|
||||
if (event->id.name)
|
||||
free((void *)(event->id.name));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -256,9 +252,8 @@ espeak_ERROR event_declare(espeak_EVENT *event)
|
||||
|
||||
event_display(event);
|
||||
|
||||
if (!event) {
|
||||
if (!event)
|
||||
return EE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
int a_status = pthread_mutex_lock(&my_mutex);
|
||||
espeak_ERROR a_error = EE_OK;
|
||||
@@ -267,9 +262,8 @@ espeak_ERROR event_declare(espeak_EVENT *event)
|
||||
SHOW_TIME("event_declare > locked\n");
|
||||
espeak_EVENT *a_event = event_copy(event);
|
||||
a_error = push(a_event);
|
||||
if (a_error != EE_OK) {
|
||||
if (a_error != EE_OK)
|
||||
event_delete(a_event);
|
||||
}
|
||||
SHOW_TIME("event_declare > unlocking\n");
|
||||
a_status = pthread_mutex_unlock(&my_mutex);
|
||||
}
|
||||
@@ -277,9 +271,8 @@ espeak_ERROR event_declare(espeak_EVENT *event)
|
||||
SHOW_TIME("event_declare > post my_sem_start_is_required\n");
|
||||
sem_post(&my_sem_start_is_required);
|
||||
|
||||
if (a_status != 0) {
|
||||
if (a_status != 0)
|
||||
a_error = EE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
return a_error;
|
||||
}
|
||||
@@ -292,28 +285,24 @@ espeak_ERROR event_clear_all()
|
||||
int a_event_is_running = 0;
|
||||
|
||||
SHOW_TIME("event_stop > locked\n");
|
||||
if (a_status != 0) {
|
||||
if (a_status != 0)
|
||||
return EE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (my_event_is_running) {
|
||||
SHOW_TIME("event_stop > post my_sem_stop_is_required\n");
|
||||
sem_post(&my_sem_stop_is_required);
|
||||
a_event_is_running = 1;
|
||||
} else {
|
||||
} else
|
||||
init(); // clear pending events
|
||||
}
|
||||
SHOW_TIME("event_stop > unlocking\n");
|
||||
a_status = pthread_mutex_unlock(&my_mutex);
|
||||
if (a_status != 0) {
|
||||
if (a_status != 0)
|
||||
return EE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (a_event_is_running) {
|
||||
SHOW_TIME("event_stop > wait for my_sem_stop_is_acknowledged\n");
|
||||
while ((sem_wait(&my_sem_stop_is_acknowledged) == -1) && errno == EINTR) {
|
||||
while ((sem_wait(&my_sem_stop_is_acknowledged) == -1) && errno == EINTR)
|
||||
continue; // Restart when interrupted by handler
|
||||
}
|
||||
SHOW_TIME("event_stop > get my_sem_stop_is_acknowledged\n");
|
||||
}
|
||||
|
||||
@@ -346,9 +335,8 @@ static int sleep_until_timeout_or_stop_request(uint32_t time_in_ms)
|
||||
ts.tv_sec, ts.tv_nsec);
|
||||
|
||||
while ((err = sem_timedwait(&my_sem_stop_is_required, &ts)) == -1
|
||||
&& errno == EINTR) {
|
||||
&& errno == EINTR)
|
||||
continue; // Restart when interrupted by handler
|
||||
}
|
||||
|
||||
assert(gettimeofday(&tv, NULL) != -1);
|
||||
SHOW("polling_thread > sleep_until_timeout_or_stop_request > stop sem_timedwait %d.%09lu \n",
|
||||
@@ -417,9 +405,8 @@ static void *polling_thread(void *p)
|
||||
|
||||
SHOW_TIME("polling_thread > wait for my_sem_start_is_required\n");
|
||||
|
||||
while ((sem_wait(&my_sem_start_is_required) == -1) && errno == EINTR) {
|
||||
while ((sem_wait(&my_sem_start_is_required) == -1) && errno == EINTR)
|
||||
continue; // Restart when interrupted by handler
|
||||
}
|
||||
|
||||
SHOW_TIME("polling_thread > get my_sem_start_is_required\n");
|
||||
|
||||
@@ -436,16 +423,14 @@ static void *polling_thread(void *p)
|
||||
while (0 == sem_trywait(&my_sem_stop_is_required)) {
|
||||
}
|
||||
;
|
||||
} else {
|
||||
} else
|
||||
a_stop_is_required = 0;
|
||||
}
|
||||
|
||||
// In this loop, my_event_is_running = 1
|
||||
while (head && (a_stop_is_required <= 0)) {
|
||||
SHOW_TIME("polling_thread > check head\n");
|
||||
while (0 == sem_trywait(&my_sem_start_is_required)) {
|
||||
}
|
||||
;
|
||||
|
||||
espeak_EVENT *event = (espeak_EVENT *)(head->data);
|
||||
assert(event);
|
||||
@@ -455,9 +440,9 @@ static void *polling_thread(void *p)
|
||||
int err = get_remaining_time((uint32_t)event->sample,
|
||||
&time_in_ms,
|
||||
&a_stop_is_required);
|
||||
if (a_stop_is_required > 0) {
|
||||
if (a_stop_is_required > 0)
|
||||
break;
|
||||
} else if (err != 0) {
|
||||
else if (err != 0) {
|
||||
// No available time: the event is deleted.
|
||||
SHOW("polling_thread > %s\n", "audio device down");
|
||||
a_status = pthread_mutex_lock(&my_mutex);
|
||||
@@ -487,13 +472,10 @@ static void *polling_thread(void *p)
|
||||
SHOW("polling_thread > stop required (%d)\n", __LINE__);
|
||||
while (0 == sem_trywait(&my_sem_stop_is_required)) {
|
||||
}
|
||||
;
|
||||
} else {
|
||||
} else
|
||||
a_stop_is_required = 0;
|
||||
}
|
||||
} else { // The event will be notified soon: sleep until timeout or stop request
|
||||
} else // The event will be notified soon: sleep until timeout or stop request
|
||||
a_stop_is_required = sleep_until_timeout_or_stop_request(time_in_ms);
|
||||
}
|
||||
}
|
||||
|
||||
a_status = pthread_mutex_lock(&my_mutex);
|
||||
@@ -508,10 +490,8 @@ static void *polling_thread(void *p)
|
||||
SHOW("polling_thread > stop required (%d)\n", __LINE__);
|
||||
while (0 == sem_trywait(&my_sem_stop_is_required)) {
|
||||
}
|
||||
;
|
||||
} else {
|
||||
} else
|
||||
a_stop_is_required = 0;
|
||||
}
|
||||
}
|
||||
|
||||
a_status = pthread_mutex_unlock(&my_mutex);
|
||||
@@ -551,9 +531,8 @@ static espeak_ERROR push(void *the_data)
|
||||
}
|
||||
|
||||
node *n = (node *)malloc(sizeof(node));
|
||||
if (n == NULL) {
|
||||
if (n == NULL)
|
||||
return EE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (head == NULL) {
|
||||
head = n;
|
||||
@@ -588,9 +567,8 @@ static void *pop()
|
||||
SHOW("event > pop > event=0x%x (counter=%d, uid=%d)\n", the_data, node_counter, ((espeak_EVENT *)the_data)->unique_identifier);
|
||||
}
|
||||
|
||||
if (head == NULL) {
|
||||
if (head == NULL)
|
||||
tail = NULL;
|
||||
}
|
||||
|
||||
return the_data;
|
||||
}
|
||||
|
||||
+17
-35
@@ -87,9 +87,8 @@ void fifo_init()
|
||||
|
||||
// leave once the thread is actually started
|
||||
SHOW_TIME("fifo > wait for my_sem_stop_is_acknowledged\n");
|
||||
while ((sem_wait(&my_sem_stop_is_acknowledged) == -1) && errno == EINTR) {
|
||||
while ((sem_wait(&my_sem_stop_is_acknowledged) == -1) && errno == EINTR)
|
||||
continue; // Restart when interrupted by handler
|
||||
}
|
||||
SHOW_TIME("fifo > get my_sem_stop_is_acknowledged\n");
|
||||
}
|
||||
|
||||
@@ -119,9 +118,8 @@ espeak_ERROR fifo_add_command(t_espeak_command *the_command)
|
||||
}
|
||||
}
|
||||
|
||||
if (a_status != 0) {
|
||||
if (a_status != 0)
|
||||
a_error = EE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
SHOW_TIME("LEAVE fifo_add_command");
|
||||
return a_error;
|
||||
@@ -160,9 +158,8 @@ espeak_ERROR fifo_add_commands(t_espeak_command *command1, t_espeak_command *com
|
||||
}
|
||||
}
|
||||
|
||||
if (a_status != 0) {
|
||||
if (a_status != 0)
|
||||
a_error = EE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
SHOW_TIME("LEAVE fifo_add_commands");
|
||||
return a_error;
|
||||
@@ -175,9 +172,8 @@ espeak_ERROR fifo_stop()
|
||||
int a_command_is_running = 0;
|
||||
int a_status = pthread_mutex_lock(&my_mutex);
|
||||
SHOW_TIME("fifo_stop > locked\n");
|
||||
if (a_status != 0) {
|
||||
if (a_status != 0)
|
||||
return EE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (my_command_is_running) {
|
||||
a_command_is_running = 1;
|
||||
@@ -186,15 +182,13 @@ espeak_ERROR fifo_stop()
|
||||
}
|
||||
SHOW_TIME("fifo_stop > unlocking\n");
|
||||
a_status = pthread_mutex_unlock(&my_mutex);
|
||||
if (a_status != 0) {
|
||||
if (a_status != 0)
|
||||
return EE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (a_command_is_running) {
|
||||
SHOW_TIME("fifo_stop > wait for my_sem_stop_is_acknowledged\n");
|
||||
while ((sem_wait(&my_sem_stop_is_acknowledged) == -1) && errno == EINTR) {
|
||||
while ((sem_wait(&my_sem_stop_is_acknowledged) == -1) && errno == EINTR)
|
||||
continue; // Restart when interrupted by handler
|
||||
}
|
||||
SHOW_TIME("fifo_stop > get my_sem_stop_is_acknowledged\n");
|
||||
}
|
||||
|
||||
@@ -224,11 +218,10 @@ static int sleep_until_start_request_or_inactivity()
|
||||
//
|
||||
int i = 0;
|
||||
while ((i <= MAX_INACTIVITY_CHECK) && !a_start_is_required) {
|
||||
if (wave_is_busy(NULL)) {
|
||||
if (wave_is_busy(NULL))
|
||||
i = 0;
|
||||
} else {
|
||||
else
|
||||
i++;
|
||||
}
|
||||
|
||||
int err = 0;
|
||||
struct timespec ts;
|
||||
@@ -249,17 +242,15 @@ static int sleep_until_start_request_or_inactivity()
|
||||
ts.tv_sec, ts.tv_nsec);
|
||||
|
||||
while ((err = sem_timedwait(&my_sem_start_is_required, &ts)) == -1
|
||||
&& errno == EINTR) {
|
||||
&& errno == EINTR)
|
||||
continue;
|
||||
}
|
||||
|
||||
assert(gettimeofday(&tv, NULL) != -1);
|
||||
SHOW("fifo > sleep_until_start_request_or_inactivity > stop sem_timedwait (start_is_required, err=%d) %d.%09lu \n", err,
|
||||
tv.tv_sec, tv.tv_usec*1000);
|
||||
|
||||
if (err == 0) {
|
||||
if (err == 0)
|
||||
a_start_is_required = 1;
|
||||
}
|
||||
}
|
||||
SHOW_TIME("fifo > sleep_until_start_request_or_inactivity > LEAVE");
|
||||
return a_start_is_required;
|
||||
@@ -276,9 +267,8 @@ static void close_stream()
|
||||
int a_status = pthread_mutex_lock(&my_mutex);
|
||||
assert(!a_status);
|
||||
int a_stop_is_required = my_stop_is_required;
|
||||
if (!a_stop_is_required) {
|
||||
if (!a_stop_is_required)
|
||||
my_command_is_running = 1;
|
||||
}
|
||||
a_status = pthread_mutex_unlock(&my_mutex);
|
||||
|
||||
if (!a_stop_is_required) {
|
||||
@@ -319,16 +309,14 @@ static void *say_thread(void *p)
|
||||
int a_start_is_required = 0;
|
||||
if (look_for_inactivity) {
|
||||
a_start_is_required = sleep_until_start_request_or_inactivity();
|
||||
if (!a_start_is_required) {
|
||||
if (!a_start_is_required)
|
||||
close_stream();
|
||||
}
|
||||
}
|
||||
look_for_inactivity = 1;
|
||||
|
||||
if (!a_start_is_required) {
|
||||
while ((sem_wait(&my_sem_start_is_required) == -1) && errno == EINTR) {
|
||||
while ((sem_wait(&my_sem_start_is_required) == -1) && errno == EINTR)
|
||||
continue; // Restart when interrupted by handler
|
||||
}
|
||||
}
|
||||
SHOW_TIME("say_thread > get my_sem_start_is_required\n");
|
||||
|
||||
@@ -353,7 +341,6 @@ static void *say_thread(void *p)
|
||||
SHOW_TIME("say_thread > purge my_sem_start_is_required\n");
|
||||
while (0 == sem_trywait(&my_sem_start_is_required)) {
|
||||
}
|
||||
;
|
||||
|
||||
if (my_stop_is_required) {
|
||||
SHOW_TIME("say_thread > my_command_is_running = 0\n");
|
||||
@@ -362,9 +349,8 @@ static void *say_thread(void *p)
|
||||
SHOW_TIME("say_thread > unlocking\n");
|
||||
a_status = pthread_mutex_unlock(&my_mutex);
|
||||
|
||||
if (my_command_is_running) {
|
||||
if (my_command_is_running)
|
||||
process_espeak_command(a_command);
|
||||
}
|
||||
delete_espeak_command(a_command);
|
||||
}
|
||||
}
|
||||
@@ -378,7 +364,6 @@ static void *say_thread(void *p)
|
||||
SHOW_TIME("say_thread > purge my_sem_start_is_required\n");
|
||||
while (0 == sem_trywait(&my_sem_start_is_required)) {
|
||||
}
|
||||
;
|
||||
|
||||
// acknowledge the stop request
|
||||
SHOW_TIME("say_thread > post my_sem_stop_is_acknowledged\n");
|
||||
@@ -423,9 +408,8 @@ static espeak_ERROR push(t_espeak_command *the_command)
|
||||
}
|
||||
|
||||
node *n = (node *)malloc(sizeof(node));
|
||||
if (n == NULL) {
|
||||
if (n == NULL)
|
||||
return EE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (head == NULL) {
|
||||
head = n;
|
||||
@@ -463,9 +447,8 @@ static t_espeak_command *pop()
|
||||
SHOW("pop > command=0x%x (counter=%d)\n", the_command, node_counter);
|
||||
}
|
||||
|
||||
if (head == NULL) {
|
||||
if (head == NULL)
|
||||
tail = NULL;
|
||||
}
|
||||
|
||||
display_espeak_command(the_command);
|
||||
|
||||
@@ -478,9 +461,8 @@ static void init(int process_parameters)
|
||||
ENTER("fifo > init");
|
||||
c = pop();
|
||||
while (c != NULL) {
|
||||
if (process_parameters && (c->type == ET_PARAMETER || c->type == ET_VOICE_NAME || c->type == ET_VOICE_SPEC)) {
|
||||
if (process_parameters && (c->type == ET_PARAMETER || c->type == ET_VOICE_NAME || c->type == ET_VOICE_SPEC))
|
||||
process_espeak_command(c);
|
||||
}
|
||||
delete_espeak_command(c);
|
||||
c = pop();
|
||||
}
|
||||
|
||||
@@ -357,11 +357,10 @@ static void count_pitch_vowels(int start, int end, int clause_end)
|
||||
stress = syllable_tab[ix].stress; /* marked stress level */
|
||||
|
||||
if (stress >= max_stress) {
|
||||
if (stress > max_stress) {
|
||||
if (stress > max_stress)
|
||||
max_stress_posn2 = ix;
|
||||
} else {
|
||||
else
|
||||
max_stress_posn2 = max_stress_posn;
|
||||
}
|
||||
max_stress_posn = ix;
|
||||
max_stress = stress;
|
||||
}
|
||||
@@ -384,9 +383,8 @@ static void count_pitch_vowels(int start, int end, int clause_end)
|
||||
if (no_tonic) {
|
||||
tone_posn = tone_posn2 = end; // next position after the end of the truncated clause
|
||||
} else if (last_primary >= 0) {
|
||||
if (end == clause_end) {
|
||||
if (end == clause_end)
|
||||
syllable_tab[last_primary].stress = PRIMARY_LAST;
|
||||
}
|
||||
} else {
|
||||
// no primary stress. Use the highest stress
|
||||
syllable_tab[tone_posn].stress = PRIMARY_LAST;
|
||||
@@ -519,9 +517,9 @@ static int SetHeadIntonation(TUNE *tune, int syl_ix, int end_ix, int control)
|
||||
if (n_steps > tune->head_max_steps)
|
||||
n_steps = tune->head_max_steps;
|
||||
|
||||
if (n_steps > 1) {
|
||||
if (n_steps > 1)
|
||||
increment = pitch_range / (n_steps -1);
|
||||
} else
|
||||
else
|
||||
increment = 0;
|
||||
|
||||
} else if (syl_ix == head_final) {
|
||||
@@ -538,9 +536,8 @@ static int SetHeadIntonation(TUNE *tune, int syl_ix, int end_ix, int control)
|
||||
pitch += increment;
|
||||
else {
|
||||
pitch = (tune->head_end << 8) + (pitch_range_abs * tune->head_extend[overflow_ix++])/64;
|
||||
if (overflow_ix >= tune->n_head_extend) {
|
||||
if (overflow_ix >= tune->n_head_extend)
|
||||
overflow_ix = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,9 +624,9 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
|
||||
if (n_steps > th->body_max_steps)
|
||||
n_steps = th->body_max_steps;
|
||||
|
||||
if (n_steps > 1) {
|
||||
if (n_steps > 1)
|
||||
increment = pitch_range / (n_steps -1);
|
||||
} else
|
||||
else
|
||||
increment = 0;
|
||||
|
||||
pitch = th->body_start << 8;
|
||||
@@ -648,17 +645,16 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
|
||||
n_steps--;
|
||||
|
||||
n_primary--;
|
||||
if ((tn->backwards) && (n_primary < 2)) {
|
||||
if ((tn->backwards) && (n_primary < 2))
|
||||
pitch = tn->backwards[n_primary] << 8;
|
||||
}
|
||||
}
|
||||
|
||||
if (stress >= PRIMARY) {
|
||||
syl->stress = PRIMARY_STRESSED;
|
||||
set_pitch(syl, (pitch >> 8), drops[stress]);
|
||||
} else if (stress >= SECONDARY) {
|
||||
} else if (stress >= SECONDARY)
|
||||
set_pitch(syl, (pitch >> 8), drops[stress]);
|
||||
} else {
|
||||
else {
|
||||
/* unstressed, drop pitch if preceded by PRIMARY */
|
||||
if ((syllable_tab[ix-1].stress & 0x3f) >= SECONDARY)
|
||||
set_pitch(syl, (pitch >> 8) - th->body_lower_u, drops[stress]);
|
||||
@@ -692,9 +688,8 @@ static void SetPitchGradient(int start_ix, int end_ix, int start_pitch, int end_
|
||||
if (n_increments <= 0)
|
||||
return;
|
||||
|
||||
if (n_increments > 1) {
|
||||
if (n_increments > 1)
|
||||
increment = increment / n_increments;
|
||||
}
|
||||
|
||||
pitch = start_pitch << 8;
|
||||
|
||||
@@ -740,9 +735,8 @@ static int calc_pitches2(int start, int end, int tune_number)
|
||||
/* body of tonic segment */
|
||||
/*************************/
|
||||
|
||||
if (option_tone_flags & OPTION_EMPHASIZE_PENULTIMATE) {
|
||||
if (option_tone_flags & OPTION_EMPHASIZE_PENULTIMATE)
|
||||
tone_posn = tone_posn2; // put tone on the penultimate stressed word
|
||||
}
|
||||
ix = SetHeadIntonation(tune, ix, tone_posn, 0);
|
||||
|
||||
if (no_tonic)
|
||||
@@ -784,9 +778,8 @@ static int calc_pitches(int control, int start, int end, int tune_number)
|
||||
int drop;
|
||||
int continuing = 0;
|
||||
|
||||
if (control == 0) {
|
||||
if (control == 0)
|
||||
return calc_pitches2(start, end, tune_number);
|
||||
}
|
||||
|
||||
if (start > 0)
|
||||
continuing = 1;
|
||||
@@ -804,9 +797,8 @@ static int calc_pitches(int control, int start, int end, int tune_number)
|
||||
/* body of tonic segment */
|
||||
/*************************/
|
||||
|
||||
if (option_tone_flags & OPTION_EMPHASIZE_PENULTIMATE) {
|
||||
if (option_tone_flags & OPTION_EMPHASIZE_PENULTIMATE)
|
||||
tone_posn = tone_posn2; // put tone on the penultimate stressed word
|
||||
}
|
||||
ix = calc_pitch_segment(ix, tone_posn, th, tn, PRIMARY, continuing);
|
||||
|
||||
if (no_tonic)
|
||||
@@ -905,9 +897,8 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone)
|
||||
prevw_tph = phoneme_tab[phonPAUSE]; // forget previous tone
|
||||
}
|
||||
|
||||
if (p->newword) {
|
||||
if (p->newword)
|
||||
prev_tph = phoneme_tab[phonPAUSE]; // forget across word boundaries
|
||||
}
|
||||
|
||||
if (p->synthflags & SFLAG_SYLLABLE) {
|
||||
tone_ph = p->tone_ph;
|
||||
@@ -919,16 +910,14 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone)
|
||||
if (pause || tone_promoted) {
|
||||
tone_ph = PhonemeCode2('5', '5'); // no previous vowel, use tone 1
|
||||
tone_promoted = 1;
|
||||
} else {
|
||||
} else
|
||||
tone_ph = PhonemeCode2('1', '1'); // default tone 5
|
||||
}
|
||||
|
||||
p->tone_ph = tone_ph;
|
||||
tph = phoneme_tab[tone_ph];
|
||||
|
||||
} else {
|
||||
} else
|
||||
tone_promoted = 0;
|
||||
}
|
||||
|
||||
if (ix == final_stressed) {
|
||||
if ((tph->mnemonic == 0x3535 ) || (tph->mnemonic == 0x3135)) {
|
||||
@@ -943,9 +932,8 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone)
|
||||
else
|
||||
prev_p->tone_ph = PhonemeCode2('2', '1');
|
||||
}
|
||||
if ((prev_tph->mnemonic == 0x3135) && (tph->mnemonic == 0x3135)) { // [51] + [51]
|
||||
if ((prev_tph->mnemonic == 0x3135) && (tph->mnemonic == 0x3135)) // [51] + [51]
|
||||
prev_p->tone_ph = PhonemeCode2('5', '3');
|
||||
}
|
||||
|
||||
if (tph->mnemonic == 0x3131) { // [11] Tone 5
|
||||
// tone 5, change its level depending on the previous tone (across word boundaries)
|
||||
@@ -1034,9 +1022,8 @@ void CalcPitches(Translator *tr, int clause_type)
|
||||
|
||||
if (p->stresslevel >= 4)
|
||||
n_primary++;
|
||||
} else if ((p->ph->code == phonPAUSE_CLAUSE) && (n_st > 0)) {
|
||||
} else if ((p->ph->code == phonPAUSE_CLAUSE) && (n_st > 0))
|
||||
syllable_tab[n_st-1].flags |= SYL_END_CLAUSE;
|
||||
}
|
||||
}
|
||||
syllable_tab[n_st].stress = 0; // extra 0 entry at the end
|
||||
|
||||
@@ -1159,9 +1146,9 @@ void CalcPitches(Translator *tr, int clause_type)
|
||||
p->pitch2 = syl->pitch2;
|
||||
|
||||
p->env = PITCHfall;
|
||||
if (syl->flags & SYL_RISE) {
|
||||
if (syl->flags & SYL_RISE)
|
||||
p->env = PITCHrise;
|
||||
} else if (p->stresslevel > 5)
|
||||
else if (p->stresslevel > 5)
|
||||
p->env = syl->env;
|
||||
|
||||
if (p->pitch1 > p->pitch2) {
|
||||
@@ -1178,9 +1165,8 @@ void CalcPitches(Translator *tr, int clause_type)
|
||||
p->pitch1 = x + ph->start_type;
|
||||
}
|
||||
|
||||
if (syl->flags & SYL_EMPHASIS) {
|
||||
if (syl->flags & SYL_EMPHASIS)
|
||||
p->stresslevel |= 8; // emphasized
|
||||
}
|
||||
|
||||
st_ix++;
|
||||
}
|
||||
|
||||
+29
-54
@@ -240,9 +240,8 @@ static double sampled_source(int source_num)
|
||||
|
||||
result = samples[itemp] + diff_value;
|
||||
result = result * kt_globals.sample_factor;
|
||||
} else {
|
||||
} else
|
||||
result = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -288,9 +287,8 @@ static int parwave(klatt_frame_ptr frame)
|
||||
second half of glottal period) if voicing simultaneously present.
|
||||
*/
|
||||
|
||||
if (kt_globals.nper > kt_globals.nmod) {
|
||||
if (kt_globals.nper > kt_globals.nmod)
|
||||
noise *= (double)0.5;
|
||||
}
|
||||
|
||||
/* Compute frication noise */
|
||||
frics = kt_globals.amp_frica * noise;
|
||||
@@ -350,9 +348,8 @@ static int parwave(klatt_frame_ptr frame)
|
||||
*/
|
||||
|
||||
|
||||
if (kt_globals.nper < kt_globals.nopen) {
|
||||
if (kt_globals.nper < kt_globals.nopen)
|
||||
voice += kt_globals.amp_breth * kt_globals.nrand;
|
||||
}
|
||||
|
||||
/* Set amplitude of voicing */
|
||||
glotout = kt_globals.amp_voice * voice;
|
||||
@@ -399,9 +396,8 @@ static int parwave(klatt_frame_ptr frame)
|
||||
sourc = frics + par_glotout - glotlast;
|
||||
glotlast = par_glotout;
|
||||
|
||||
for (ix = R2p; ix <= R6p; ix++) {
|
||||
for (ix = R2p; ix <= R6p; ix++)
|
||||
out = resonator(&(kt_globals.rsn[ix]), sourc) - out;
|
||||
}
|
||||
|
||||
outbypas = kt_globals.amp_bypas * sourc;
|
||||
|
||||
@@ -444,13 +440,11 @@ static int parwave(klatt_frame_ptr frame)
|
||||
if (echo_tail >= N_ECHO_BUF)
|
||||
echo_tail = 0;
|
||||
|
||||
if (value < -32768) {
|
||||
if (value < -32768)
|
||||
value = -32768;
|
||||
}
|
||||
|
||||
if (value > 32767) {
|
||||
if (value > 32767)
|
||||
value = 32767;
|
||||
}
|
||||
|
||||
*out_ptr++ = value;
|
||||
*out_ptr++ = value >> 8;
|
||||
@@ -460,9 +454,8 @@ static int parwave(klatt_frame_ptr frame)
|
||||
echo_head = 0;
|
||||
|
||||
sample_count++;
|
||||
if (out_ptr >= out_end) {
|
||||
if (out_ptr >= out_end)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -521,9 +514,8 @@ static void frame_init(klatt_frame_ptr frame)
|
||||
kt_globals.original_f0 = frame->F0hz10 / 10;
|
||||
|
||||
frame->AVdb_tmp = frame->AVdb - 7;
|
||||
if (frame->AVdb_tmp < 0) {
|
||||
if (frame->AVdb_tmp < 0)
|
||||
frame->AVdb_tmp = 0;
|
||||
}
|
||||
|
||||
kt_globals.amp_aspir = DBtoLIN(frame->ASP) * 0.05;
|
||||
kt_globals.amp_frica = DBtoLIN(frame->AF) * 0.25;
|
||||
@@ -536,9 +528,8 @@ static void frame_init(klatt_frame_ptr frame)
|
||||
}
|
||||
|
||||
Gain0_tmp = frame->Gain0 - 3;
|
||||
if (Gain0_tmp <= 0) {
|
||||
if (Gain0_tmp <= 0)
|
||||
Gain0_tmp = 57;
|
||||
}
|
||||
kt_globals.amp_gain0 = DBtoLIN(Gain0_tmp) / kt_globals.scale_wav;
|
||||
|
||||
/* Set coefficients of variable cascade resonators */
|
||||
@@ -593,11 +584,10 @@ static double impulsive_source()
|
||||
static double doublet[] = { 0.0, 13000000.0, -13000000.0 };
|
||||
static double vwave;
|
||||
|
||||
if (kt_globals.nper < 3) {
|
||||
if (kt_globals.nper < 3)
|
||||
vwave = doublet[kt_globals.nper];
|
||||
} else {
|
||||
else
|
||||
vwave = 0.0;
|
||||
}
|
||||
|
||||
return resonator(&(kt_globals.rsn[RGL]), vwave);
|
||||
}
|
||||
@@ -622,10 +612,9 @@ static double natural_source()
|
||||
lgtemp = vwave * 0.028;
|
||||
|
||||
return lgtemp;
|
||||
} else {
|
||||
vwave = 0.0;
|
||||
return 0.0;
|
||||
}
|
||||
vwave = 0.0;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
@@ -697,9 +686,8 @@ static void pitch_synch_par_reset(klatt_frame_ptr frame)
|
||||
/* Duration of period before amplitude modulation */
|
||||
|
||||
kt_globals.nmod = kt_globals.T0;
|
||||
if (frame->AVdb_tmp > 0) {
|
||||
if (frame->AVdb_tmp > 0)
|
||||
kt_globals.nmod >>= 1;
|
||||
}
|
||||
|
||||
/* Breathiness of voicing waveform */
|
||||
|
||||
@@ -709,13 +697,11 @@ static void pitch_synch_par_reset(klatt_frame_ptr frame)
|
||||
|
||||
kt_globals.nopen = 4 * frame->Kopen;
|
||||
|
||||
if ((kt_globals.glsource == IMPULSIVE) && (kt_globals.nopen > 263)) {
|
||||
if ((kt_globals.glsource == IMPULSIVE) && (kt_globals.nopen > 263))
|
||||
kt_globals.nopen = 263;
|
||||
}
|
||||
|
||||
if (kt_globals.nopen >= (kt_globals.T0-1)) {
|
||||
if (kt_globals.nopen >= (kt_globals.T0-1))
|
||||
kt_globals.nopen = kt_globals.T0 - 2;
|
||||
}
|
||||
|
||||
if (kt_globals.nopen < 40) {
|
||||
/* F0 max = 1000 Hz */
|
||||
@@ -746,14 +732,12 @@ static void pitch_synch_par_reset(klatt_frame_ptr frame)
|
||||
|
||||
|
||||
temp = kt_globals.T0 - kt_globals.nopen;
|
||||
if (frame->Kskew > temp) {
|
||||
if (frame->Kskew > temp)
|
||||
frame->Kskew = temp;
|
||||
}
|
||||
if (skew >= 0) {
|
||||
if (skew >= 0)
|
||||
skew = frame->Kskew;
|
||||
} else {
|
||||
else
|
||||
skew = -frame->Kskew;
|
||||
}
|
||||
|
||||
/* Add skewness to closed portion of voicing period */
|
||||
kt_globals.T0 = kt_globals.T0 + skew;
|
||||
@@ -774,11 +758,10 @@ static void pitch_synch_par_reset(klatt_frame_ptr frame)
|
||||
|
||||
kt_globals.decay = (0.033 * frame->TLTdb);
|
||||
|
||||
if (kt_globals.decay > 0.0) {
|
||||
if (kt_globals.decay > 0.0)
|
||||
kt_globals.onemd = 1.0 - kt_globals.decay;
|
||||
} else {
|
||||
else
|
||||
kt_globals.onemd = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -913,9 +896,8 @@ static double DBtoLIN(long dB)
|
||||
26214, 29491, 32767
|
||||
};
|
||||
|
||||
if ((dB < 0) || (dB > 87)) {
|
||||
if ((dB < 0) || (dB > 87))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (double)(amptable[dB]) * 0.001;
|
||||
}
|
||||
@@ -941,9 +923,8 @@ int Wavegen_Klatt(int resume)
|
||||
int ix;
|
||||
int fade;
|
||||
|
||||
if (resume == 0) {
|
||||
if (resume == 0)
|
||||
sample_count = 0;
|
||||
}
|
||||
|
||||
while (sample_count < nsamples) {
|
||||
kt_frame.F0hz10 = (wdata.pitch * 10) / 4096;
|
||||
@@ -953,13 +934,11 @@ int Wavegen_Klatt(int resume)
|
||||
// F0 is used for the nasal zero
|
||||
for (ix = 0; ix < 6; ix++) {
|
||||
kt_frame.Fhz[ix] = peaks[ix].freq;
|
||||
if (ix < 4) {
|
||||
if (ix < 4)
|
||||
kt_frame.Bhz[ix] = peaks[ix].bw;
|
||||
}
|
||||
}
|
||||
for (ix = 1; ix < 7; ix++) {
|
||||
for (ix = 1; ix < 7; ix++)
|
||||
kt_frame.Ap[ix] = peaks[ix].ap;
|
||||
}
|
||||
|
||||
kt_frame.AVdb = klattp[KLATT_AV];
|
||||
kt_frame.AVpdb = klattp[KLATT_AVp];
|
||||
@@ -991,9 +970,8 @@ int Wavegen_Klatt(int resume)
|
||||
|
||||
for (ix = 0; ix <= 6; ix++) {
|
||||
kt_frame.Fhz_next[ix] = peaks[ix].freq;
|
||||
if (ix < 4) {
|
||||
if (ix < 4)
|
||||
kt_frame.Bhz_next[ix] = peaks[ix].bw;
|
||||
}
|
||||
}
|
||||
|
||||
// advance the pitch
|
||||
@@ -1008,9 +986,8 @@ int Wavegen_Klatt(int resume)
|
||||
|
||||
frame_init(&kt_frame); /* get parameters for next frame of speech */
|
||||
|
||||
if (parwave(&kt_frame) == 1) {
|
||||
if (parwave(&kt_frame) == 1)
|
||||
return 1; // output buffer is full
|
||||
}
|
||||
}
|
||||
|
||||
if (end_wave > 0) {
|
||||
@@ -1021,9 +998,8 @@ int Wavegen_Klatt(int resume)
|
||||
end_wave = 0;
|
||||
sample_count -= fade;
|
||||
kt_globals.nspfr = fade;
|
||||
if (parwave(&kt_frame) == 1) {
|
||||
if (parwave(&kt_frame) == 1)
|
||||
return 1; // output buffer is full
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1048,9 +1024,8 @@ void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v
|
||||
}
|
||||
|
||||
end_wave = 0;
|
||||
if (control & 2) {
|
||||
if (control & 2)
|
||||
end_wave = 1; // fadeout at the end
|
||||
}
|
||||
if (control & 1) {
|
||||
end_wave = 1;
|
||||
for (qix = wcmdq_head+1;; qix++) {
|
||||
|
||||
+11
-12
@@ -95,9 +95,9 @@ static int create_pipes(int p1[2], int p2[2], int p3[2])
|
||||
|
||||
if (pipe(p1) != -1) {
|
||||
if (pipe(p2) != -1) {
|
||||
if (pipe(p3) != -1) {
|
||||
if (pipe(p3) != -1)
|
||||
return 0;
|
||||
} else
|
||||
else
|
||||
error = errno;
|
||||
close(p2[0]);
|
||||
close(p2[1]);
|
||||
@@ -248,11 +248,11 @@ static int mbrola_died(void)
|
||||
char msgbuf[80];
|
||||
|
||||
pid = waitpid(mbr_pid, &status, WNOHANG);
|
||||
if (!pid) {
|
||||
if (!pid)
|
||||
msg = "mbrola closed stderr and did not exit";
|
||||
} else if (pid != mbr_pid) {
|
||||
else if (pid != mbr_pid)
|
||||
msg = "waitpid() is confused";
|
||||
} else {
|
||||
else {
|
||||
mbr_pid = 0;
|
||||
if (WIFSIGNALED(status)) {
|
||||
int sig = WTERMSIG(status);
|
||||
@@ -264,9 +264,8 @@ static int mbrola_died(void)
|
||||
snprintf(msgbuf, sizeof(msgbuf),
|
||||
"mbrola exited with status %d", exst);
|
||||
msg = msgbuf;
|
||||
} else {
|
||||
} else
|
||||
msg = "mbrola died and wait status is weird";
|
||||
}
|
||||
}
|
||||
|
||||
log("mbrowrap error: %s", msg);
|
||||
@@ -338,11 +337,11 @@ static int send_to_mbrola(const char *cmd)
|
||||
|
||||
if (result == -1) {
|
||||
int error = errno;
|
||||
if (error == EPIPE && mbrola_has_errors()) {
|
||||
if (error == EPIPE && mbrola_has_errors())
|
||||
return -1;
|
||||
} else if (error == EAGAIN) {
|
||||
else if (error == EAGAIN)
|
||||
result = 0;
|
||||
} else {
|
||||
else {
|
||||
err("write(): %s", strerror(error));
|
||||
return -1;
|
||||
}
|
||||
@@ -449,9 +448,9 @@ static ssize_t receive_from_mbrola(void *buffer, size_t bufsize)
|
||||
err("write(): %s", strerror(error));
|
||||
return -1;
|
||||
}
|
||||
if (result != left) {
|
||||
if (result != left)
|
||||
head->done += result;
|
||||
} else {
|
||||
else {
|
||||
mbr_pending_data_head = head->next;
|
||||
free(head);
|
||||
if (!mbr_pending_data_head)
|
||||
|
||||
+45
-83
@@ -409,9 +409,8 @@ static int LookupLetter2(Translator *tr, unsigned int letter, char *ph_buf)
|
||||
|
||||
if (Lookup(tr, &single_letter[1], ph_buf) == 0) {
|
||||
single_letter[1] = ' ';
|
||||
if (Lookup(tr, &single_letter[2], ph_buf) == 0) {
|
||||
if (Lookup(tr, &single_letter[2], ph_buf) == 0)
|
||||
TranslateRules(tr, &single_letter[2], ph_buf, 20, NULL, 0, NULL);
|
||||
}
|
||||
}
|
||||
return ph_buf[0];
|
||||
}
|
||||
@@ -433,11 +432,10 @@ void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf)
|
||||
|
||||
ph_accent2[0] = 0;
|
||||
|
||||
if ((letter >= 0xe0) && (letter < 0x17f)) {
|
||||
if ((letter >= 0xe0) && (letter < 0x17f))
|
||||
accent_data = letter_accents_0e0[letter - 0xe0];
|
||||
} else if ((letter >= 0x250) && (letter <= 0x2a8)) {
|
||||
else if ((letter >= 0x250) && (letter <= 0x2a8))
|
||||
accent_data = letter_accents_250[letter - 0x250];
|
||||
}
|
||||
|
||||
if (accent_data != 0) {
|
||||
basic_letter = (accent_data & 0x3f) + 59;
|
||||
@@ -542,19 +540,16 @@ void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_b
|
||||
|
||||
if (Lookup(tr, &single_letter[1], ph_buf3) == 0) {
|
||||
single_letter[1] = ' ';
|
||||
if (Lookup(tr, &single_letter[2], ph_buf3) == 0) {
|
||||
if (Lookup(tr, &single_letter[2], ph_buf3) == 0)
|
||||
TranslateRules(tr, &single_letter[2], ph_buf3, sizeof(ph_buf3), NULL, FLAG_NO_TRACE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (ph_buf3[0] == 0) {
|
||||
if (ph_buf3[0] == 0)
|
||||
LookupAccentedLetter(tr, letter, ph_buf3);
|
||||
}
|
||||
|
||||
strcpy(ph_buf1, ph_buf3);
|
||||
if ((ph_buf1[0] == 0) || (ph_buf1[0] == phonSWITCH)) {
|
||||
if ((ph_buf1[0] == 0) || (ph_buf1[0] == phonSWITCH))
|
||||
return;
|
||||
}
|
||||
|
||||
dict_flags[0] = 0;
|
||||
dict_flags[1] = 0;
|
||||
@@ -717,15 +712,13 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
|
||||
n_bytes = utf8_in(&letter, word);
|
||||
|
||||
if ((letter & 0xfff00) == 0x0e000) {
|
||||
if ((letter & 0xfff00) == 0x0e000)
|
||||
letter &= 0xff; // uncode private usage area
|
||||
}
|
||||
|
||||
if (control & 2) {
|
||||
// include CAPITAL information
|
||||
if (iswupper2(letter)) {
|
||||
if (iswupper2(letter))
|
||||
Lookup(tr, "_cap", capital);
|
||||
}
|
||||
}
|
||||
letter = towlower2(letter);
|
||||
LookupLetter(tr, letter, word[n_bytes], ph_buf, control & 1);
|
||||
@@ -840,9 +833,8 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
ph_buf[3] = 0;
|
||||
TranslateRules(translator2, &hangul_buf[1], &ph_buf[3], sizeof(ph_buf)-3, NULL, 0, NULL);
|
||||
SetWordStress(translator2, &ph_buf[3], NULL, -1, 0);
|
||||
} else {
|
||||
} else
|
||||
LookupLetter(translator2, letter, word[n_bytes], &ph_buf[3], control & 1);
|
||||
}
|
||||
|
||||
if (ph_buf[3] == phonSWITCH) {
|
||||
// another level of language change
|
||||
@@ -876,9 +868,8 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
if ((ph_buf[0] == 0) && !iswspace(letter))
|
||||
Lookup(translator, "_??", ph_buf);
|
||||
|
||||
if (ph_buf[0] == 0) {
|
||||
if (ph_buf[0] == 0)
|
||||
EncodePhonemes("l'et@", ph_buf, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(control & 4) && (al_flags & AL_NOT_CODE)) {
|
||||
@@ -891,9 +882,8 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
// braille dots symbol, list the numbered dots
|
||||
p2 = hexbuf;
|
||||
for (ix = 0; ix < 8; ix++) {
|
||||
if (letter & (1 << ix)) {
|
||||
if (letter & (1 << ix))
|
||||
*p2++ = '1'+ix;
|
||||
}
|
||||
}
|
||||
*p2 = 0;
|
||||
} else {
|
||||
@@ -941,9 +931,8 @@ void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars)
|
||||
unsigned char buf[N_WORD_PHONEMES];
|
||||
|
||||
for (ix = 0; (c = phonemes[ix]) != 0; ix++) {
|
||||
if ((c == phonSTRESS_P) && (prev != phonSWITCH)) {
|
||||
if ((c == phonSTRESS_P) && (prev != phonSWITCH))
|
||||
n_stress++;
|
||||
}
|
||||
buf[ix] = prev = c;
|
||||
}
|
||||
buf[ix] = 0;
|
||||
@@ -1015,9 +1004,8 @@ static int CheckDotOrdinal(Translator *tr, char *word, char *word_end, WORD_TAB
|
||||
if ((roman == 0) && (tr->translator_name == L('h', 'u'))) {
|
||||
// lang=hu don't treat dot as ordinal indicator if the next word is a month name ($alt). It may have a suffix.
|
||||
nextflags = 0;
|
||||
if (IsAlpha(c2)) {
|
||||
if (IsAlpha(c2))
|
||||
nextflags = TranslateWord(tr, &word_end[2], 0, NULL, NULL);
|
||||
}
|
||||
|
||||
if ((tr->prev_dict_flags[0] & FLAG_ALT_TRANS) && ((c2 == 0) || (wtab[0].flags & FLAG_COMMA_AFTER) || iswdigit(c2)))
|
||||
ordinal = 0; // TEST 09.02.10
|
||||
@@ -1163,9 +1151,8 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
wtab[0].flags |= FLAG_ORDINAL;
|
||||
}
|
||||
}
|
||||
|
||||
tr->prev_dict_flags[0] = 0;
|
||||
@@ -1263,9 +1250,8 @@ static int LookupThousands(Translator *tr, int value, int thousandplex, int thou
|
||||
}
|
||||
|
||||
if (found_value == 0) {
|
||||
if ((value % 100) >= 20) {
|
||||
if ((value % 100) >= 20)
|
||||
Lookup(tr, "_0of", ph_of);
|
||||
}
|
||||
|
||||
found = 0;
|
||||
if (thousands_exact & 1) {
|
||||
@@ -1352,9 +1338,8 @@ static int LookupNum2(Translator *tr, int value, int thousandplex, const int con
|
||||
ph_digits[0] = 0;
|
||||
ph_and[0] = 0;
|
||||
|
||||
if (control & 0x20) {
|
||||
if (control & 0x20)
|
||||
ord_type = 'q';
|
||||
}
|
||||
|
||||
is_ordinal = control & 1;
|
||||
|
||||
@@ -1532,9 +1517,8 @@ static int LookupNum2(Translator *tr, int value, int thousandplex, const int con
|
||||
if ((ix > 0) && (phoneme_tab[(unsigned char)(ph_out[ix-1])]->type == phVOWEL))
|
||||
ix--;
|
||||
sprintf(&ph_out[ix], "%s", ph_ordinal);
|
||||
} else {
|
||||
} else
|
||||
sprintf(ph_out, "%s%s%s", ph_tens, ph_digits, ph_ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1615,9 +1599,8 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
// special form for exact hundreds?
|
||||
found = Lookup(tr, "_0C0", ph_100);
|
||||
}
|
||||
if (!found) {
|
||||
if (!found)
|
||||
Lookup(tr, "_0C", ph_100);
|
||||
}
|
||||
}
|
||||
|
||||
if (((tr->langopts.numbers & NUM_1900) != 0) && (hundreds == 19)) {
|
||||
@@ -1630,9 +1613,8 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
exact = 1;
|
||||
|
||||
tplex = thousandplex+1;
|
||||
if (tr->langopts.numbers2 & NUM2_MYRIADS) {
|
||||
if (tr->langopts.numbers2 & NUM2_MYRIADS)
|
||||
tplex = 0;
|
||||
}
|
||||
|
||||
if (LookupThousands(tr, hundreds / 10, tplex, exact | ordinal, ph_10T) == 0) {
|
||||
x = 0;
|
||||
@@ -1658,9 +1640,8 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
ph_digits[0] = 0;
|
||||
|
||||
if ((hundreds > 0) || say_zero_hundred) {
|
||||
if ((tr->langopts.numbers & NUM_AND_HUNDRED) && ((control & 1) || (ph_thousands[0] != 0))) {
|
||||
if ((tr->langopts.numbers & NUM_AND_HUNDRED) && ((control & 1) || (ph_thousands[0] != 0)))
|
||||
Lookup(tr, "_0and", ph_thousand_and);
|
||||
}
|
||||
|
||||
suppress_null = 1;
|
||||
|
||||
@@ -1678,9 +1659,9 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
}
|
||||
}
|
||||
|
||||
if ((hundreds == 0) && say_zero_hundred) {
|
||||
if ((hundreds == 0) && say_zero_hundred)
|
||||
Lookup(tr, "_0", ph_digits);
|
||||
} else {
|
||||
else {
|
||||
if ((hundreds == 1) && (tr->langopts.numbers2 & NUM2_OMIT_1_HUNDRED_ONLY) && ((control & 1) == 0)) {
|
||||
// only look for special 100 if there are previous thousands
|
||||
} else {
|
||||
@@ -1696,18 +1677,17 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
if (found)
|
||||
ph_100[0] = 0;
|
||||
} else {
|
||||
else {
|
||||
say_one_hundred = 1;
|
||||
if (hundreds == 1) {
|
||||
if ((tr->langopts.numbers & NUM_OMIT_1_HUNDRED) != 0)
|
||||
say_one_hundred = 0;
|
||||
}
|
||||
|
||||
if (say_one_hundred != 0) {
|
||||
if (say_one_hundred != 0)
|
||||
LookupNum2(tr, hundreds, thousandplex, 0, ph_digits);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1721,13 +1701,11 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
// Don't use "and" if we apply ordinal to both hundreds and units
|
||||
} else {
|
||||
if ((value > 100) || ((control & 1) && (thousandplex == 0))) {
|
||||
if ((tr->langopts.numbers & NUM_HUNDRED_AND) || ((tr->langopts.numbers & NUM_HUNDRED_AND_DIGIT) && (tensunits < 10))) {
|
||||
if ((tr->langopts.numbers & NUM_HUNDRED_AND) || ((tr->langopts.numbers & NUM_HUNDRED_AND_DIGIT) && (tensunits < 10)))
|
||||
Lookup(tr, "_0and", ph_hundred_and);
|
||||
}
|
||||
}
|
||||
if ((tr->langopts.numbers & NUM_THOUSAND_AND) && (hundreds == 0) && ((control & 1) || (ph_thousands[0] != 0))) {
|
||||
if ((tr->langopts.numbers & NUM_THOUSAND_AND) && (hundreds == 0) && ((control & 1) || (ph_thousands[0] != 0)))
|
||||
Lookup(tr, "_0and", ph_hundred_and);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1744,14 +1722,11 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
x |= 4; // tens and units only, no higher digits
|
||||
if (ordinal & 0x20)
|
||||
x |= 0x20; // variant form of ordinal number
|
||||
} else {
|
||||
if (tr->langopts.numbers2 & (1 << thousandplex))
|
||||
x = 8; // use variant (feminine) for before thousands and millions
|
||||
}
|
||||
} else if (tr->langopts.numbers2 & (1 << thousandplex))
|
||||
x = 8; // use variant (feminine) for before thousands and millions
|
||||
|
||||
if ((tr->translator_name == L('m', 'l')) && (thousandplex == 1)) {
|
||||
if ((tr->translator_name == L('m', 'l')) && (thousandplex == 1))
|
||||
x |= 0x208; // use #f form for both tens and units
|
||||
}
|
||||
|
||||
if ((tr->langopts.numbers2 & NUM2_ZERO_TENS) && ((control & 1) || (hundreds > 0))) {
|
||||
// LANG=zh,
|
||||
@@ -1850,13 +1825,11 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
prev_thousands = 1;
|
||||
} else if ((tr->langopts.thousands_sep == ' ') || (tr->langopts.numbers & NUM_ALLOW_SPACE)) {
|
||||
// thousands groups can be separated by spaces
|
||||
if ((n_digits == 3) && !(wtab->flags & FLAG_MULTIPLE_SPACES) && IsDigit09(word[-2])) {
|
||||
if ((n_digits == 3) && !(wtab->flags & FLAG_MULTIPLE_SPACES) && IsDigit09(word[-2]))
|
||||
prev_thousands = 1;
|
||||
}
|
||||
}
|
||||
if (prev_thousands == 0) {
|
||||
if (prev_thousands == 0)
|
||||
speak_missing_thousands = 0;
|
||||
}
|
||||
|
||||
ph_ordinal2[0] = 0;
|
||||
ph_zeros[0] = 0;
|
||||
@@ -1880,15 +1853,14 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
*p++ = '-';
|
||||
ix++;
|
||||
}
|
||||
while ((word[ix] != 0) && (word[ix] != ' ') && (ix < (int)(sizeof(suffix)-1))) {
|
||||
while ((word[ix] != 0) && (word[ix] != ' ') && (ix < (int)(sizeof(suffix)-1)))
|
||||
*p++ = word[ix++];
|
||||
}
|
||||
*p = 0;
|
||||
|
||||
if (suffix[0] != 0) {
|
||||
if ((tr->langopts.ordinal_indicator != NULL) && (strcmp(suffix, tr->langopts.ordinal_indicator) == 0)) {
|
||||
if ((tr->langopts.ordinal_indicator != NULL) && (strcmp(suffix, tr->langopts.ordinal_indicator) == 0))
|
||||
ordinal = 2;
|
||||
} else if (!IsDigit09(suffix[0])) { // not _#9 (tab)
|
||||
else if (!IsDigit09(suffix[0])) { // not _#9 (tab)
|
||||
sprintf(string, "_#%s", suffix);
|
||||
if (Lookup(tr, string, ph_ordinal2)) {
|
||||
// this is an ordinal suffix
|
||||
@@ -1919,9 +1891,8 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
}
|
||||
|
||||
// speak leading zeros
|
||||
for (ix = 0; (word[ix] == '0') && (ix < (n_digits-1)); ix++) {
|
||||
for (ix = 0; (word[ix] == '0') && (ix < (n_digits-1)); ix++)
|
||||
Lookup(tr, "_0", &ph_zeros[strlen(ph_zeros)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1954,15 +1925,13 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
}
|
||||
}
|
||||
|
||||
if ((value == 0) && prev_thousands) {
|
||||
if ((value == 0) && prev_thousands)
|
||||
suppress_null = 1;
|
||||
}
|
||||
|
||||
if (tr->translator_name == L('h', 'u')) {
|
||||
// variant form of numbers when followed by hyphen and a suffix starting with 'a' or 'e' (but not a, e, az, ez, azt, ezt
|
||||
if ((wtab[thousandplex].flags & FLAG_HYPHEN_AFTER) && (thousands_exact == 1) && hu_number_e(&word[suffix_ix], thousandplex, value)) {
|
||||
if ((wtab[thousandplex].flags & FLAG_HYPHEN_AFTER) && (thousands_exact == 1) && hu_number_e(&word[suffix_ix], thousandplex, value))
|
||||
number_control |= 1; // use _1e variant of number
|
||||
}
|
||||
}
|
||||
|
||||
if ((word[n_digits] == tr->langopts.decimal_sep) && IsDigit09(word[n_digits+1])) {
|
||||
@@ -1988,9 +1957,8 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
}
|
||||
}
|
||||
|
||||
if ((ph_append[0] == 0) && (word[n_digits] == '.') && (thousandplex == 0)) {
|
||||
if ((ph_append[0] == 0) && (word[n_digits] == '.') && (thousandplex == 0))
|
||||
Lookup(tr, "_.", ph_append);
|
||||
}
|
||||
|
||||
if (thousandplex == 0) {
|
||||
char *p2;
|
||||
@@ -1999,34 +1967,30 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
while (IsDigit09(p[1])) p++; // just use the last digit
|
||||
if (IsDigit09(p[-1])) {
|
||||
p2 = p - 1;
|
||||
if (LookupDictList(tr, &p2, buf_digit_lookup, flags, FLAG_SUFX, wtab)) { // lookup 2 digits
|
||||
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')) {
|
||||
// LANG=hu ?
|
||||
// not found, lookup only the last digit (?? but not if dot-ordinal has been found)
|
||||
if (LookupDictList(tr, &p, buf_digit_lookup, flags, FLAG_SUFX, wtab)) { // don't match '0', or entries with $only
|
||||
if (LookupDictList(tr, &p, buf_digit_lookup, flags, FLAG_SUFX, wtab)) // don't match '0', or entries with $only
|
||||
n_digit_lookup = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (prev_thousands == 0) {
|
||||
if ((decimal_point == 0) && (ordinal == 0)) {
|
||||
// Look for special pronunciation for this number in isolation (LANG=kl)
|
||||
sprintf(string, "_%dn", value);
|
||||
if (Lookup(tr, string, ph_out)) {
|
||||
if (Lookup(tr, string, ph_out))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (tr->langopts.numbers2 & NUM2_PERCENT_BEFORE) {
|
||||
// LANG=si, say "percent" before the number
|
||||
p2 = word;
|
||||
while ((*p2 != ' ') && (*p2 != 0)) {
|
||||
while ((*p2 != ' ') && (*p2 != 0))
|
||||
p2++;
|
||||
}
|
||||
if (p2[1] == '%') {
|
||||
Lookup(tr, "%", ph_out);
|
||||
ph_out += strlen(ph_out);
|
||||
@@ -2125,9 +2089,8 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
if ((c == tr->langopts.decimal_sep) && IsDigit09(word[n_digits+1])) {
|
||||
Lookup(tr, "_dpt", buf1);
|
||||
strcat(ph_out, buf1);
|
||||
} else {
|
||||
} else
|
||||
decimal_point = 0;
|
||||
}
|
||||
}
|
||||
if ((ph_out[0] != 0) && (ph_out[0] != phonSWITCH)) {
|
||||
int next_char;
|
||||
@@ -2157,8 +2120,7 @@ int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *fla
|
||||
if ((option_sayas == SAYAS_DIGITS1) || (wtab[0].flags & FLAG_INDIVIDUAL_DIGITS))
|
||||
return 0; // speak digits individually
|
||||
|
||||
if (tr->langopts.numbers != 0) {
|
||||
if (tr->langopts.numbers != 0)
|
||||
return TranslateNumber_1(tr, word1, ph_out, flags, wtab, control);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -87,9 +87,8 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST *plist_out)
|
||||
}
|
||||
}
|
||||
|
||||
if (plist2->phcode == 0) {
|
||||
if (plist2->phcode == 0)
|
||||
continue; // phoneme has been replaced by NULL, so don't copy it
|
||||
}
|
||||
}
|
||||
|
||||
// copy phoneme into the output list
|
||||
@@ -166,13 +165,11 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
delete_count = 0;
|
||||
current_phoneme_tab = tr->phoneme_tab_ix;
|
||||
for (j = 0; j < n_ph_list2; j++) {
|
||||
if (current_phoneme_tab != tr->phoneme_tab_ix) {
|
||||
if (current_phoneme_tab != tr->phoneme_tab_ix)
|
||||
plist2[j].synthflags |= SFLAG_SWITCHED_LANG;
|
||||
}
|
||||
|
||||
if (delete_count > 0) {
|
||||
if (delete_count > 0)
|
||||
memcpy(&plist2[j-delete_count], &plist2[j], sizeof(plist2[0]));
|
||||
}
|
||||
|
||||
if (plist2[j].phcode == phonSWITCH) {
|
||||
if ((!(plist2[j].synthflags & SFLAG_EMBEDDED)) && (
|
||||
@@ -183,9 +180,8 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
// delete this phonSWITCH if it's switching to the current phoneme table, or
|
||||
// delete this phonSWITCH if its followed by another phonSWITCH
|
||||
delete_count++;
|
||||
} else {
|
||||
} else
|
||||
current_phoneme_tab = plist2[j].tone_ph;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -223,25 +219,22 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
}
|
||||
|
||||
if ((type == phSTOP) || type == (phFRICATIVE)) {
|
||||
if ((voicing == 0) && (regression & 0xf)) {
|
||||
if ((voicing == 0) && (regression & 0xf))
|
||||
voicing = 1;
|
||||
} else if ((voicing == 2) && (ph->end_type != 0)) { // use end_type field for voicing_switch for consonants
|
||||
else if ((voicing == 2) && (ph->end_type != 0)) // use end_type field for voicing_switch for consonants
|
||||
plist2[j].phcode = ph->end_type; // change to voiced equivalent
|
||||
}
|
||||
} else if ((type == phVSTOP) || type == (phVFRICATIVE)) {
|
||||
if ((voicing == 0) && (regression & 0xf)) {
|
||||
if ((voicing == 0) && (regression & 0xf))
|
||||
voicing = 2;
|
||||
} else if ((voicing == 1) && (ph->end_type != 0)) {
|
||||
else if ((voicing == 1) && (ph->end_type != 0))
|
||||
plist2[j].phcode = ph->end_type; // change to unvoiced equivalent
|
||||
}
|
||||
} else {
|
||||
if (regression & 0x8) {
|
||||
// LANG=Polish, propagate through liquids and nasals
|
||||
if ((type == phPAUSE) || (type == phVOWEL))
|
||||
voicing = 0;
|
||||
} else {
|
||||
} else
|
||||
voicing = 0;
|
||||
}
|
||||
}
|
||||
if (stop_propagation) {
|
||||
voicing = 0;
|
||||
@@ -255,9 +248,8 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
}
|
||||
if (regression & 0x100) {
|
||||
// devoice word-final consonants, unless propagating voiced
|
||||
if (voicing == 0) {
|
||||
if (voicing == 0)
|
||||
voicing = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -281,13 +273,11 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
if (ph_list3[nextw].sourceix)
|
||||
break; // start of the next word
|
||||
}
|
||||
for (k = j; k < nextw; k++) {
|
||||
for (k = j; k < nextw; k++)
|
||||
ph_list3[k].wordstress = word_stress;
|
||||
}
|
||||
j = nextw;
|
||||
} else {
|
||||
} else
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
// transfer all the phonemes of the clause into phoneme_list
|
||||
@@ -314,9 +304,8 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
if (word_start > 0) {
|
||||
k = word_start;
|
||||
word_start--;
|
||||
} else {
|
||||
} else
|
||||
k = 2; // No more space, don't loose the start of word mark at ph_list2[word_start]
|
||||
}
|
||||
for (; k <= j; k++)
|
||||
memcpy(&ph_list3[k-1], &ph_list3[k], sizeof(*plist3));
|
||||
}
|
||||
@@ -382,9 +371,9 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
plist3->ph = ph;
|
||||
plist3->phcode = alternative;
|
||||
|
||||
if (alternative == 1) {
|
||||
if (alternative == 1)
|
||||
deleted = 1; // NULL phoneme, discard
|
||||
} else {
|
||||
else {
|
||||
if (ph->type == phVOWEL) {
|
||||
plist3->synthflags |= SFLAG_SYLLABLE;
|
||||
if (ph2->type != phVOWEL)
|
||||
@@ -427,9 +416,8 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
if ((tr->langopts.stress_flags & S_NO_DIM) || ((word_stress > 3) && ((plist3+1)->sourceix != 0))) {
|
||||
// An unstressed final vowel of a stressed word
|
||||
unstress_count = 1; // try again for next syllable
|
||||
} else {
|
||||
} else
|
||||
plist3->stresslevel = 0; // change stress to 'diminished'
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -488,18 +476,16 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
insert_ph = pause_phonemes[x];
|
||||
}
|
||||
}
|
||||
if (option_wordgap > 0) {
|
||||
if (option_wordgap > 0)
|
||||
insert_ph = phonPAUSE_LONG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
next2 = phoneme_tab[plist3[2].phcode];
|
||||
plist3[2].ph = next2;
|
||||
|
||||
if ((insert_ph == 0) && (phdata.pd_param[pd_APPENDPHONEME] != 0)) {
|
||||
if ((insert_ph == 0) && (phdata.pd_param[pd_APPENDPHONEME] != 0))
|
||||
insert_ph = phdata.pd_param[pd_APPENDPHONEME];
|
||||
}
|
||||
|
||||
if (deleted == 0) {
|
||||
phlist[ix].ph = ph;
|
||||
@@ -520,9 +506,8 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
phlist[ix].newword = 5; // start of sentence + start of word
|
||||
start_sentence = 0;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
phlist[ix].newword = 0;
|
||||
}
|
||||
|
||||
phlist[ix].length = phdata.pd_param[i_SET_LENGTH]*2;
|
||||
if ((ph->code == phonPAUSE_LONG) && (option_wordgap > 0) && (plist3[1].sourceix != 0)) {
|
||||
|
||||
@@ -400,9 +400,8 @@ const int wcslen(const wchar_t *str)
|
||||
{
|
||||
int ix = 0;
|
||||
|
||||
while (*str != 0) {
|
||||
while (*str != 0)
|
||||
ix++;
|
||||
}
|
||||
return ix;
|
||||
}
|
||||
#endif
|
||||
@@ -466,9 +465,8 @@ int towlower2(unsigned int c)
|
||||
|
||||
// check for non-standard upper to lower case conversions
|
||||
if (c == 'I') {
|
||||
if (translator->langopts.dotless_i) {
|
||||
if (translator->langopts.dotless_i)
|
||||
c = 0x131; // I -> ı
|
||||
}
|
||||
}
|
||||
|
||||
if (c < 0x80)
|
||||
@@ -606,9 +604,8 @@ static int GetC(void)
|
||||
if (ungot2 != 0) {
|
||||
c1 = ungot2;
|
||||
ungot2 = 0;
|
||||
} else {
|
||||
} else
|
||||
c1 = GetC_get();
|
||||
}
|
||||
|
||||
if ((option_multibyte == espeakCHARS_WCHAR) || (option_multibyte == espeakCHARS_16BIT)) {
|
||||
count_characters++;
|
||||
@@ -752,11 +749,10 @@ static const char *LookupCharName(Translator *tr, int c, int only)
|
||||
string = &single_letter[2];
|
||||
LookupDictList(translator2, &string, phonemes, flags, 0, NULL);
|
||||
}
|
||||
if (phonemes[0]) {
|
||||
if (phonemes[0])
|
||||
lang_name = "en";
|
||||
} else {
|
||||
else
|
||||
SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
|
||||
}
|
||||
}
|
||||
|
||||
if (phonemes[0]) {
|
||||
@@ -770,9 +766,8 @@ static const char *LookupCharName(Translator *tr, int c, int only)
|
||||
DecodePhonemes(phonemes, phonemes2);
|
||||
sprintf(buf, "[\002%s]] ", phonemes2);
|
||||
}
|
||||
} else if (only == 0) {
|
||||
} else if (only == 0)
|
||||
strcpy(buf, "[\002(X1)(X1)(X1)]]");
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -836,9 +831,8 @@ static int LoadSoundFile(const char *fname, int index)
|
||||
if ((fd_temp = mkstemp(fname_temp)) >= 0) {
|
||||
close(fd_temp);
|
||||
sprintf(command, "sox \"%s\" -r %d -c1 -t wav %s\n", fname, samplerate, fname_temp);
|
||||
if (system(command) == 0) {
|
||||
if (system(command) == 0)
|
||||
fname = fname_temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -942,13 +936,11 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output
|
||||
UngetC(c2);
|
||||
} else {
|
||||
if ((c1 == '.') && (end_clause) && (c2 != '.')) {
|
||||
if (LookupSpecial(tr, "_.p", ph_buf)) {
|
||||
if (LookupSpecial(tr, "_.p", ph_buf))
|
||||
punctname = ph_buf; // use word for 'period' instead of 'dot'
|
||||
}
|
||||
}
|
||||
if (punctname == NULL) {
|
||||
if (punctname == NULL)
|
||||
punctname = LookupCharName(tr, c1, 0);
|
||||
}
|
||||
|
||||
if (punctname == NULL)
|
||||
return -1;
|
||||
@@ -960,13 +952,12 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output
|
||||
c2 = GetC();
|
||||
}
|
||||
*c2_ptr = c2;
|
||||
if (end_clause) {
|
||||
if (end_clause)
|
||||
UngetC(c2);
|
||||
}
|
||||
|
||||
if (punct_count == 1) {
|
||||
if (punct_count == 1)
|
||||
sprintf(buf, " %s", punctname); // we need the space before punctname, to ensure it doesn't merge with the previous word (eg. "2.-a")
|
||||
} else if (punct_count < 4) {
|
||||
else if (punct_count < 4) {
|
||||
buf[0] = 0;
|
||||
if (embedded_value[EMBED_S] < 300)
|
||||
sprintf(buf, "\001+10S"); // Speak punctuation name faster, unless we are already speaking fast. It would upset Sonic SpeedUp
|
||||
@@ -980,10 +971,9 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output
|
||||
sprintf(buf2, " \001-10S");
|
||||
strcat(buf, buf2);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
sprintf(buf, " %s %d %s",
|
||||
punctname, punct_count, punctname);
|
||||
}
|
||||
} else {
|
||||
// end the clause now and pick up the punctuation next time
|
||||
UngetC(c2);
|
||||
@@ -1139,9 +1129,8 @@ static const char *VoiceFromStack()
|
||||
if (voice_name_specified == 0)
|
||||
voice_name[0] = 0; // forget a previous voice name if a language is specified
|
||||
}
|
||||
if (sp->voice_gender != 0) {
|
||||
if (sp->voice_gender != 0)
|
||||
voice_select.gender = sp->voice_gender;
|
||||
}
|
||||
|
||||
if (sp->voice_age != 0)
|
||||
voice_select.age = sp->voice_age;
|
||||
@@ -1228,9 +1217,8 @@ static PARAM_STACK *PushParamStack(int tag_type)
|
||||
n_param_stack++;
|
||||
|
||||
sp->type = tag_type;
|
||||
for (ix = 0; ix < N_SPEECH_PARAM; ix++) {
|
||||
for (ix = 0; ix < N_SPEECH_PARAM; ix++)
|
||||
sp->parameter[ix] = -1;
|
||||
}
|
||||
return sp;
|
||||
}
|
||||
|
||||
@@ -1245,13 +1233,11 @@ static void PopParamStack(int tag_type, char *outbuf, int *outix)
|
||||
tag_type -= SSML_CLOSE;
|
||||
|
||||
for (ix = 0; ix < n_param_stack; ix++) {
|
||||
if (param_stack[ix].type == tag_type) {
|
||||
if (param_stack[ix].type == tag_type)
|
||||
top = ix;
|
||||
}
|
||||
}
|
||||
if (top > 0) {
|
||||
if (top > 0)
|
||||
n_param_stack = top;
|
||||
}
|
||||
ProcessParamStack(outbuf, outix);
|
||||
}
|
||||
|
||||
@@ -1322,9 +1308,8 @@ static int attrnumber(const wchar_t *pw, int default_value, int type)
|
||||
if ((pw == NULL) || !IsDigit09(*pw))
|
||||
return default_value;
|
||||
|
||||
while (IsDigit09(*pw)) {
|
||||
while (IsDigit09(*pw))
|
||||
value = value*10 + *pw++ - '0';
|
||||
}
|
||||
if ((type == 1) && (towlower(*pw) == 's')) {
|
||||
// time: seconds rather than ms
|
||||
value *= 1000;
|
||||
@@ -1422,9 +1407,8 @@ int AddNameData(const char *name, int wide)
|
||||
if (wide) {
|
||||
len = (wcslen((const wchar_t *)name)+1)*sizeof(wchar_t);
|
||||
n_namedata = (n_namedata + sizeof(wchar_t) - 1) % sizeof(wchar_t); // round to wchar_t boundary
|
||||
} else {
|
||||
} else
|
||||
len = strlen(name)+1;
|
||||
}
|
||||
|
||||
if (namedata_ix+len >= n_namedata) {
|
||||
// allocate more space for marker names
|
||||
@@ -1491,9 +1475,8 @@ static int GetVoiceAttributes(wchar_t *pw, int tag_type)
|
||||
|
||||
if (tag_type & SSML_CLOSE) {
|
||||
// delete a stack frame
|
||||
if (n_ssml_stack > 1) {
|
||||
if (n_ssml_stack > 1)
|
||||
n_ssml_stack--;
|
||||
}
|
||||
} else {
|
||||
// add a stack frame if any voice details are specified
|
||||
lang = GetSsmlAttribute(pw, "xml:lang");
|
||||
@@ -1726,9 +1709,8 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
|
||||
|
||||
if (tag_name[0] == '/') {
|
||||
// closing tag
|
||||
if ((tag_type = LookupMnem(ssmltags, &tag_name[1])) != HTML_NOSPACE) {
|
||||
if ((tag_type = LookupMnem(ssmltags, &tag_name[1])) != HTML_NOSPACE)
|
||||
outbuf[(*outix)++] = ' ';
|
||||
}
|
||||
tag_type += SSML_CLOSE;
|
||||
} else {
|
||||
if ((tag_type = LookupMnem(ssmltags, tag_name)) != HTML_NOSPACE) {
|
||||
@@ -1768,9 +1750,8 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
|
||||
|
||||
// look for attributes: rate, volume, pitch, range
|
||||
for (param_type = espeakRATE; param_type <= espeakRANGE; param_type++) {
|
||||
if ((attr1 = GetSsmlAttribute(px, prosody_attr[param_type])) != NULL) {
|
||||
if ((attr1 = GetSsmlAttribute(px, prosody_attr[param_type])) != NULL)
|
||||
SetProsodyParameter(param_type, attr1, sp);
|
||||
}
|
||||
}
|
||||
|
||||
ProcessParamStack(outbuf, outix);
|
||||
@@ -1779,9 +1760,8 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
|
||||
case SSML_EMPHASIS:
|
||||
sp = PushParamStack(tag_type);
|
||||
value = 3; // default is "moderate"
|
||||
if ((attr1 = GetSsmlAttribute(px, "level")) != NULL) {
|
||||
if ((attr1 = GetSsmlAttribute(px, "level")) != NULL)
|
||||
value = attrlookup(attr1, mnem_emphasis);
|
||||
}
|
||||
|
||||
if (translator->langopts.tone_language == 1) {
|
||||
static unsigned char emphasis_to_pitch_range[] = { 50, 50, 40, 70, 90, 100 };
|
||||
@@ -1901,9 +1881,8 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
|
||||
if ((xmlbase != NULL) && (buf[0] != '/')) {
|
||||
sprintf(fname, "%s/%s", xmlbase, buf);
|
||||
index = LoadSoundFile2(fname);
|
||||
} else {
|
||||
} else
|
||||
index = LoadSoundFile2(buf);
|
||||
}
|
||||
if (index >= 0) {
|
||||
sprintf(buf, "%c%dI", CTRL_EMBEDDED, index);
|
||||
strcpy(&outbuf[*outix], buf);
|
||||
@@ -1977,9 +1956,8 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
|
||||
case SSML_SPEAK:
|
||||
if ((attr1 = GetSsmlAttribute(px, "xml:base")) != NULL) {
|
||||
attrcopy_utf8(buf, attr1, sizeof(buf));
|
||||
if ((index = AddNameData(buf, 0)) >= 0) {
|
||||
if ((index = AddNameData(buf, 0)) >= 0)
|
||||
xmlbase = &namedata[index];
|
||||
}
|
||||
}
|
||||
if (GetVoiceAttributes(px, tag_type) == 0)
|
||||
return 0; // no voice change
|
||||
@@ -1992,16 +1970,14 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
|
||||
|
||||
case SSML_SPEAK + SSML_CLOSE:
|
||||
// unwind stack until the previous <voice> or <speak> tag
|
||||
while ((n_ssml_stack > 1) && (ssml_stack[n_ssml_stack-1].tag_type != SSML_SPEAK)) {
|
||||
while ((n_ssml_stack > 1) && (ssml_stack[n_ssml_stack-1].tag_type != SSML_SPEAK))
|
||||
n_ssml_stack--;
|
||||
}
|
||||
return CLAUSE_PERIOD + GetVoiceAttributes(px, tag_type);
|
||||
|
||||
case SSML_VOICE + SSML_CLOSE:
|
||||
// unwind stack until the previous <voice> or <speak> tag
|
||||
while ((n_ssml_stack > 1) && (ssml_stack[n_ssml_stack-1].tag_type != SSML_VOICE)) {
|
||||
while ((n_ssml_stack > 1) && (ssml_stack[n_ssml_stack-1].tag_type != SSML_VOICE))
|
||||
n_ssml_stack--;
|
||||
}
|
||||
|
||||
terminator = 0; // ?? Sentence intonation, but no pause ??
|
||||
return terminator + GetVoiceAttributes(px, tag_type);
|
||||
@@ -2135,11 +2111,10 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
ungot_word = NULL;
|
||||
}
|
||||
|
||||
if (ungot_char2 != 0) {
|
||||
if (ungot_char2 != 0)
|
||||
c2 = ungot_char2;
|
||||
} else {
|
||||
else
|
||||
c2 = GetC();
|
||||
}
|
||||
|
||||
while (!Eof() || (ungot_char != 0) || (ungot_char2 != 0) || (ungot_string_ix >= 0)) {
|
||||
if (!iswalnum(c1)) {
|
||||
@@ -2167,17 +2142,15 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
ungot_string_ix = -1;
|
||||
}
|
||||
|
||||
if ((ungot_string_ix == 0) && (ungot_char2 == 0)) {
|
||||
if ((ungot_string_ix == 0) && (ungot_char2 == 0))
|
||||
c1 = ungot_string[ungot_string_ix++];
|
||||
}
|
||||
if (ungot_string_ix >= 0) {
|
||||
if (ungot_string_ix >= 0)
|
||||
c2 = ungot_string[ungot_string_ix++];
|
||||
} else {
|
||||
else {
|
||||
c2 = GetC();
|
||||
|
||||
if (Eof()) {
|
||||
if (Eof())
|
||||
c2 = ' ';
|
||||
}
|
||||
}
|
||||
ungot_char2 = 0;
|
||||
|
||||
@@ -2207,9 +2180,8 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
c2 = ' ';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
found = -1;
|
||||
}
|
||||
|
||||
if (found <= 0) {
|
||||
ungot_string_ix = 0;
|
||||
@@ -2223,9 +2195,8 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
} else if ((c1 == '<') && (ssml_ignore_l_angle != '<')) {
|
||||
if ((c2 == '!') || (c2 == '?')) {
|
||||
// a comment, ignore until closing '<' (or <?xml tag )
|
||||
while (!Eof() && (c1 != '>')) {
|
||||
while (!Eof() && (c1 != '>'))
|
||||
c1 = GetC();
|
||||
}
|
||||
c2 = ' ';
|
||||
} else if ((c2 == '/') || iswalpha2(c2)) {
|
||||
// check for space in the output buffer for embedded commands produced by the SSML tag
|
||||
@@ -2264,9 +2235,8 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
buf[ix] = ' ';
|
||||
buf[ix++] = 0;
|
||||
|
||||
if (terminator & CLAUSE_BIT_VOICE) {
|
||||
if (terminator & CLAUSE_BIT_VOICE)
|
||||
strcpy(voice_change, current_voice_id);
|
||||
}
|
||||
return terminator;
|
||||
}
|
||||
c1 = ' ';
|
||||
@@ -2287,9 +2257,8 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
*charix_top = ix;
|
||||
ix += utf8_out(c1, &buf[ix]);
|
||||
terminator = CLAUSE_PERIOD; // line doesn't end in punctuation, assume period
|
||||
} else {
|
||||
} else
|
||||
terminator = punct_attributes[punct];
|
||||
}
|
||||
buf[ix] = ' ';
|
||||
buf[ix+1] = 0;
|
||||
return terminator;
|
||||
@@ -2376,9 +2345,8 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
|
||||
if (c1 == 0xd4d) {
|
||||
// Malayalam virama, check if next character is Zero-width-joiner
|
||||
if (c2 == 0x200d) {
|
||||
if (c2 == 0x200d)
|
||||
c1 = 0xd4e; // use this unofficial code for chillu-virama
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2421,9 +2389,8 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
// 2nd newline, assume paragraph
|
||||
UngetC(c2);
|
||||
|
||||
if (end_clause_after_tag) {
|
||||
if (end_clause_after_tag)
|
||||
RemoveChar(&buf[end_clause_index]); // delete clause-end punctiation
|
||||
}
|
||||
buf[ix] = ' ';
|
||||
buf[ix+1] = 0;
|
||||
if (parag > 3)
|
||||
@@ -2532,9 +2499,8 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
}
|
||||
}
|
||||
|
||||
if ((c1 == '.') && (nl_count < 2)) {
|
||||
if ((c1 == '.') && (nl_count < 2))
|
||||
punct_data |= CLAUSE_DOT;
|
||||
}
|
||||
|
||||
if (nl_count == 0) {
|
||||
if ((c1 == ',') && (cprev == '.') && (tr->translator_name == L('h', 'u')) && iswdigit(cprev2) && (iswdigit(c_next) || (iswlower2(c_next)))) {
|
||||
@@ -2547,15 +2513,14 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
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)) {
|
||||
if (!iswdigit(cprev))
|
||||
is_end_clause = 0; // Roman number followed by dot
|
||||
} else {
|
||||
else {
|
||||
if (iswlower2(c_next) || (c_next == '-')) // hyphen is needed for lang-hu (eg. 2.-kal)
|
||||
is_end_clause = 0; // only if followed by lower-case, (or if there is a XML tag)
|
||||
}
|
||||
} else if (c_next == '\'') {
|
||||
} else if (c_next == '\'')
|
||||
is_end_clause = 0; // eg. u.s.a.'s
|
||||
}
|
||||
if (iswlower2(c_next)) {
|
||||
// next word has no capital letter, this dot is probably from an abbreviation
|
||||
is_end_clause = 0;
|
||||
@@ -2586,9 +2551,8 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
buf[ix] = ' ';
|
||||
buf[ix+1] = 0;
|
||||
|
||||
if (iswdigit(cprev) && !IsAlpha(c_next)) { // ????
|
||||
if (iswdigit(cprev) && !IsAlpha(c_next)) // ????
|
||||
punct_data &= ~CLAUSE_DOT;
|
||||
}
|
||||
if (nl_count > 1) {
|
||||
if ((punct_data == CLAUSE_QUESTION) || (punct_data == CLAUSE_EXCLAMATION))
|
||||
return punct_data + 35; // with a longer pause
|
||||
@@ -2610,11 +2574,10 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
if (c1 == announced_punctuation) {
|
||||
// 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 != '-') {
|
||||
else if (c1 != '-')
|
||||
c1 = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
j = ix+1;
|
||||
@@ -2640,12 +2603,10 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
|
||||
}
|
||||
}
|
||||
|
||||
if (stressed_word) {
|
||||
if (stressed_word)
|
||||
ix += utf8_out(CHAR_EMPHASIS, &buf[ix]);
|
||||
}
|
||||
if (end_clause_after_tag) {
|
||||
if (end_clause_after_tag)
|
||||
RemoveChar(&buf[end_clause_index]); // delete clause-end punctiation
|
||||
}
|
||||
buf[ix] = ' ';
|
||||
buf[ix+1] = 0;
|
||||
return CLAUSE_EOF; // end of file
|
||||
|
||||
@@ -162,13 +162,11 @@ void SetSpeed(int control)
|
||||
|
||||
wpm_value = wpm;
|
||||
|
||||
if (voice->speed_percent > 0) {
|
||||
if (voice->speed_percent > 0)
|
||||
wpm = (wpm * voice->speed_percent)/100;
|
||||
}
|
||||
|
||||
if (control & 2) {
|
||||
if (control & 2)
|
||||
DoSonicSpeed(1 * 1024);
|
||||
}
|
||||
if ((wpm_value >= 450) || ((wpm_value > speed.fast_settings[0]) && (wpm > 350))) {
|
||||
wpm2 = wpm;
|
||||
wpm = 175;
|
||||
@@ -198,9 +196,8 @@ void SetSpeed(int control)
|
||||
if (wpm > 450)
|
||||
wpm = 450;
|
||||
|
||||
if (wpm > 360) {
|
||||
if (wpm > 360)
|
||||
speed.loud_consonants = (wpm - 360) / 8;
|
||||
}
|
||||
|
||||
wpm2 = wpm;
|
||||
if (wpm > 359) wpm2 = 359;
|
||||
@@ -243,9 +240,8 @@ void SetSpeed(int control)
|
||||
else
|
||||
speed.wav_factor = 128 + (128*s1)/130; // = 215 at 170 wpm
|
||||
|
||||
if (wpm >= 350) {
|
||||
if (wpm >= 350)
|
||||
speed.wav_factor = wav_factor_350[wpm-350];
|
||||
}
|
||||
|
||||
if (wpm >= 390) {
|
||||
speed.min_sample_len = 450 - (wpm - 400)/2;
|
||||
@@ -259,15 +255,14 @@ void SetSpeed(int control)
|
||||
speed.pause_factor = (256 * s1)/115; // full speed adjustment, used for pause length
|
||||
speed.clause_pause_factor = 0;
|
||||
|
||||
if (wpm > 430) {
|
||||
if (wpm > 430)
|
||||
speed.pause_factor = 12;
|
||||
} else if (wpm > 400) {
|
||||
else if (wpm > 400)
|
||||
speed.pause_factor = 13;
|
||||
} else if (wpm > 374) {
|
||||
else if (wpm > 374)
|
||||
speed.pause_factor = 14;
|
||||
} else if (wpm > 350) {
|
||||
else if (wpm > 350)
|
||||
speed.pause_factor = pause_factor_350[wpm - 350];
|
||||
}
|
||||
|
||||
if (speed.clause_pause_factor == 0) {
|
||||
// restrict the reduction of pauses between clauses
|
||||
@@ -296,15 +291,13 @@ void SetSpeed(int control)
|
||||
if (control == 2)
|
||||
wpm = embedded_value[EMBED_S2];
|
||||
|
||||
if (voice->speed_percent > 0) {
|
||||
if (voice->speed_percent > 0)
|
||||
wpm = (wpm * voice->speed_percent)/100;
|
||||
}
|
||||
if (wpm > 450)
|
||||
wpm = 450;
|
||||
|
||||
if (wpm > 360) {
|
||||
if (wpm > 360)
|
||||
speed.loud_consonants = (wpm - 360) / 8;
|
||||
}
|
||||
|
||||
wpm2 = wpm;
|
||||
if (wpm > 359) wpm2 = 359;
|
||||
@@ -347,9 +340,8 @@ void SetSpeed(int control)
|
||||
else
|
||||
speed.wav_factor = 128 + (128*s1)/130; // = 215 at 170 wpm
|
||||
|
||||
if (wpm >= 350) {
|
||||
if (wpm >= 350)
|
||||
speed.wav_factor = wav_factor_350[wpm-350];
|
||||
}
|
||||
|
||||
if (wpm >= 390) {
|
||||
speed.min_sample_len = 450 - (wpm - 400)/2;
|
||||
@@ -360,15 +352,14 @@ void SetSpeed(int control)
|
||||
speed.pause_factor = (256 * s1)/115; // full speed adjustment, used for pause length
|
||||
speed.clause_pause_factor = 0;
|
||||
|
||||
if (wpm > 430) {
|
||||
if (wpm > 430)
|
||||
speed.pause_factor = 12;
|
||||
} else if (wpm > 400) {
|
||||
else if (wpm > 400)
|
||||
speed.pause_factor = 13;
|
||||
} else if (wpm > 374) {
|
||||
else if (wpm > 374)
|
||||
speed.pause_factor = 14;
|
||||
} else if (wpm > 350) {
|
||||
else if (wpm > 350)
|
||||
speed.pause_factor = pause_factor_350[wpm - 350];
|
||||
}
|
||||
|
||||
if (speed.clause_pause_factor == 0) {
|
||||
// restrict the reduction of pauses between clauses
|
||||
@@ -500,9 +491,8 @@ void CalcLengths(Translator *tr)
|
||||
|
||||
next = &phoneme_list[ix+1];
|
||||
|
||||
if (p->synthflags & SFLAG_EMBEDDED) {
|
||||
if (p->synthflags & SFLAG_EMBEDDED)
|
||||
DoEmbedded2(&embedded_ix);
|
||||
}
|
||||
|
||||
type = p->type;
|
||||
if (p->synthflags & SFLAG_SYLLABLE)
|
||||
@@ -540,9 +530,8 @@ void CalcLengths(Translator *tr)
|
||||
case phFRICATIVE:
|
||||
if (p->newword) {
|
||||
if ((prev->type == phVOWEL) && (p->ph->phflags & phNOPAUSE)) {
|
||||
} else {
|
||||
} else
|
||||
p->prepause = 15;
|
||||
}
|
||||
}
|
||||
|
||||
if (next->type == phPAUSE && prev->type == phNASAL && !(p->ph->phflags&phFORTIS))
|
||||
@@ -563,12 +552,10 @@ void CalcLengths(Translator *tr)
|
||||
p->length = 256;
|
||||
|
||||
if (type == phVFRICATIVE) {
|
||||
if (next->type == phVOWEL) {
|
||||
if (next->type == phVOWEL)
|
||||
pre_voiced = 1;
|
||||
}
|
||||
if ((prev->type == phVOWEL) || (prev->type == phLIQUID)) {
|
||||
if ((prev->type == phVOWEL) || (prev->type == phLIQUID))
|
||||
p->length = (255 + prev->length)/2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -620,24 +607,21 @@ void CalcLengths(Translator *tr)
|
||||
}
|
||||
}
|
||||
|
||||
if (next->type == phVOWEL) {
|
||||
if (next->type == phVOWEL)
|
||||
pre_sonorant = 1;
|
||||
} else {
|
||||
else {
|
||||
p->pitch2 = last_pitch;
|
||||
|
||||
if ((prev->type == phVOWEL) || (prev->type == phLIQUID)) {
|
||||
p->length = prev->length;
|
||||
|
||||
if (p->type == phLIQUID) {
|
||||
if (p->type == phLIQUID)
|
||||
p->length = speed1;
|
||||
}
|
||||
|
||||
if (next->type == phVSTOP) {
|
||||
if (next->type == phVSTOP)
|
||||
p->length = (p->length * 160)/100;
|
||||
}
|
||||
if (next->type == phVFRICATIVE) {
|
||||
if (next->type == phVFRICATIVE)
|
||||
p->length = (p->length * 120)/100;
|
||||
}
|
||||
} else {
|
||||
for (ix2 = ix; ix2 < n_phoneme_list; ix2++) {
|
||||
if (phoneme_list[ix2].type == phVOWEL) {
|
||||
@@ -648,9 +632,8 @@ void CalcLengths(Translator *tr)
|
||||
}
|
||||
|
||||
p->pitch1 = p->pitch2-16;
|
||||
if (p->pitch2 < 16) {
|
||||
if (p->pitch2 < 16)
|
||||
p->pitch1 = 0;
|
||||
}
|
||||
p->env = PITCHfall;
|
||||
pre_voiced = 0;
|
||||
}
|
||||
@@ -663,9 +646,8 @@ void CalcLengths(Translator *tr)
|
||||
|
||||
if (stress > 7) stress = 7;
|
||||
|
||||
if (stress <= 1) {
|
||||
if (stress <= 1)
|
||||
stress = stress ^ 1; // swap diminished and unstressed (until we swap stress_amps,stress_lengths in tr_languages)
|
||||
}
|
||||
if (pre_sonorant)
|
||||
p->amp = tr->stress_amps[stress]-1;
|
||||
else
|
||||
@@ -693,9 +675,8 @@ void CalcLengths(Translator *tr)
|
||||
if (p2->ph->code == phonPAUSE_CLAUSE)
|
||||
end_of_clause = 2;
|
||||
|
||||
if ((p2->newword & 2) && (more_syllables == 0)) {
|
||||
if ((p2->newword & 2) && (more_syllables == 0))
|
||||
end_of_clause = 2;
|
||||
}
|
||||
|
||||
// calc length modifier
|
||||
if ((next->ph->code == phonPAUSE_VSHORT) && (next2->type == phPAUSE)) {
|
||||
@@ -744,9 +725,8 @@ void CalcLengths(Translator *tr)
|
||||
length_mod += tr->langopts.lengthen_tonic;
|
||||
if (emphasized)
|
||||
length_mod += (tr->langopts.lengthen_tonic/2);
|
||||
} else if (emphasized) {
|
||||
} else if (emphasized)
|
||||
length_mod += tr->langopts.lengthen_tonic;
|
||||
}
|
||||
|
||||
if ((len = tr->stress_lengths[stress]) == 0)
|
||||
len = tr->stress_lengths[6];
|
||||
@@ -794,9 +774,8 @@ void CalcLengths(Translator *tr)
|
||||
if (p->tone_ph != 0) {
|
||||
InterpretPhoneme2(p->tone_ph, &phdata_tone);
|
||||
pitch_env = GetEnvelope(phdata_tone.pitch_env);
|
||||
} else {
|
||||
} else
|
||||
pitch_env = envelope_data[env2];
|
||||
}
|
||||
|
||||
pitch_start = p->pitch1 + ((p->pitch2-p->pitch1)*pitch_env[0])/256;
|
||||
|
||||
@@ -813,9 +792,8 @@ void CalcLengths(Translator *tr)
|
||||
if (last_pitch < pitch_start) {
|
||||
prev->env = PITCHrise;
|
||||
p->env = env2;
|
||||
} else {
|
||||
} else
|
||||
prev->env = PITCHfall;
|
||||
}
|
||||
|
||||
prev->length = length_mod;
|
||||
|
||||
@@ -832,14 +810,12 @@ void CalcLengths(Translator *tr)
|
||||
if (next->type == phLIQUID) {
|
||||
next->synthflags |= SFLAG_SEQCONTINUE;
|
||||
|
||||
if (next2->type == phVOWEL) {
|
||||
if (next2->type == phVOWEL)
|
||||
next->synthflags &= ~SFLAG_SEQCONTINUE;
|
||||
}
|
||||
|
||||
if (next2->type != phVOWEL) {
|
||||
if (next->ph->mnemonic == ('/'*256+'r')) {
|
||||
if (next->ph->mnemonic == ('/'*256+'r'))
|
||||
next->synthflags &= ~SFLAG_SEQCONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,9 +107,8 @@ static int dispatch_audio(short *outbuf, int length, espeak_EVENT *event)
|
||||
case AUDIO_OUTPUT_PLAYBACK:
|
||||
{
|
||||
int event_type = 0;
|
||||
if (event) {
|
||||
if (event)
|
||||
event_type = event->type;
|
||||
}
|
||||
|
||||
if (event_type == espeakEVENT_SAMPLERATE) {
|
||||
voice_samplerate = event->id.number;
|
||||
@@ -141,13 +140,11 @@ static int dispatch_audio(short *outbuf, int length, espeak_EVENT *event)
|
||||
// TBD: For example sentence "or ALT)." returns three words
|
||||
// "or", "ALT" and "".
|
||||
// TBD: the last one has its size=0.
|
||||
if (event && (event->type == espeakEVENT_WORD) && (event->length == 0)) {
|
||||
if (event && (event->type == espeakEVENT_WORD) && (event->length == 0))
|
||||
break;
|
||||
}
|
||||
espeak_ERROR a_error = event_declare(event);
|
||||
if (a_error != EE_BUFFER_FULL) {
|
||||
if (a_error != EE_BUFFER_FULL)
|
||||
break;
|
||||
}
|
||||
SHOW_TIME("dispatch_audio > EE_BUFFER_FULL\n");
|
||||
usleep(10000);
|
||||
a_wave_can_be_played = fifo_is_command_enabled();
|
||||
@@ -156,9 +153,8 @@ static int dispatch_audio(short *outbuf, int length, espeak_EVENT *event)
|
||||
break;
|
||||
|
||||
case AUDIO_OUTPUT_RETRIEVAL:
|
||||
if (synth_callback) {
|
||||
if (synth_callback)
|
||||
synth_callback(outbuf, length, event);
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_OUTPUT_SYNCHRONOUS:
|
||||
@@ -166,9 +162,8 @@ static int dispatch_audio(short *outbuf, int length, espeak_EVENT *event)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!a_wave_can_be_played) {
|
||||
if (!a_wave_can_be_played)
|
||||
SHOW_TIME("dispatch_audio > synth must be stopped!\n");
|
||||
}
|
||||
|
||||
SHOW_TIME("LEAVE dispatch_audio\n");
|
||||
|
||||
@@ -190,9 +185,9 @@ static int create_events(short *outbuf, int length, espeak_EVENT *event, uint32_
|
||||
|
||||
do { // for each event
|
||||
espeak_EVENT *event;
|
||||
if (event_list_ix == 0) {
|
||||
if (event_list_ix == 0)
|
||||
event = NULL;
|
||||
} else {
|
||||
else {
|
||||
event = event_list + i;
|
||||
#ifdef DEBUG_ENABLED
|
||||
SHOW("Synthesize: event->sample(%d) + %d = %d\n", event->sample, the_write_pos, event->sample + the_write_pos);
|
||||
@@ -228,16 +223,14 @@ int sync_espeak_terminated_msg(uint32_t unique_identifier, void *user_data)
|
||||
if (my_mode == AUDIO_OUTPUT_PLAYBACK) {
|
||||
while (1) {
|
||||
espeak_ERROR a_error = event_declare(event_list);
|
||||
if (a_error != EE_BUFFER_FULL) {
|
||||
if (a_error != EE_BUFFER_FULL)
|
||||
break;
|
||||
}
|
||||
SHOW_TIME("sync_espeak_terminated_msg > EE_BUFFER_FULL\n");
|
||||
usleep(10000);
|
||||
}
|
||||
} else {
|
||||
if (synth_callback) {
|
||||
if (synth_callback)
|
||||
finished = synth_callback(NULL, 0, event_list);
|
||||
}
|
||||
}
|
||||
return finished;
|
||||
}
|
||||
@@ -353,9 +346,8 @@ static void init_path(const char *path)
|
||||
}
|
||||
|
||||
snprintf(path_home, sizeof(path_home), "%s/espeak-data", getenv("HOME"));
|
||||
if (access(path_home, R_OK) != 0) {
|
||||
if (access(path_home, R_OK) != 0)
|
||||
strcpy(path_home, PATH_ESPEAK_DATA);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -371,9 +363,8 @@ static int initialise(int control)
|
||||
if ((result = LoadPhData(&srate)) != 1) { // reads sample rate from espeak-data/phontab
|
||||
if (result == -1) {
|
||||
fprintf(stderr, "Failed to load espeak-data\n");
|
||||
if ((control & espeakINITIALIZE_DONT_EXIT) == 0) {
|
||||
if ((control & espeakINITIALIZE_DONT_EXIT) == 0)
|
||||
exit(1);
|
||||
}
|
||||
} else
|
||||
fprintf(stderr, "Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n", result, version_phdata, path_home);
|
||||
}
|
||||
@@ -403,9 +394,8 @@ static espeak_ERROR Synthesize(unsigned int unique_identifier, const void *text,
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
ENTER("Synthesize");
|
||||
if (text) {
|
||||
if (text)
|
||||
SHOW("Synthesize > uid=%d, flags=%d, >>>text=%s<<<\n", unique_identifier, flags, text);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((outbuf == NULL) || (event_list == NULL))
|
||||
@@ -419,14 +409,12 @@ static espeak_ERROR Synthesize(unsigned int unique_identifier, const void *text,
|
||||
count_samples = 0;
|
||||
|
||||
#ifdef USE_ASYNC
|
||||
if (my_mode == AUDIO_OUTPUT_PLAYBACK) {
|
||||
if (my_mode == AUDIO_OUTPUT_PLAYBACK)
|
||||
a_write_pos = wave_get_write_position(my_audio);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (translator == NULL) {
|
||||
if (translator == NULL)
|
||||
SetVoiceByName("default");
|
||||
}
|
||||
|
||||
SpeakNextClause(NULL, text, 0);
|
||||
|
||||
@@ -474,9 +462,8 @@ static espeak_ERROR Synthesize(unsigned int unique_identifier, const void *text,
|
||||
return EE_INTERNAL_ERROR;
|
||||
length = 0; // the wave data are played once.
|
||||
#endif
|
||||
} else {
|
||||
} else
|
||||
finished = synth_callback((short *)outbuf, length, event_list);
|
||||
}
|
||||
if (finished) {
|
||||
SpeakNextClause(NULL, 0, 2); // stop
|
||||
break;
|
||||
@@ -496,9 +483,8 @@ static espeak_ERROR Synthesize(unsigned int unique_identifier, const void *text,
|
||||
if (my_mode == AUDIO_OUTPUT_PLAYBACK) {
|
||||
if (dispatch_audio(NULL, 0, NULL) < 0) // TBD: test case
|
||||
return err = EE_INTERNAL_ERROR;
|
||||
} else {
|
||||
} else
|
||||
synth_callback(NULL, 0, event_list); // NULL buffer ptr indicates end of data
|
||||
}
|
||||
#else
|
||||
synth_callback(NULL, 0, event_list); // NULL buffer ptr indicates end of data
|
||||
#endif
|
||||
@@ -561,9 +547,8 @@ void MarkerEvent(int type, unsigned int char_position, int value, int value2, un
|
||||
p = (int *)(ep->id.string);
|
||||
p[0] = value;
|
||||
p[1] = value2;
|
||||
} else {
|
||||
} else
|
||||
ep->id.number = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -744,9 +729,8 @@ ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output_type, int buf_length
|
||||
initialise(options);
|
||||
select_output(output_type);
|
||||
|
||||
if (f_logespeak) {
|
||||
if (f_logespeak)
|
||||
fprintf(f_logespeak, "INIT mode %d options 0x%x\n", output_type, options);
|
||||
}
|
||||
|
||||
// buflength is in mS, allocate 2 bytes per sample
|
||||
if ((buf_length == 0) || (output_type == AUDIO_OUTPUT_PLAYBACK) || (output_type == AUDIO_OUTPUT_SYNCH_PLAYBACK))
|
||||
@@ -805,14 +789,12 @@ ESPEAK_API espeak_ERROR espeak_Synth(const void *text, size_t size,
|
||||
espeak_ERROR a_error = EE_INTERNAL_ERROR;
|
||||
static unsigned int temp_identifier;
|
||||
|
||||
if (unique_identifier == NULL) {
|
||||
if (unique_identifier == NULL)
|
||||
unique_identifier = &temp_identifier;
|
||||
}
|
||||
*unique_identifier = 0;
|
||||
|
||||
if (synchronous_mode) {
|
||||
if (synchronous_mode)
|
||||
return sync_espeak_Synth(0, text, size, position, position_type, end_position, flags, user_data);
|
||||
}
|
||||
|
||||
#ifdef USE_ASYNC
|
||||
// Create the text command
|
||||
@@ -858,19 +840,16 @@ ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text, size_t size,
|
||||
espeak_ERROR a_error = EE_OK;
|
||||
static unsigned int temp_identifier;
|
||||
|
||||
if (f_logespeak) {
|
||||
if (f_logespeak)
|
||||
fprintf(f_logespeak, "\nSYNTH MARK %s posn %d flags 0x%x\n%s\n", index_mark, end_position, flags, (const char *)text);
|
||||
}
|
||||
|
||||
|
||||
if (unique_identifier == NULL) {
|
||||
if (unique_identifier == NULL)
|
||||
unique_identifier = &temp_identifier;
|
||||
}
|
||||
*unique_identifier = 0;
|
||||
|
||||
if (synchronous_mode) {
|
||||
if (synchronous_mode)
|
||||
return sync_espeak_Synth_Mark(0, text, size, index_mark, end_position, flags, user_data);
|
||||
}
|
||||
|
||||
#ifdef USE_ASYNC
|
||||
// Create the mark command
|
||||
@@ -907,9 +886,8 @@ ESPEAK_API espeak_ERROR espeak_Key(const char *key)
|
||||
ENTER("espeak_Key");
|
||||
// symbolic name, symbolicname_character - is there a system resource of symbolicnames per language
|
||||
|
||||
if (f_logespeak) {
|
||||
if (f_logespeak)
|
||||
fprintf(f_logespeak, "\nKEY %s\n", key);
|
||||
}
|
||||
|
||||
espeak_ERROR a_error = EE_OK;
|
||||
|
||||
@@ -921,9 +899,8 @@ ESPEAK_API espeak_ERROR espeak_Key(const char *key)
|
||||
#ifdef USE_ASYNC
|
||||
t_espeak_command *c = create_espeak_key(key, NULL);
|
||||
a_error = fifo_add_command(c);
|
||||
if (a_error != EE_OK) {
|
||||
if (a_error != EE_OK)
|
||||
delete_espeak_command(c);
|
||||
}
|
||||
|
||||
#endif
|
||||
return a_error;
|
||||
@@ -935,9 +912,8 @@ ESPEAK_API espeak_ERROR espeak_Char(wchar_t character)
|
||||
ENTER("espeak_Char");
|
||||
// is there a system resource of character names per language?
|
||||
|
||||
if (f_logespeak) {
|
||||
if (f_logespeak)
|
||||
fprintf(f_logespeak, "\nCHAR U+%x\n", character);
|
||||
}
|
||||
|
||||
#ifdef USE_ASYNC
|
||||
espeak_ERROR a_error;
|
||||
@@ -949,9 +925,8 @@ ESPEAK_API espeak_ERROR espeak_Char(wchar_t character)
|
||||
|
||||
t_espeak_command *c = create_espeak_char(character, NULL);
|
||||
a_error = fifo_add_command(c);
|
||||
if (a_error != EE_OK) {
|
||||
if (a_error != EE_OK)
|
||||
delete_espeak_command(c);
|
||||
}
|
||||
return a_error;
|
||||
#else
|
||||
sync_espeak_Char(character);
|
||||
@@ -981,11 +956,9 @@ ESPEAK_API int espeak_GetParameter(espeak_PARAMETER parameter, int current)
|
||||
{
|
||||
ENTER("espeak_GetParameter");
|
||||
// current: 0=default value, 1=current value
|
||||
if (current) {
|
||||
if (current)
|
||||
return param_stack[0].parameter[parameter];
|
||||
} else {
|
||||
return param_defaults[parameter];
|
||||
}
|
||||
return param_defaults[parameter];
|
||||
}
|
||||
|
||||
|
||||
@@ -993,9 +966,8 @@ ESPEAK_API espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int valu
|
||||
{
|
||||
ENTER("espeak_SetParameter");
|
||||
|
||||
if (f_logespeak) {
|
||||
if (f_logespeak)
|
||||
fprintf(f_logespeak, "SETPARAM %d %d %d\n", parameter, value, relative);
|
||||
}
|
||||
#ifdef USE_ASYNC
|
||||
espeak_ERROR a_error;
|
||||
|
||||
@@ -1007,9 +979,8 @@ ESPEAK_API espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int valu
|
||||
t_espeak_command *c = create_espeak_parameter(parameter, value, relative);
|
||||
|
||||
a_error = fifo_add_command(c);
|
||||
if (a_error != EE_OK) {
|
||||
if (a_error != EE_OK)
|
||||
delete_espeak_command(c);
|
||||
}
|
||||
return a_error;
|
||||
#else
|
||||
SetParameter(parameter, value, relative);
|
||||
@@ -1033,9 +1004,8 @@ ESPEAK_API espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist)
|
||||
|
||||
t_espeak_command *c = create_espeak_punctuation_list(punctlist);
|
||||
a_error = fifo_add_command(c);
|
||||
if (a_error != EE_OK) {
|
||||
if (a_error != EE_OK)
|
||||
delete_espeak_command(c);
|
||||
}
|
||||
return a_error;
|
||||
#else
|
||||
sync_espeak_SetPunctuationList(punctlist);
|
||||
@@ -1095,9 +1065,8 @@ ESPEAK_API espeak_ERROR espeak_Cancel(void)
|
||||
fifo_stop();
|
||||
event_clear_all();
|
||||
|
||||
if (my_mode == AUDIO_OUTPUT_PLAYBACK) {
|
||||
if (my_mode == AUDIO_OUTPUT_PLAYBACK)
|
||||
wave_close(my_audio);
|
||||
}
|
||||
SHOW_TIME("espeak_Cancel > LEAVE");
|
||||
#endif
|
||||
embedded_value[EMBED_T] = 0; // reset echo for pronunciation announcements
|
||||
@@ -1127,9 +1096,8 @@ ESPEAK_API espeak_ERROR espeak_Synchronize(void)
|
||||
espeak_ERROR berr = err;
|
||||
#ifdef USE_ASYNC
|
||||
SHOW_TIME("espeak_Synchronize > ENTER");
|
||||
while (espeak_IsPlaying()) {
|
||||
while (espeak_IsPlaying())
|
||||
usleep(20000);
|
||||
}
|
||||
#endif
|
||||
err = EE_OK;
|
||||
SHOW_TIME("espeak_Synchronize > LEAVE");
|
||||
@@ -1172,9 +1140,8 @@ ESPEAK_API espeak_ERROR espeak_Terminate(void)
|
||||
|
||||
ESPEAK_API const char *espeak_Info(const char **ptr)
|
||||
{
|
||||
if (ptr != NULL) {
|
||||
if (ptr != NULL)
|
||||
*ptr = path_home;
|
||||
}
|
||||
return version_string;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,9 +85,8 @@ float polint(float xa[], float ya[], int n, float x)
|
||||
ho = xa[i]-x;
|
||||
hp = xa[i+m]-x;
|
||||
w = c[i+1]-d[i];
|
||||
if ((den = ho-hp) == 0.0) {
|
||||
if ((den = ho-hp) == 0.0)
|
||||
return ya[2]; // two input xa are identical
|
||||
}
|
||||
den = w/den;
|
||||
d[i] = hp*den;
|
||||
c[i] = ho*den;
|
||||
@@ -178,9 +177,8 @@ int LoadFrame(SpectFrame *frame, FILE *stream, int file_format_type)
|
||||
}
|
||||
|
||||
if (file_format_type > 0) {
|
||||
for (ix = 0; ix < N_KLATTP2; ix++) {
|
||||
for (ix = 0; ix < N_KLATTP2; ix++)
|
||||
fread(frame->klatt_param + ix, sizeof(short), 1, stream);
|
||||
}
|
||||
}
|
||||
|
||||
spect_data = malloc(sizeof(USHORT) * frame->nx);
|
||||
@@ -222,9 +220,8 @@ double GetFrameRms(SpectFrame *frame, int seq_amplitude)
|
||||
}
|
||||
|
||||
maxh = PeaksToHarmspect(wpeaks, 90<<16, htab, 0);
|
||||
for (h = 1; h < maxh; h++) {
|
||||
for (h = 1; h < maxh; h++)
|
||||
total += ((htab[h] * htab[h]) >> 10);
|
||||
}
|
||||
frame->rms = sqrt(total) / 7.25;
|
||||
return frame->rms;
|
||||
}
|
||||
@@ -300,13 +297,13 @@ int LoadSpectSeq(SpectSeq *spect, const char *filename)
|
||||
fread(&id1, sizeof(uint32_t), 1, stream);
|
||||
fread(&id2, sizeof(uint32_t), 1, stream);
|
||||
|
||||
if ((id1 == FILEID1_SPECTSEQ) && (id2 == FILEID2_SPECTSEQ)) {
|
||||
if ((id1 == FILEID1_SPECTSEQ) && (id2 == FILEID2_SPECTSEQ))
|
||||
spect->file_format = 0; // eSpeak formants
|
||||
} else if ((id1 == FILEID1_SPECTSEQ) && (id2 == FILEID2_SPECTSEK)) {
|
||||
else if ((id1 == FILEID1_SPECTSEQ) && (id2 == FILEID2_SPECTSEK))
|
||||
spect->file_format = 1; // formants for Klatt synthesizer
|
||||
} else if ((id1 == FILEID1_SPECTSEQ) && (id2 == FILEID2_SPECTSQ2)) {
|
||||
else if ((id1 == FILEID1_SPECTSEQ) && (id2 == FILEID2_SPECTSQ2))
|
||||
spect->file_format = 2; // formants for Klatt synthesizer
|
||||
} else {
|
||||
else {
|
||||
fprintf(stderr, "Unsupported spectral file format.\n");
|
||||
fclose(stream);
|
||||
return 1;
|
||||
|
||||
@@ -140,9 +140,8 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
|
||||
if (GetFileLength(path) <= 0) {
|
||||
sprintf(path, "/usr/share/mbrola/%s/%s", mbrola_voice, mbrola_voice);
|
||||
|
||||
if (GetFileLength(path) <= 0) {
|
||||
if (GetFileLength(path) <= 0)
|
||||
sprintf(path, "/usr/share/mbrola/voices/%s", mbrola_voice);
|
||||
}
|
||||
}
|
||||
}
|
||||
close_MBR();
|
||||
@@ -175,9 +174,8 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
|
||||
|
||||
mbrola_control = Read4Bytes(f_in);
|
||||
pw = (int *)mbrola_tab;
|
||||
for (ix = 4; ix < size; ix += 4) {
|
||||
for (ix = 4; ix < size; ix += 4)
|
||||
*pw++ = Read4Bytes(f_in);
|
||||
}
|
||||
size = fread(mbrola_tab, 1, size, f_in);
|
||||
fclose(f_in);
|
||||
|
||||
@@ -221,9 +219,9 @@ static int GetMbrName(PHONEME_LIST *plist, PHONEME_TAB *ph, PHONEME_TAB *ph_prev
|
||||
if (mnem == pr->name) {
|
||||
if (pr->next_phoneme == 0)
|
||||
found = 1;
|
||||
else if ((pr->next_phoneme == ':') && (plist->synthflags & SFLAG_LENGTHEN)) {
|
||||
else if ((pr->next_phoneme == ':') && (plist->synthflags & SFLAG_LENGTHEN))
|
||||
found = 1;
|
||||
} else {
|
||||
else {
|
||||
if (pr->control & 2)
|
||||
other_ph = ph_prev;
|
||||
else if ((pr->control & 8) && ((plist+1)->newword))
|
||||
@@ -233,9 +231,8 @@ static int GetMbrName(PHONEME_LIST *plist, PHONEME_TAB *ph, PHONEME_TAB *ph_prev
|
||||
|
||||
if ((pr->next_phoneme == other_ph->mnemonic) ||
|
||||
((pr->next_phoneme == 2) && (other_ph->type == phVOWEL)) ||
|
||||
((pr->next_phoneme == '_') && (other_ph->type == phPAUSE))) {
|
||||
((pr->next_phoneme == '_') && (other_ph->type == phPAUSE)))
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((pr->control & 4) && (plist->newword == 0)) // only at start of word
|
||||
@@ -264,9 +261,8 @@ static int GetMbrName(PHONEME_LIST *plist, PHONEME_TAB *ph, PHONEME_TAB *ph_prev
|
||||
pr++;
|
||||
}
|
||||
|
||||
if (mbr_name_prefix != 0) {
|
||||
if (mbr_name_prefix != 0)
|
||||
mnem = (mnem << 8) | (mbr_name_prefix & 0xff);
|
||||
}
|
||||
mbr_name_prefix = 0;
|
||||
return mnem;
|
||||
}
|
||||
@@ -317,12 +313,10 @@ static char *WritePitch(int env, int pitch1, int pitch2, int split, int final)
|
||||
// set an additional pitch point half way through the phoneme.
|
||||
// but look for a maximum or a minimum and use that instead
|
||||
y[2] = 64;
|
||||
if ((y_max > 0) && (y_max < 127)) {
|
||||
if ((y_max > 0) && (y_max < 127))
|
||||
y[2] = y_max;
|
||||
}
|
||||
if ((y_min > 0) && (y_min < 127)) {
|
||||
if ((y_min > 0) && (y_min < 127))
|
||||
y[2] = y_min;
|
||||
}
|
||||
y[1] = y[2] / 2;
|
||||
y[3] = y[2] + (127 - y[2])/2;
|
||||
|
||||
@@ -341,13 +335,12 @@ static char *WritePitch(int env, int pitch1, int pitch2, int split, int final)
|
||||
for (ix = 1; ix < 4; ix++) {
|
||||
p2 = ((pitch_env[y[ix]]*pitch_range)>>8) + pitch_base;
|
||||
|
||||
if (split > 0) {
|
||||
if (split > 0)
|
||||
y2 = (y[ix] * env100)/env_split;
|
||||
} else if (split < 0) {
|
||||
else if (split < 0)
|
||||
y2 = ((y[ix]-env_split) * env100)/env_split;
|
||||
} else {
|
||||
else
|
||||
y2 = (y[ix] * env100)/128;
|
||||
}
|
||||
if ((y2 > 0) && (y2 <= env100)) {
|
||||
sprintf(buf, " %d %d", y2, p2/4096);
|
||||
strcat(output, buf);
|
||||
@@ -417,9 +410,8 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
ph_prev = plist[phix-1].ph;
|
||||
ph_next = plist[phix+1].ph;
|
||||
|
||||
if (p->synthflags & SFLAG_EMBEDDED) {
|
||||
if (p->synthflags & SFLAG_EMBEDDED)
|
||||
DoEmbedded(&embedded_ix, p->sourceix);
|
||||
}
|
||||
|
||||
if (p->newword & 4)
|
||||
DoMarker(espeakEVENT_SENTENCE, (p->sourceix & 0x7ff) + clause_start_char, 0, count_sentences);
|
||||
@@ -552,9 +544,9 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
pause = 0;
|
||||
}
|
||||
|
||||
if (f_mbrola) {
|
||||
if (f_mbrola)
|
||||
fwrite(mbr_buf, 1, (ptr-mbr_buf), f_mbrola); // write .pho to a file
|
||||
} else {
|
||||
else {
|
||||
int res = write_MBR(mbr_buf);
|
||||
if (res < 0)
|
||||
return 0; /* don't get stuck on error */
|
||||
|
||||
@@ -139,9 +139,8 @@ int LoadPhData(int *srate)
|
||||
rate += (wavefile_data[ix+4] << (ix*8));
|
||||
}
|
||||
|
||||
if (version != version_phdata) {
|
||||
if (version != version_phdata)
|
||||
result = version;
|
||||
}
|
||||
|
||||
// set up phoneme tables
|
||||
p = phoneme_tab_data;
|
||||
@@ -257,18 +256,17 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params,
|
||||
|
||||
frames = &frames_buf[0];
|
||||
if (seq_break > 0) {
|
||||
if (which == 1) {
|
||||
if (which == 1)
|
||||
nf = seq_break + 1;
|
||||
} else {
|
||||
else {
|
||||
frames = &frames_buf[seq_break]; // body of vowel, skip past initial frames
|
||||
nf -= seq_break;
|
||||
}
|
||||
}
|
||||
|
||||
// do we need to modify a frame for blending with a consonant?
|
||||
if ((this_ph->type == phVOWEL) && (fmt_params->fmt2_addr == 0) && (fmt_params->use_vowelin)) {
|
||||
if ((this_ph->type == phVOWEL) && (fmt_params->fmt2_addr == 0) && (fmt_params->use_vowelin))
|
||||
seq_len_adjust += FormantTransition2(frames, &nf, fmt_params->transition0, fmt_params->transition1, NULL, which);
|
||||
}
|
||||
|
||||
length1 = 0;
|
||||
nf1 = nf - 1;
|
||||
@@ -315,9 +313,8 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params,
|
||||
|
||||
length_factor = (length_std * 256)/ length1;
|
||||
|
||||
for (ix = 0; ix < nf1; ix++) {
|
||||
for (ix = 0; ix < nf1; ix++)
|
||||
frames[ix].length = (frames[ix].length * length_factor)/256;
|
||||
}
|
||||
} else {
|
||||
if (which == 1) {
|
||||
// front of a vowel
|
||||
@@ -329,16 +326,14 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params,
|
||||
}
|
||||
} else {
|
||||
// not a vowel
|
||||
if (fmt_params->std_length > 0) {
|
||||
if (fmt_params->std_length > 0)
|
||||
seq_len_adjust += (fmt_params->std_length - length1);
|
||||
}
|
||||
}
|
||||
|
||||
if (seq_len_adjust != 0) {
|
||||
length_factor = ((length1 + seq_len_adjust) * 256)/length1;
|
||||
for (ix = 0; ix < nf1; ix++) {
|
||||
for (ix = 0; ix < nf1; ix++)
|
||||
frames[ix].length = (frames[ix].length * length_factor)/256;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -366,9 +361,8 @@ static void SetUpPhonemeTable(int number, int recursing)
|
||||
int ph_code;
|
||||
PHONEME_TAB *phtab;
|
||||
|
||||
if (recursing == 0) {
|
||||
if (recursing == 0)
|
||||
memset(phoneme_tab_flags, 0, sizeof(phoneme_tab_flags));
|
||||
}
|
||||
|
||||
if ((includes = phoneme_tab_list[number].includes) > 0) {
|
||||
// recursively include base phoneme tables
|
||||
@@ -449,9 +443,8 @@ void LoadConfig(void)
|
||||
}
|
||||
|
||||
sprintf(buf, "%s%c%s", path_home, PATHSEP, "config");
|
||||
if ((f = fopen(buf, "r")) == NULL) {
|
||||
if ((f = fopen(buf, "r")) == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
while (fgets(buf, sizeof(buf), f) != NULL) {
|
||||
if (buf[0] == '/') continue;
|
||||
@@ -462,11 +455,11 @@ void LoadConfig(void)
|
||||
fclose(f_logespeak);
|
||||
f_logespeak = fopen(string, "w");
|
||||
}
|
||||
} else if (memcmp(buf, "tone", 4) == 0) {
|
||||
} else if (memcmp(buf, "tone", 4) == 0)
|
||||
ReadTonePoints(&buf[5], tone_points);
|
||||
} else if (memcmp(buf, "pa_device", 9) == 0) {
|
||||
else if (memcmp(buf, "pa_device", 9) == 0)
|
||||
sscanf(&buf[10], "%d", &option_device_number);
|
||||
} else if (memcmp(buf, "soundicon", 9) == 0) {
|
||||
else if (memcmp(buf, "soundicon", 9) == 0) {
|
||||
ix = sscanf(&buf[10], "_%c %s", &c1, string);
|
||||
if (ix == 2) {
|
||||
soundicon_tab[n_soundicon_tab].name = c1;
|
||||
@@ -501,13 +494,13 @@ static bool StressCondition(Translator *tr, PHONEME_LIST *plist, int condition,
|
||||
PHONEME_LIST *pl;
|
||||
static int condition_level[4] = { 1, 2, 4, 15 };
|
||||
|
||||
if (phoneme_tab[plist[0].phcode]->type == phVOWEL) {
|
||||
if (phoneme_tab[plist[0].phcode]->type == phVOWEL)
|
||||
pl = plist;
|
||||
} else {
|
||||
else {
|
||||
// consonant, get stress from the following vowel
|
||||
if (phoneme_tab[plist[1].phcode]->type == phVOWEL) {
|
||||
if (phoneme_tab[plist[1].phcode]->type == phVOWEL)
|
||||
pl = &plist[1];
|
||||
} else
|
||||
else
|
||||
return false; // no stress elevel for this consonant
|
||||
}
|
||||
|
||||
@@ -525,9 +518,8 @@ static bool StressCondition(Translator *tr, PHONEME_LIST *plist, int condition,
|
||||
}
|
||||
}
|
||||
|
||||
if (condition == 4) {
|
||||
if (condition == 4)
|
||||
return stress_level >= pl->wordstress;
|
||||
}
|
||||
|
||||
if (condition == 3) {
|
||||
// if stressed
|
||||
@@ -815,9 +807,8 @@ static void SwitchOnVowelType(PHONEME_LIST *plist, PHONEME_DATA *phdata, USHORT
|
||||
if (instn_type == 2) {
|
||||
phdata->pd_control |= pd_FORNEXTPH;
|
||||
voweltype = plist[1].ph->start_type; // SwitchNextVowelType
|
||||
} else {
|
||||
} else
|
||||
voweltype = plist[-1].ph->end_type; // SwitchPrevVowelType
|
||||
}
|
||||
|
||||
voweltype -= phonVOWELTYPES;
|
||||
if ((voweltype >= 0) && (voweltype < 6)) {
|
||||
@@ -874,9 +865,8 @@ int NumInstnWords(USHORT *prog)
|
||||
// This instruction is followed by addWav(), 2 more words
|
||||
return 4;
|
||||
}
|
||||
if (instn2 == i_CONTINUE) {
|
||||
if (instn2 == i_CONTINUE)
|
||||
return 3;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -915,9 +905,8 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
phdata->pd_param[i_SET_LENGTH] = ph->std_length;
|
||||
phdata->pd_param[i_LENGTH_MOD] = ph->length_mod;
|
||||
|
||||
if (ph->program == 0) {
|
||||
if (ph->program == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
end_flag = 0;
|
||||
|
||||
@@ -964,17 +953,15 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
}
|
||||
phdata->ipa_string[ix] = 0;
|
||||
} else if (instn2 < N_PHONEME_DATA_PARAM) {
|
||||
if (instn2 == i_CHANGE_PHONEME2) {
|
||||
if (instn2 == i_CHANGE_PHONEME2)
|
||||
phdata->pd_param[i_CHANGE_PHONEME] = data; // also set ChangePhoneme
|
||||
}
|
||||
phdata->pd_param[instn2] = data;
|
||||
if ((instn2 == i_CHANGE_PHONEME) && (control & 0x100)) {
|
||||
// found ChangePhoneme() in PhonemeList mode, exit
|
||||
end_flag = 1;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
InvalidInstn(ph, instn);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@@ -1013,9 +1000,9 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
}
|
||||
|
||||
if (truth == false) {
|
||||
if ((instn & 0xf800) == i_JUMP_FALSE) {
|
||||
if ((instn & 0xf800) == i_JUMP_FALSE)
|
||||
prog += instn & 0xff;
|
||||
} else {
|
||||
else {
|
||||
// instruction after a condition is not JUMP_FALSE, so skip the instruction.
|
||||
prog += NumInstnWords(prog);
|
||||
if ((prog[0] & 0xfe00) == 0x6000)
|
||||
@@ -1118,9 +1105,8 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
break;
|
||||
}
|
||||
|
||||
if (ph->phflags & phSINGLE_INSTN) {
|
||||
if (ph->phflags & phSINGLE_INSTN)
|
||||
end_flag = 1; // this phoneme has a one-instruction program, with an implicit Return
|
||||
}
|
||||
|
||||
if ((end_flag == 1) && (n_return > 0)) {
|
||||
// return from called procedure or phoneme
|
||||
@@ -1129,9 +1115,8 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
}
|
||||
}
|
||||
|
||||
if ((worddata != NULL) && (plist->type == phVOWEL)) {
|
||||
if ((worddata != NULL) && (plist->type == phVOWEL))
|
||||
memcpy(&worddata->prev_vowel, &plist[0], sizeof(PHONEME_LIST));
|
||||
}
|
||||
|
||||
plist->std_length = phdata->pd_param[i_SET_LENGTH];
|
||||
if (phdata->sound_addr[0] != 0) {
|
||||
|
||||
@@ -215,9 +215,9 @@ static void DoPause(int length, int control)
|
||||
else {
|
||||
len = PauseLength(length, control);
|
||||
|
||||
if (len < 90000) {
|
||||
if (len < 90000)
|
||||
len = (len * samplerate) / 1000; // convert from mS to number of samples
|
||||
} else {
|
||||
else {
|
||||
srate2 = samplerate / 25; // avoid overflow
|
||||
len = (len * srate2) / 40;
|
||||
}
|
||||
@@ -278,9 +278,8 @@ static int DoSample2(int index, int which, int std_length, int control, int leng
|
||||
std_length = wav_length;
|
||||
}
|
||||
|
||||
if (length_mod > 0) {
|
||||
if (length_mod > 0)
|
||||
std_length = (std_length * length_mod)/256;
|
||||
}
|
||||
|
||||
length = (std_length * speed.wav_factor)/256;
|
||||
|
||||
@@ -391,11 +390,10 @@ int DoSample3(PHONEME_DATA *phdata, int length_mod, int amp)
|
||||
|
||||
seq_len_adjust = 0;
|
||||
|
||||
if (phdata->sound_addr[pd_WAV] == 0) {
|
||||
if (phdata->sound_addr[pd_WAV] == 0)
|
||||
len = 0;
|
||||
} else {
|
||||
else
|
||||
len = DoSample2(phdata->sound_addr[pd_WAV], 2, phdata->pd_param[pd_LENGTHMOD]*2, phdata->pd_control, length_mod, amp2);
|
||||
}
|
||||
last_frame = NULL;
|
||||
return len;
|
||||
}
|
||||
@@ -446,9 +444,8 @@ static void set_frame_rms(frame_t *fr, int new_rms)
|
||||
};
|
||||
|
||||
if (voice->klattv[0]) {
|
||||
if (new_rms == -1) {
|
||||
if (new_rms == -1)
|
||||
fr->klattp[KLATT_AV] = 50;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -526,9 +523,8 @@ static void AdjustFormants(frame_t *fr, int target, int min, int max, int f1_adj
|
||||
fr->ffreq[2] += x;
|
||||
fr->ffreq[3] += f3_adj;
|
||||
|
||||
if (flags & 0x20) {
|
||||
if (flags & 0x20)
|
||||
f3_adj = -f3_adj; // . reverse direction for f4,f5 change
|
||||
}
|
||||
fr->ffreq[4] += f3_adj;
|
||||
fr->ffreq[5] += f3_adj;
|
||||
|
||||
@@ -627,18 +623,15 @@ int FormantTransition2(frameref_t *seq, int *n_frames, unsigned int data1, unsig
|
||||
|
||||
next_rms = seq[1].frame->rms;
|
||||
|
||||
if (voice->klattv[0]) {
|
||||
if (voice->klattv[0])
|
||||
fr->klattp[KLATT_AV] = seq[1].frame->klattp[KLATT_AV] - 4;
|
||||
}
|
||||
if (f2 != 0) {
|
||||
if (rms & 0x20) {
|
||||
if (rms & 0x20)
|
||||
set_frame_rms(fr, (next_rms * (rms & 0x1f))/30);
|
||||
}
|
||||
AdjustFormants(fr, f2, f2_min, f2_max, f1, f3_adj, f3_amp, flags);
|
||||
|
||||
if ((rms & 0x20) == 0) {
|
||||
if ((rms & 0x20) == 0)
|
||||
set_frame_rms(fr, rms*2);
|
||||
}
|
||||
} else {
|
||||
if (flags & 8)
|
||||
set_frame_rms(fr, (next_rms*24)/32);
|
||||
@@ -646,9 +639,8 @@ int FormantTransition2(frameref_t *seq, int *n_frames, unsigned int data1, unsig
|
||||
set_frame_rms(fr, RMS_START);
|
||||
}
|
||||
|
||||
if (flags & 8) {
|
||||
if (flags & 8)
|
||||
modn_flags = 0x800 + (VowelCloseness(fr) << 8);
|
||||
}
|
||||
} else {
|
||||
// exit from vowel
|
||||
rms = rms*2;
|
||||
@@ -666,9 +658,8 @@ int FormantTransition2(frameref_t *seq, int *n_frames, unsigned int data1, unsig
|
||||
if (len > 36)
|
||||
seq_len_adjust += (len - 36);
|
||||
|
||||
if (f2 != 0) {
|
||||
if (f2 != 0)
|
||||
AdjustFormants(fr, f2, f2_min, f2_max, f1, f3_adj, f3_amp, flags);
|
||||
}
|
||||
}
|
||||
|
||||
set_frame_rms(fr, rms);
|
||||
@@ -771,11 +762,10 @@ static void SmoothSpect(void)
|
||||
f2 = frame->ffreq[pk];
|
||||
|
||||
// backwards
|
||||
if ((diff = f2 - f1) > 0) {
|
||||
if ((diff = f2 - f1) > 0)
|
||||
allowed = f1*2 + f2;
|
||||
} else {
|
||||
else
|
||||
allowed = f1 + f2*2;
|
||||
}
|
||||
|
||||
// the allowed change is specified as percentage (%*10) of the frequency
|
||||
// take "frequency" as 1/3 from the lower freq
|
||||
@@ -843,11 +833,10 @@ static void SmoothSpect(void)
|
||||
f2 = frame->ffreq[pk];
|
||||
|
||||
// forwards
|
||||
if ((diff = f2 - f1) > 0) {
|
||||
if ((diff = f2 - f1) > 0)
|
||||
allowed = f1*2 + f2;
|
||||
} else {
|
||||
else
|
||||
allowed = f1 + f2*2;
|
||||
}
|
||||
allowed = (allowed * formant_rate[pk])/3000;
|
||||
allowed = (allowed * len)/256;
|
||||
|
||||
@@ -928,9 +917,8 @@ int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_L
|
||||
if (which == 1) {
|
||||
// limit the shortening of sonorants before shortened (eg. unstressed vowels)
|
||||
if ((this_ph->type == phLIQUID) || (plist[-1].type == phLIQUID) || (plist[-1].type == phNASAL)) {
|
||||
if (length_mod < (len = translator->langopts.param[LOPT_SONORANT_MIN])) {
|
||||
if (length_mod < (len = translator->langopts.param[LOPT_SONORANT_MIN]))
|
||||
length_mod = len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1016,9 +1004,8 @@ int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_L
|
||||
|
||||
if ((length_sum > 0) && (length_sum < length_min)) {
|
||||
// lengthen, so that the sequence is greater than one cycle at low pitch
|
||||
for (frameix = 1; frameix < n_frames; frameix++) {
|
||||
for (frameix = 1; frameix < n_frames; frameix++)
|
||||
frame_lengths[frameix] = (frame_lengths[frameix] * length_min) / length_sum;
|
||||
}
|
||||
}
|
||||
|
||||
for (frameix = 1; frameix < n_frames; frameix++) {
|
||||
@@ -1034,9 +1021,8 @@ int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_L
|
||||
}
|
||||
|
||||
if (modulation >= 0) {
|
||||
if (frame1->frflags & FRFLAG_MODULATE) {
|
||||
if (frame1->frflags & FRFLAG_MODULATE)
|
||||
modulation = 6;
|
||||
}
|
||||
if ((frameix == n_frames-1) && (modn_flags & 0xf00))
|
||||
modulation |= modn_flags; // before or after a glottal stop
|
||||
}
|
||||
@@ -1265,25 +1251,20 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
next = &phoneme_list[ix+1];
|
||||
next2 = &phoneme_list[ix+2];
|
||||
|
||||
if (p->synthflags & SFLAG_EMBEDDED) {
|
||||
if (p->synthflags & SFLAG_EMBEDDED)
|
||||
DoEmbedded(&embedded_ix, p->sourceix);
|
||||
}
|
||||
|
||||
if (p->newword) {
|
||||
if (((p->type == phVOWEL) && (translator->langopts.param[LOPT_WORD_MERGE] & 1)) ||
|
||||
(p->ph->phflags & phNOPAUSE)) {
|
||||
} else {
|
||||
} else
|
||||
last_frame = NULL;
|
||||
}
|
||||
|
||||
sourceix = (p->sourceix & 0x7ff) + clause_start_char;
|
||||
|
||||
if (p->newword & 4)
|
||||
DoMarker(espeakEVENT_SENTENCE, sourceix, 0, count_sentences); // start of sentence
|
||||
|
||||
// if(p->newword & 2)
|
||||
// DoMarker(espeakEVENT_END, count_characters, 0, count_sentences); // end of clause
|
||||
|
||||
if (p->newword & 1)
|
||||
DoMarker(espeakEVENT_WORD, sourceix, p->sourceix >> 11, clause_start_word + word_count++); // NOTE, this count doesn't include multiple-word pronunciations in *_list. eg (of a)
|
||||
}
|
||||
@@ -1314,9 +1295,9 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
case phSTOP:
|
||||
released = 0;
|
||||
ph = p->ph;
|
||||
if (next->type == phVOWEL) {
|
||||
if (next->type == phVOWEL)
|
||||
released = 1;
|
||||
} else if (!next->newword) {
|
||||
else if (!next->newword) {
|
||||
if (next->type == phLIQUID) released = 1;
|
||||
}
|
||||
if (released == 0)
|
||||
@@ -1345,9 +1326,8 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
case phFRICATIVE:
|
||||
InterpretPhoneme(NULL, 0, p, &phdata, &worddata);
|
||||
|
||||
if (p->synthflags & SFLAG_LENGTHEN) {
|
||||
if (p->synthflags & SFLAG_LENGTHEN)
|
||||
DoSample3(&phdata, p->length, 0); // play it twice for [s:] etc.
|
||||
}
|
||||
DoSample3(&phdata, p->length, 0);
|
||||
break;
|
||||
|
||||
@@ -1384,17 +1364,15 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
DoSpect2(ph, 0, &fmtp, p, 0);
|
||||
}
|
||||
} else {
|
||||
if (p->synthflags & SFLAG_LENGTHEN) {
|
||||
if (p->synthflags & SFLAG_LENGTHEN)
|
||||
DoPause(50, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (pre_voiced) {
|
||||
// followed by a vowel, or liquid + vowel
|
||||
StartSyllable();
|
||||
} else {
|
||||
} else
|
||||
p->synthflags |= SFLAG_NEXT_PAUSE;
|
||||
}
|
||||
InterpretPhoneme(NULL, 0, p, &phdata, &worddata);
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
fmtp.fmt_amp = phdata.sound_param[pd_FMT];
|
||||
@@ -1424,11 +1402,10 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
}
|
||||
}
|
||||
|
||||
if ((next->type == phVOWEL) || ((next->type == phLIQUID) && (next->newword == 0))) { // ?? test 14.Aug.2007
|
||||
if ((next->type == phVOWEL) || ((next->type == phLIQUID) && (next->newword == 0))) // ?? test 14.Aug.2007
|
||||
StartSyllable();
|
||||
} else {
|
||||
else
|
||||
p->synthflags |= SFLAG_NEXT_PAUSE;
|
||||
}
|
||||
InterpretPhoneme(NULL, 0, p, &phdata, &worddata);
|
||||
memset(&fmtp, 0, sizeof(fmtp));
|
||||
fmtp.std_length = phdata.pd_param[i_SET_LENGTH]*2;
|
||||
@@ -1449,9 +1426,8 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
DoPitch(envelope_data[p->env], p->pitch1, p->pitch2);
|
||||
}
|
||||
|
||||
if (prev->type == phNASAL) {
|
||||
if (prev->type == phNASAL)
|
||||
last_frame = NULL;
|
||||
}
|
||||
|
||||
InterpretPhoneme(NULL, 0, p, &phdata, &worddata);
|
||||
fmtp.std_length = phdata.pd_param[i_SET_LENGTH]*2;
|
||||
@@ -1461,9 +1437,9 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
if (next->type == phVOWEL) {
|
||||
StartSyllable();
|
||||
DoSpect2(p->ph, 0, &fmtp, p, 0);
|
||||
} else if (prev->type == phVOWEL && (p->synthflags & SFLAG_SEQCONTINUE)) {
|
||||
} else if (prev->type == phVOWEL && (p->synthflags & SFLAG_SEQCONTINUE))
|
||||
DoSpect2(p->ph, 0, &fmtp, p, 0);
|
||||
} else {
|
||||
else {
|
||||
last_frame = NULL; // only for nasal ?
|
||||
DoSpect2(p->ph, 0, &fmtp, p, 0);
|
||||
last_frame = NULL;
|
||||
@@ -1482,18 +1458,15 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
DoPitch(envelope_data[p->env], p->pitch1, p->pitch2);
|
||||
}
|
||||
|
||||
if (prev->type == phNASAL) {
|
||||
if (prev->type == phNASAL)
|
||||
last_frame = NULL;
|
||||
}
|
||||
|
||||
if (next->type == phVOWEL) {
|
||||
if (next->type == phVOWEL)
|
||||
StartSyllable();
|
||||
}
|
||||
InterpretPhoneme(NULL, 0, p, &phdata, &worddata);
|
||||
|
||||
if ((value = (phdata.pd_param[i_PAUSE_BEFORE] - p->prepause)) > 0) {
|
||||
if ((value = (phdata.pd_param[i_PAUSE_BEFORE] - p->prepause)) > 0)
|
||||
DoPause(value, 1);
|
||||
}
|
||||
fmtp.std_length = phdata.pd_param[i_SET_LENGTH]*2;
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
fmtp.fmt_amp = phdata.sound_param[pd_FMT];
|
||||
@@ -1587,9 +1560,9 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
fmtp.transition0 = 0;
|
||||
fmtp.transition1 = 0;
|
||||
|
||||
if ((fmtp.fmt2_addr = phdata.sound_addr[pd_VWLEND]) != 0) {
|
||||
if ((fmtp.fmt2_addr = phdata.sound_addr[pd_VWLEND]) != 0)
|
||||
fmtp.fmt2_lenadj = phdata.sound_param[pd_VWLEND];
|
||||
} else if (next->type != phPAUSE) {
|
||||
else if (next->type != phPAUSE) {
|
||||
fmtp.fmt2_lenadj = 0;
|
||||
InterpretPhoneme(NULL, 0, next, &phdata_next, NULL);
|
||||
|
||||
@@ -1625,17 +1598,15 @@ static int paused = 0;
|
||||
|
||||
int SynthOnTimer()
|
||||
{
|
||||
if (!timer_on) {
|
||||
if (!timer_on)
|
||||
return WavegenCloseSound();
|
||||
}
|
||||
|
||||
do {
|
||||
if (WcmdqUsed() > 0)
|
||||
WavegenOpenSound();
|
||||
|
||||
if (Generate(phoneme_list, &n_phoneme_list, 1) == 0) {
|
||||
if (Generate(phoneme_list, &n_phoneme_list, 1) == 0)
|
||||
SpeakNextClause(NULL, NULL, 1);
|
||||
}
|
||||
} while (skipping_text);
|
||||
|
||||
return 0;
|
||||
@@ -1730,9 +1701,8 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (current_phoneme_table != voice->phoneme_tab_ix) {
|
||||
if (current_phoneme_table != voice->phoneme_tab_ix)
|
||||
SelectPhonemeTable(voice->phoneme_tab_ix);
|
||||
}
|
||||
|
||||
// read the next clause from the input text file, translate it, and generate
|
||||
// entries in the wavegen command queue
|
||||
@@ -1743,12 +1713,10 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control)
|
||||
|
||||
if ((option_phonemes & 0xf) || (phoneme_callback != NULL)) {
|
||||
phon_out = GetTranslatedPhonemeString(option_phonemes);
|
||||
if (option_phonemes & 0xf) {
|
||||
if (option_phonemes & 0xf)
|
||||
fprintf(f_trans, "%s\n", phon_out);
|
||||
}
|
||||
if (phoneme_callback != NULL) {
|
||||
if (phoneme_callback != NULL)
|
||||
phoneme_callback(phon_out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -157,9 +157,8 @@ static void ResetLetterBits(Translator *tr, int groups)
|
||||
|
||||
mask = ~groups;
|
||||
|
||||
for (ix = 0; ix < sizeof(tr->letter_bits); ix++) {
|
||||
for (ix = 0; ix < sizeof(tr->letter_bits); ix++)
|
||||
tr->letter_bits[ix] &= mask;
|
||||
}
|
||||
}
|
||||
|
||||
static void SetLetterBits(Translator *tr, int group, const char *string)
|
||||
@@ -178,9 +177,8 @@ static void SetLetterBitsRange(Translator *tr, int group, int first, int last)
|
||||
int ix;
|
||||
|
||||
bits = (1L << group);
|
||||
for (ix = first; ix <= last; ix++) {
|
||||
for (ix = first; ix <= last; ix++)
|
||||
tr->letter_bits[ix] |= bits;
|
||||
}
|
||||
}
|
||||
|
||||
// ignore these characters
|
||||
@@ -767,9 +765,8 @@ Translator *SelectTranslator(const char *name)
|
||||
// stress last syllable unless word ends with a vowel
|
||||
tr->langopts.stress_rule = STRESSPOSN_1R;
|
||||
tr->langopts.stress_flags = S_FINAL_VOWEL_UNSTRESSED | S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_NO_AUTO_2;
|
||||
} else {
|
||||
} else
|
||||
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use es_rules for unpronouncable rules
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -884,9 +881,9 @@ Translator *SelectTranslator(const char *name)
|
||||
tr->langopts.break_numbers = 0x14aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
|
||||
tr->letter_bits_offset = OFFSET_DEVANAGARI;
|
||||
|
||||
if (name2 == L('p', 'a')) {
|
||||
if (name2 == L('p', 'a'))
|
||||
tr->letter_bits_offset = OFFSET_GURMUKHI;
|
||||
} else if (name2 == L('g', 'u')) {
|
||||
else if (name2 == L('g', 'u')) {
|
||||
SetupTranslator(tr, stress_lengths_equal, stress_amps_equal);
|
||||
tr->letter_bits_offset = OFFSET_GUJARATI;
|
||||
tr->langopts.stress_rule = STRESSPOSN_2R;
|
||||
@@ -895,9 +892,8 @@ Translator *SelectTranslator(const char *name)
|
||||
tr->langopts.break_numbers = 0x2aaaa8;
|
||||
tr->langopts.max_digits = 22;
|
||||
tr->langopts.numbers2 |= NUM2_ENGLISH_NUMERALS;
|
||||
} else if (name2 == L('o', 'r')) {
|
||||
} else if (name2 == L('o', 'r'))
|
||||
tr->letter_bits_offset = OFFSET_ORIYA;
|
||||
}
|
||||
SetIndicLetters(tr);
|
||||
}
|
||||
break;
|
||||
@@ -1485,9 +1481,9 @@ Translator *SelectTranslator(const char *name)
|
||||
tr->langopts.numbers = NUM_OMIT_1_THOUSAND;
|
||||
tr->langopts.numbers2 = NUM2_ORDINAL_AND_THOUSANDS;
|
||||
tr->langopts.param[LOPT_WORD_MERGE] = 1; // don't break vowels betwen words
|
||||
} else if (name2 == L('m', 'r')) {
|
||||
} else if (name2 == L('m', 'r'))
|
||||
tr->letter_bits_offset = OFFSET_DEVANAGARI;
|
||||
} else if (name2 == L('m', 'l')) {
|
||||
else if (name2 == L('m', 'l')) {
|
||||
static const short stress_lengths_ml[8] = { 180, 160, 240, 240, 0, 0, 260, 260 };
|
||||
SetupTranslator(tr, stress_lengths_ml, stress_amps_equal);
|
||||
tr->letter_bits_offset = OFFSET_MALAYALAM;
|
||||
@@ -1521,11 +1517,10 @@ Translator *SelectTranslator(const char *name)
|
||||
tr->langopts.dotless_i = 1;
|
||||
tr->langopts.param[LOPT_SUFFIX] = 1;
|
||||
|
||||
if (name2 == L('a', 'z')) {
|
||||
if (name2 == L('a', 'z'))
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
|
||||
} else {
|
||||
else
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
|
||||
}
|
||||
tr->langopts.max_initial_consonants = 2;
|
||||
}
|
||||
break;
|
||||
@@ -1640,9 +1635,8 @@ void ProcessLanguageOptions(LANGUAGE_OPTIONS *langopts)
|
||||
langopts->thousands_sep = '.';
|
||||
langopts->decimal_sep = ',';
|
||||
}
|
||||
if (langopts->numbers & NUM_THOUS_SPACE) {
|
||||
if (langopts->numbers & NUM_THOUS_SPACE)
|
||||
langopts->thousands_sep = 0; // don't allow thousands separator, except space
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -365,9 +365,8 @@ void SetLengthMods(Translator *tr, int value)
|
||||
int value2;
|
||||
|
||||
tr->langopts.length_mods0 = tr->langopts.length_mods = length_mod_tabs[value % 100];
|
||||
if ((value2 = value / 100) != 0) {
|
||||
if ((value2 = value / 100) != 0)
|
||||
tr->langopts.length_mods0 = length_mod_tabs[value2];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -580,9 +579,8 @@ int utf8_in2(int *c, const char *buf, int backwards)
|
||||
n_bytes = 3;
|
||||
|
||||
c1 &= mask[n_bytes];
|
||||
for (ix = 0; ix < n_bytes; ix++) {
|
||||
for (ix = 0; ix < n_bytes; ix++)
|
||||
c1 = (c1 << 6) + (*buf++ & 0x3f);
|
||||
}
|
||||
}
|
||||
*c = c1;
|
||||
return n_bytes+1;
|
||||
@@ -772,9 +770,8 @@ int ChangeEquivalentPhonemes(Translator *tr, int lang2, char *phonemes)
|
||||
}
|
||||
*p_out = 0;
|
||||
|
||||
if (remove_stress) {
|
||||
if (remove_stress)
|
||||
SetWordStress(tr, phonbuf, NULL, -1, 0);
|
||||
}
|
||||
|
||||
strcpy(phonemes, phonbuf);
|
||||
|
||||
@@ -912,9 +909,8 @@ int TranslateWord(Translator *tr, char *word_start, int next_pause, WORD_TAB *wt
|
||||
found = LookupDictList(tr, &word1, phonemes, dictionary_flags, FLAG_ALLOW_TEXTMODE, wtab); // the original word
|
||||
|
||||
|
||||
if ((dictionary_flags[0] & (FLAG_ALLOW_DOT | FLAG_NEEDS_DOT)) && (wordx[1] == '.')) {
|
||||
if ((dictionary_flags[0] & (FLAG_ALLOW_DOT | FLAG_NEEDS_DOT)) && (wordx[1] == '.'))
|
||||
wordx[1] = ' '; // remove a Dot after this word
|
||||
}
|
||||
|
||||
if (dictionary_flags[0] & FLAG_TEXTMODE) {
|
||||
if (word_out != NULL)
|
||||
@@ -1087,9 +1083,8 @@ int TranslateWord(Translator *tr, char *word_start, int next_pause, WORD_TAB *wt
|
||||
// ?? should we say super/sub-script numbers and letters here?
|
||||
utf8_in(&wc, wordx);
|
||||
if ((word_length == 1) && (IsAlpha(wc) || IsSuperscript(wc))) {
|
||||
if ((wordx = SpeakIndividualLetters(tr, wordx, phonemes, spell_word)) == NULL) {
|
||||
if ((wordx = SpeakIndividualLetters(tr, wordx, phonemes, spell_word)) == NULL)
|
||||
return 0;
|
||||
}
|
||||
strcpy(word_phonemes, phonemes);
|
||||
return 0;
|
||||
}
|
||||
@@ -1150,9 +1145,8 @@ int TranslateWord(Translator *tr, char *word_start, int next_pause, WORD_TAB *wt
|
||||
for (ix = 0; ix < n_chars; ix++) { // num. of bytes to remove
|
||||
prefix_chars[pfix++] = *wordx++;
|
||||
|
||||
if ((prefix_type & SUFX_B) && (ix == (n_chars-1))) {
|
||||
if ((prefix_type & SUFX_B) && (ix == (n_chars-1)))
|
||||
prefix_chars[pfix-1] = 0; // discard the last character of the prefix, this is the separator character
|
||||
}
|
||||
}
|
||||
prefix_chars[pfix] = 0;
|
||||
}
|
||||
@@ -1173,16 +1167,14 @@ int TranslateWord(Translator *tr, char *word_start, int next_pause, WORD_TAB *wt
|
||||
|
||||
// look for stress marker or $abbrev
|
||||
found = LookupDictList(tr, &wordpf, phonemes, dictionary_flags, 0, wtab);
|
||||
if (found) {
|
||||
if (found)
|
||||
strcpy(prefix_phonemes, phonemes);
|
||||
}
|
||||
if (dictionary_flags[0] & FLAG_ABBREV) {
|
||||
prefix_phonemes[0] = 0;
|
||||
SpeakIndividualLetters(tr, wordpf, prefix_phonemes, 1);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
strcat(prefix_phonemes, end_phonemes);
|
||||
}
|
||||
end_phonemes[0] = 0;
|
||||
|
||||
end_type = 0;
|
||||
@@ -1249,10 +1241,6 @@ int TranslateWord(Translator *tr, char *word_start, int next_pause, WORD_TAB *wt
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dictionary_flags2[0] & FLAG_ABBREV) {
|
||||
// Removing the suffix leaves a word which should be spoken as individual letters
|
||||
// Not yet implemented
|
||||
}
|
||||
if (dictionary_flags[0] == 0) {
|
||||
dictionary_flags[0] = dictionary_flags2[0];
|
||||
dictionary_flags[1] = dictionary_flags2[1];
|
||||
@@ -1328,15 +1316,13 @@ int TranslateWord(Translator *tr, char *word_start, int next_pause, WORD_TAB *wt
|
||||
/* determine stress pattern for this word */
|
||||
/******************************************/
|
||||
add_suffix_phonemes = 0;
|
||||
if (end_phonemes[0] != 0) {
|
||||
if (end_phonemes[0] != 0)
|
||||
add_suffix_phonemes = 2;
|
||||
}
|
||||
|
||||
prefix_stress = 0;
|
||||
for (p = prefix_phonemes; *p != 0; p++) {
|
||||
if ((*p == phonSTRESS_P) || (*p == phonSTRESS_P2)) {
|
||||
if ((*p == phonSTRESS_P) || (*p == phonSTRESS_P2))
|
||||
prefix_stress = *p;
|
||||
}
|
||||
}
|
||||
if (prefix_flags || (prefix_stress != 0)) {
|
||||
if ((tr->langopts.param[LOPT_PREFIXES]) || (prefix_type & SUFX_T)) {
|
||||
@@ -1397,9 +1383,9 @@ int TranslateWord(Translator *tr, char *word_start, int next_pause, WORD_TAB *wt
|
||||
dictionary_flags[0] &= ~FLAG_PAUSE1;
|
||||
}
|
||||
|
||||
if ((wflags & FLAG_HYPHEN) && (tr->langopts.stress_flags & S_HYPEN_UNSTRESS)) {
|
||||
if ((wflags & FLAG_HYPHEN) && (tr->langopts.stress_flags & S_HYPEN_UNSTRESS))
|
||||
ChangeWordStress(tr, word_phonemes, 3);
|
||||
} else if (wflags & FLAG_EMPHASIZED2) {
|
||||
else if (wflags & FLAG_EMPHASIZED2) {
|
||||
// A word is indicated in the source text as stressed
|
||||
// Give it stress level 6 (for the intonation module)
|
||||
ChangeWordStress(tr, word_phonemes, 6);
|
||||
@@ -1467,9 +1453,8 @@ int TranslateWord(Translator *tr, char *word_start, int next_pause, WORD_TAB *wt
|
||||
dictionary_flags[0] |= FLAG_ALLOW_DOT;
|
||||
}
|
||||
|
||||
if ((tr->langopts.param[LOPT_ALT] & 2) && ((dictionary_flags[0] & (FLAG_ALT_TRANS | FLAG_ALT2_TRANS)) != 0)) {
|
||||
if ((tr->langopts.param[LOPT_ALT] & 2) && ((dictionary_flags[0] & (FLAG_ALT_TRANS | FLAG_ALT2_TRANS)) != 0))
|
||||
ApplySpecialAttribute2(tr, word_phonemes, dictionary_flags[0]);
|
||||
}
|
||||
|
||||
dictionary_flags[0] |= was_unpronouncable;
|
||||
memcpy(word_start, word_copy2, word_copy_length);
|
||||
@@ -1573,9 +1558,8 @@ int SetTranslator2(const char *new_language)
|
||||
translator2->dict_condition = 0x48; // bits 3, 6
|
||||
translator2->langopts.param[LOPT_REDUCE_T] = 1;
|
||||
}
|
||||
if (dialect == DICTDIALECT_ES_LA) {
|
||||
if (dialect == DICTDIALECT_ES_LA)
|
||||
translator2->dict_condition = 0x04; // bit 2
|
||||
}
|
||||
}
|
||||
translator2->phoneme_tab_ix = new_phoneme_tab;
|
||||
}
|
||||
@@ -1700,9 +1684,8 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
word_phonemes[1] = ix;
|
||||
word_phonemes[2] = 0;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
EncodePhonemes(word, word_phonemes, &bad_phoneme);
|
||||
}
|
||||
flags = FLAG_FOUND;
|
||||
} else {
|
||||
int c2;
|
||||
@@ -1735,9 +1718,8 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
while (*p2 != ' ') p2++;
|
||||
|
||||
utf8_in(&c_word2, p2+1); // first character of the next word;
|
||||
if (!iswalpha2(c_word2)) {
|
||||
if (!iswalpha2(c_word2))
|
||||
ok = 0;
|
||||
}
|
||||
|
||||
if (ok != 0) {
|
||||
strcpy(ph_buf, word_phonemes);
|
||||
@@ -1748,9 +1730,8 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
|
||||
if (sylimit & 0x100) {
|
||||
// only if the second word has $alt attribute
|
||||
if ((flags2[0] & FLAG_ALT_TRANS) == 0) {
|
||||
if ((flags2[0] & FLAG_ALT_TRANS) == 0)
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((sylimit & 0x200) && ((wtab+1)->flags & FLAG_LAST_WORD)) {
|
||||
@@ -1758,9 +1739,8 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
ok = 0;
|
||||
}
|
||||
|
||||
if (ok == 0) {
|
||||
if (ok == 0)
|
||||
strcpy(word_phonemes, ph_buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
@@ -1900,9 +1880,8 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
if (ph_list2[n_ph_list2-1].phcode == phonSWITCH) {
|
||||
// previous phoneme is also a phonSWITCH, just change its phoneme table number
|
||||
n_ph_list2--;
|
||||
} else {
|
||||
} else
|
||||
SetPlist2(&ph_list2[n_ph_list2], phonSWITCH);
|
||||
}
|
||||
ph_list2[n_ph_list2++].tone_ph = switch_phonemes; // temporary phoneme table number
|
||||
}
|
||||
}
|
||||
@@ -1939,29 +1918,27 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
next_stress = ph->std_length;
|
||||
else {
|
||||
// for tone languages, the tone number for a syllable follows the vowel
|
||||
if (prev_vowel >= 0) {
|
||||
if (prev_vowel >= 0)
|
||||
ph_list2[prev_vowel].tone_ph = ph_code;
|
||||
} else {
|
||||
else
|
||||
next_tone = ph_code; // no previous vowel, apply to the next vowel
|
||||
}
|
||||
}
|
||||
} else if (ph_code == phonSYLLABIC) {
|
||||
// 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].stresslevel = next_stress;
|
||||
} else if (ph_code == phonLENGTHEN) {
|
||||
} else if (ph_code == phonLENGTHEN)
|
||||
ph_list2[n_ph_list2-1].synthflags |= SFLAG_LENGTHEN;
|
||||
} else if (ph_code == phonEND_WORD) {
|
||||
else if (ph_code == phonEND_WORD) {
|
||||
// a || symbol in a phoneme string was used to indicate a word boundary
|
||||
// Don't add this phoneme to the list, but make sure the next phoneme has
|
||||
// a newword indication
|
||||
srcix = source_ix+1;
|
||||
} else if (ph_code == phonX1) {
|
||||
// a language specific action
|
||||
if (tr->langopts.param[LOPT_IT_DOUBLING]) {
|
||||
if (tr->langopts.param[LOPT_IT_DOUBLING])
|
||||
flags |= FLAG_DOUBLING;
|
||||
}
|
||||
} else {
|
||||
ph_list2[n_ph_list2].phcode = ph_code;
|
||||
ph_list2[n_ph_list2].tone_ph = 0;
|
||||
@@ -1974,9 +1951,8 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
stress = next_stress;
|
||||
next_stress = 1; // default is 'unstressed'
|
||||
|
||||
if (stress >= 4) {
|
||||
if (stress >= 4)
|
||||
any_stressed_words = 1;
|
||||
}
|
||||
|
||||
if ((prev_vowel >= 0) && (n_ph_list2-1) != prev_vowel)
|
||||
ph_list2[n_ph_list2-1].stresslevel = stress; // set stress for previous consonant
|
||||
@@ -2009,19 +1985,16 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
}
|
||||
}
|
||||
|
||||
if (word_flags & FLAG_COMMA_AFTER) {
|
||||
if (word_flags & FLAG_COMMA_AFTER)
|
||||
SetPlist2(&ph_list2[n_ph_list2++], phonPAUSE_CLAUSE);
|
||||
}
|
||||
|
||||
// don't set new-word if there is a hyphen before it
|
||||
if ((word_flags & FLAG_HYPHEN) == 0) {
|
||||
if ((word_flags & FLAG_HYPHEN) == 0)
|
||||
plist2->sourceix = source_ix;
|
||||
}
|
||||
|
||||
tr->end_stressed_vowel = 0;
|
||||
if ((stress >= 4) && (phoneme_tab[ph_list2[n_ph_list2-1].phcode]->type == phVOWEL)) {
|
||||
if ((stress >= 4) && (phoneme_tab[ph_list2[n_ph_list2-1].phcode]->type == phVOWEL))
|
||||
tr->end_stressed_vowel = 1; // word ends with a stressed vowel
|
||||
}
|
||||
|
||||
if (switch_phonemes >= 0) {
|
||||
// this word uses a different phoneme table, now switch back
|
||||
@@ -2314,9 +2287,8 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
int tone;
|
||||
int tone2;
|
||||
|
||||
if (tr == NULL) {
|
||||
if (tr == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p_textinput = (unsigned char *)vp_input;
|
||||
p_wchar_input = (wchar_t *)vp_input;
|
||||
@@ -2358,9 +2330,8 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
}
|
||||
|
||||
for (p = source; *p != 0; p++) {
|
||||
if (!isspace2(*p)) {
|
||||
if (!isspace2(*p))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (*p == 0) {
|
||||
// No characters except spaces. This is not a sentence.
|
||||
@@ -2440,9 +2411,8 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
if (prev_in_save != 0) {
|
||||
prev_in = prev_in_save;
|
||||
prev_in_save = 0;
|
||||
} else if (source_index > 0) {
|
||||
} else if (source_index > 0)
|
||||
utf8_in2(&prev_in, &source[source_index-1], 1); // prev_in = source[source_index-1];
|
||||
}
|
||||
|
||||
prev_source_index = source_index;
|
||||
|
||||
@@ -2580,9 +2550,8 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
c = ' ';
|
||||
space_inserted = 1;
|
||||
|
||||
if (!IsBracket(prev_out)) { // ?? perhaps only set FLAG_NOSPACE for . - / (hyphenated words, URLs, etc)
|
||||
if (!IsBracket(prev_out)) // ?? perhaps only set FLAG_NOSPACE for . - / (hyphenated words, URLs, etc)
|
||||
next_word_flags |= FLAG_NOSPACE;
|
||||
}
|
||||
} else {
|
||||
if (iswupper2(c))
|
||||
word_flags |= FLAG_FIRST_UPPER;
|
||||
@@ -2705,16 +2674,15 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
if (((prev_in == '.') || iswalnum(prev_in)) && IsAlpha(next_in)) {
|
||||
// between two letters, or in an abbreviation (eg. u.s.a.'s). Consider the apostrophe as part of the word
|
||||
single_quoted = 0;
|
||||
} else if ((tr->langopts.param[LOPT_APOSTROPHE] & 1) && IsAlpha(next_in)) {
|
||||
} else if ((tr->langopts.param[LOPT_APOSTROPHE] & 1) && IsAlpha(next_in))
|
||||
single_quoted = 0; // apostrophe at start of word is part of the word
|
||||
} else if ((tr->langopts.param[LOPT_APOSTROPHE] & 2) && IsAlpha(prev_in)) {
|
||||
else if ((tr->langopts.param[LOPT_APOSTROPHE] & 2) && IsAlpha(prev_in))
|
||||
single_quoted = 0; // apostrophe at end of word is part of the word
|
||||
} else if ((wcschr(tr->char_plus_apostrophe, prev_in) != 0) && (prev_out2 == ' ')) {
|
||||
else if ((wcschr(tr->char_plus_apostrophe, prev_in) != 0) && (prev_out2 == ' ')) {
|
||||
// consider single character plus apostrophe as a word
|
||||
single_quoted = 0;
|
||||
if (next_in == ' ') {
|
||||
if (next_in == ' ')
|
||||
source_index++; // skip following space
|
||||
}
|
||||
} else {
|
||||
if ((prev_out == 's') && (single_quoted == 0)) {
|
||||
// looks like apostrophe after an 's'
|
||||
@@ -2729,17 +2697,16 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
c = ' ';
|
||||
}
|
||||
}
|
||||
} else if (lookupwchar(breaks, c) != 0) {
|
||||
} else if (lookupwchar(breaks, c) != 0)
|
||||
c = ' '; // various characters to treat as space
|
||||
} else if (iswdigit(c)) {
|
||||
else if (iswdigit(c)) {
|
||||
if (tr->langopts.tone_numbers && IsAlpha(prev_out) && !IsDigit(next_in)) {
|
||||
} else if ((prev_out != ' ') && !iswdigit(prev_out)) {
|
||||
if ((prev_out != tr->langopts.decimal_sep) || ((decimal_sep_count > 0) && (tr->langopts.decimal_sep == ','))) {
|
||||
c = ' ';
|
||||
space_inserted = 1;
|
||||
} else {
|
||||
} else
|
||||
decimal_sep_count = 1;
|
||||
}
|
||||
} else if ((prev_out == ' ') && IsAlpha(prev_out2) && !IsAlpha(prev_in)) {
|
||||
// insert extra space between a word and a number, to distinguish 'a 2' from 'a2'
|
||||
sbuf[ix++] = ' ';
|
||||
@@ -2754,9 +2721,8 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
continue; // multiple spaces
|
||||
}
|
||||
|
||||
if ((cc == 0x09) || (cc == 0x0a)) {
|
||||
if ((cc == 0x09) || (cc == 0x0a))
|
||||
next_word_flags |= FLAG_MULTIPLE_SPACES; // tab or newline, not a simple space
|
||||
}
|
||||
|
||||
if (space_inserted) {
|
||||
// count the number of characters since the start of the word
|
||||
@@ -2788,9 +2754,8 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
|
||||
if (pre_pause > 0) {
|
||||
// insert an extra space before the word, to prevent influence from previous word across the pause
|
||||
for (j = ix; j > words[word_count].start; j--) {
|
||||
for (j = ix; j > words[word_count].start; j--)
|
||||
sbuf[j] = sbuf[j-1];
|
||||
}
|
||||
sbuf[j] = ' ';
|
||||
words[word_count].start++;
|
||||
ix++;
|
||||
@@ -2884,9 +2849,9 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
// Languages with 100000 numbers. Remove thousands separators so that we can insert them again later
|
||||
pn = number_buf;
|
||||
while (pn < &number_buf[sizeof(number_buf)-20]) {
|
||||
if (iswdigit(*pw)) {
|
||||
if (iswdigit(*pw))
|
||||
*pn++ = *pw++;
|
||||
} else if ((*pw == tr->langopts.thousands_sep) && (pw[1] == ' ')
|
||||
else if ((*pw == tr->langopts.thousands_sep) && (pw[1] == ' ')
|
||||
&& iswdigit(pw[2]) && (pw[3] != ' ') && (pw[4] != ' ')) { // don't allow only 1 or 2 digits in the final part
|
||||
pw += 2;
|
||||
ix++; // skip "word"
|
||||
@@ -2922,9 +2887,8 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
if ((nx > 0) && (tr->langopts.break_numbers & (1 << nx))) {
|
||||
memcpy(&num_wtab[nw++], &words[ix], sizeof(WORD_TAB)); // copy the 'words' entry for each word of numbers
|
||||
|
||||
if (tr->langopts.thousands_sep != ' ') {
|
||||
if (tr->langopts.thousands_sep != ' ')
|
||||
*pn++ = tr->langopts.thousands_sep;
|
||||
}
|
||||
*pn++ = ' ';
|
||||
|
||||
if ((words[ix].flags & FLAG_INDIVIDUAL_DIGITS) == 0) {
|
||||
@@ -2943,9 +2907,8 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
pw--;
|
||||
memcpy(&num_wtab[nw], &words[ix], sizeof(WORD_TAB)*2); // the original number word, and the word after it
|
||||
|
||||
for (j = 1; j <= nw; j++) {
|
||||
for (j = 1; j <= nw; j++)
|
||||
num_wtab[j].flags &= ~(FLAG_MULTIPLE_SPACES | FLAG_EMBEDDED); // don't use these flags for subsequent parts when splitting a number
|
||||
}
|
||||
|
||||
// include the next few characters, in case there are an ordinal indicator or other suffix
|
||||
memcpy(pn, pw, 16);
|
||||
@@ -3011,12 +2974,10 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
}
|
||||
n_ph_list2 += 2;
|
||||
|
||||
if (count_words == 0) {
|
||||
if (count_words == 0)
|
||||
clause_pause = 0;
|
||||
}
|
||||
if (Eof() && ((word_count == 0) || (option_endpause == 0))) {
|
||||
if (Eof() && ((word_count == 0) || (option_endpause == 0)))
|
||||
clause_pause = 10;
|
||||
}
|
||||
|
||||
MakePhonemeList(tr, clause_pause, new_sentence2);
|
||||
phoneme_list[N_PHONEME_LIST].ph = NULL; // recognize end of phoneme_list array, in Generate()
|
||||
@@ -3035,9 +2996,8 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
*tone_out = tone;
|
||||
|
||||
new_sentence = 0;
|
||||
if (terminator & CLAUSE_BIT_SENTENCE) {
|
||||
if (terminator & CLAUSE_BIT_SENTENCE)
|
||||
new_sentence = 1; // next clause is a new sentence
|
||||
}
|
||||
|
||||
|
||||
if (voice_change != NULL) {
|
||||
@@ -3083,7 +3043,6 @@ void InitText(int control)
|
||||
|
||||
InitText2();
|
||||
|
||||
if ((control & espeakKEEP_NAMEDATA) == 0) {
|
||||
if ((control & espeakKEEP_NAMEDATA) == 0)
|
||||
InitNamedata();
|
||||
}
|
||||
}
|
||||
|
||||
+40
-66
@@ -342,19 +342,17 @@ static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname, const char *le
|
||||
langix += len;
|
||||
n_languages++;
|
||||
}
|
||||
} else if (memcmp(linebuf, "gender", 6) == 0) {
|
||||
} else if (memcmp(linebuf, "gender", 6) == 0)
|
||||
sscanf(&linebuf[6], "%s %d", vgender, &age);
|
||||
} else if (memcmp(linebuf, "variants", 8) == 0) {
|
||||
else if (memcmp(linebuf, "variants", 8) == 0)
|
||||
sscanf(&linebuf[8], "%d", &n_variants);
|
||||
}
|
||||
}
|
||||
languages[langix++] = 0;
|
||||
|
||||
gender = LookupMnem(genders, vgender);
|
||||
|
||||
if (n_languages == 0) {
|
||||
if (n_languages == 0)
|
||||
return NULL; // no language lines in the voice file
|
||||
}
|
||||
|
||||
p = (char *)calloc(sizeof(espeak_VOICE) + langix + strlen(fname) + strlen(vname) + 3, 1);
|
||||
voice_data = (espeak_VOICE *)p;
|
||||
@@ -521,9 +519,8 @@ static unsigned int StringToWord2(const char *string)
|
||||
int c;
|
||||
unsigned int value = 0;
|
||||
|
||||
for (ix = 0; (ix < 4) && ((c = string[ix]) != 0); ix++) {
|
||||
for (ix = 0; (ix < 4) && ((c = string[ix]) != 0); ix++)
|
||||
value = (value << 8) | (c & 0xff);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -601,9 +598,9 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
|
||||
if (GetFileLength(buf) <= 0) {
|
||||
// then look in the appropriate subdirectory
|
||||
if ((voicename[0] == 'm') && (voicename[1] == 'b')) {
|
||||
if ((voicename[0] == 'm') && (voicename[1] == 'b'))
|
||||
voice_dir = "mb"; // mbrola voices
|
||||
} else {
|
||||
else {
|
||||
sprintf(name2, "%s ", voicename);
|
||||
if (strstr(voices_europe, voicename) != NULL)
|
||||
voice_dir = "europe";
|
||||
@@ -864,9 +861,8 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
((sscanf(p, "%d %d %d", &ix, &value, &value2) >= 2) && (ix < N_LOPTS))) {
|
||||
langopts->param[ix] = value;
|
||||
langopts->param2[ix] = value2;
|
||||
} else {
|
||||
} else
|
||||
fprintf(stderr, "Bad voice option: %s %s\n", buf, p);
|
||||
}
|
||||
break;
|
||||
|
||||
case V_ECHO:
|
||||
@@ -963,34 +959,31 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
name1[0] = name2[0] = 0;
|
||||
sscanf(p, "%s %s", name1, name2);
|
||||
|
||||
if (strcmp(name1, "latin") == 0) {
|
||||
if (strcmp(name1, "latin") == 0)
|
||||
strncpy0(langopts->ascii_language, name2, sizeof(langopts->ascii_language));
|
||||
} else if ((alphabet = AlphabetFromName(name1)) != 0) {
|
||||
else if ((alphabet = AlphabetFromName(name1)) != 0) {
|
||||
langopts->alt_alphabet = alphabet->offset;
|
||||
langopts->alt_alphabet_lang = StringToWord2(name2);
|
||||
} else {
|
||||
} else
|
||||
fprintf(stderr, "alphabet name '%s' not found\n", name1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case V_DICTDIALECT:
|
||||
// specify a dialect to use for foreign words, eg, en-us for _^_EN
|
||||
if (sscanf(p, "%s", name1) == 1) {
|
||||
if ((ix = LookupMnem(dict_dialects, name1)) > 0) {
|
||||
if ((ix = LookupMnem(dict_dialects, name1)) > 0)
|
||||
langopts->dict_dialect |= (1 << ix);
|
||||
} else {
|
||||
else
|
||||
fprintf(stderr, "dictdialect name '%s' not recognized\n", name1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if ((key & 0xff00) == 0x100) {
|
||||
if ((key & 0xff00) == 0x100)
|
||||
sscanf(p, "%d", &langopts->param[key &0xff]);
|
||||
} else {
|
||||
else
|
||||
fprintf(stderr, "Bad voice attribute: %s\n", buf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1010,9 +1003,9 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
voice->width2[ix] = voice->width[ix];
|
||||
}
|
||||
|
||||
if (tone_only) {
|
||||
if (tone_only)
|
||||
new_translator = translator;
|
||||
} else {
|
||||
else {
|
||||
if ((ix = SelectPhonemeTableName(phonemes_name)) < 0) {
|
||||
fprintf(stderr, "Unknown phoneme table: '%s'\n", phonemes_name);
|
||||
ix = 0;
|
||||
@@ -1034,24 +1027,20 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
langopts = &new_translator->langopts;
|
||||
|
||||
|
||||
if ((value = langopts->param[LOPT_LENGTH_MODS]) != 0) {
|
||||
if ((value = langopts->param[LOPT_LENGTH_MODS]) != 0)
|
||||
SetLengthMods(new_translator, value);
|
||||
}
|
||||
|
||||
voice->width[0] = (voice->width[0] * 105)/100;
|
||||
|
||||
if (!tone_only) {
|
||||
if (!tone_only)
|
||||
translator = new_translator;
|
||||
}
|
||||
|
||||
|
||||
// relative lengths of different stress syllables
|
||||
for (ix = 0; ix < stress_lengths_set; ix++) {
|
||||
for (ix = 0; ix < stress_lengths_set; ix++)
|
||||
translator->stress_lengths[ix] = stress_lengths[ix];
|
||||
}
|
||||
for (ix = 0; ix < stress_add_set; ix++) {
|
||||
for (ix = 0; ix < stress_add_set; ix++)
|
||||
translator->stress_lengths[ix] += stress_add[ix];
|
||||
}
|
||||
for (ix = 0; ix < stress_amps_set; ix++) {
|
||||
translator->stress_amps[ix] = stress_amps[ix];
|
||||
translator->stress_amps_r[ix] = stress_amps[ix] -1;
|
||||
@@ -1080,9 +1069,9 @@ static char *ExtractVoiceVariantName(char *vname, int variant_num, int add_dir)
|
||||
// The voice name has a +variant suffix
|
||||
variant_num = 0;
|
||||
*p++ = 0; // delete the suffix from the voice name
|
||||
if (IsDigit09(*p)) {
|
||||
if (IsDigit09(*p))
|
||||
variant_num = atoi(p); // variant number
|
||||
} else {
|
||||
else {
|
||||
// voice variant name, not number
|
||||
sprintf(variant_name, "%s%s", variant_prefix, p);
|
||||
}
|
||||
@@ -1116,9 +1105,8 @@ voice_t *LoadVoiceVariant(const char *vname, int variant_num)
|
||||
if ((v = LoadVoice(buf, 0)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (variant_name[0] != 0) {
|
||||
if (variant_name[0] != 0)
|
||||
v = LoadVoice(variant_name, 2);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -1175,9 +1163,9 @@ static int ScoreVoice(espeak_VOICE *voice_spec, const char *spec_language, int s
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (spec_n_parts == 0) {
|
||||
if (spec_n_parts == 0)
|
||||
score = 100;
|
||||
} else {
|
||||
else {
|
||||
if ((*p == 0) && (strcmp(spec_language, "variants") == 0)) {
|
||||
// match on a voice with no languages if the required language is "variants"
|
||||
score = 100;
|
||||
@@ -1197,9 +1185,8 @@ static int ScoreVoice(espeak_VOICE *voice_spec, const char *spec_language, int s
|
||||
if ((c2 = p[ix]) == '-')
|
||||
c2 = 0;
|
||||
|
||||
if (c1 != c2) {
|
||||
if (c1 != c2)
|
||||
matching = 0;
|
||||
}
|
||||
|
||||
if (p[ix] == '-') {
|
||||
n_parts++;
|
||||
@@ -1237,9 +1224,8 @@ static int ScoreVoice(espeak_VOICE *voice_spec, const char *spec_language, int s
|
||||
if (strcmp(voice_spec->name, voice->name) == 0) {
|
||||
// match on voice name
|
||||
score += 500;
|
||||
} else if (strcmp(voice_spec->name, voice->identifier) == 0) {
|
||||
} else if (strcmp(voice_spec->name, voice->identifier) == 0)
|
||||
score += 400;
|
||||
}
|
||||
}
|
||||
|
||||
if (((voice_spec->gender == 1) || (voice_spec->gender == 2)) &&
|
||||
@@ -1250,9 +1236,8 @@ static int ScoreVoice(espeak_VOICE *voice_spec, const char *spec_language, int s
|
||||
score -= 50;
|
||||
}
|
||||
|
||||
if ((voice_spec->age <= 12) && (voice->gender == 2) && (voice->age > 12)) {
|
||||
if ((voice_spec->age <= 12) && (voice->gender == 2) && (voice->age > 12))
|
||||
score += 5; // give some preference for non-child female voice if a child is requested
|
||||
}
|
||||
|
||||
if (voice->age != 0) {
|
||||
if (voice_spec->age == 0)
|
||||
@@ -1376,11 +1361,10 @@ espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name2)
|
||||
break;
|
||||
} else {
|
||||
id = voices[ix]->identifier;
|
||||
if (strcmp(name, id) == 0) {
|
||||
if (strcmp(name, id) == 0)
|
||||
match_fname = ix; // matching identifier, use this if no matching name
|
||||
} else if (strcmp(last_part, &id[strlen(id)-last_part_len]) == 0) {
|
||||
else if (strcmp(last_part, &id[strlen(id)-last_part_len]) == 0)
|
||||
match_fname2 = ix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1485,16 +1469,13 @@ char const *SelectVoice(espeak_VOICE *voice_select, int *found)
|
||||
// is the main voice the required gender?
|
||||
skip = 0;
|
||||
|
||||
if ((gender != 0) && (vp->gender != gender)) {
|
||||
if ((gender != 0) && (vp->gender != gender))
|
||||
skip = 1;
|
||||
}
|
||||
if ((ix2 == 0) && aged && (vp->age < AGE_OLD)) {
|
||||
if ((ix2 == 0) && aged && (vp->age < AGE_OLD))
|
||||
skip = 1;
|
||||
}
|
||||
|
||||
if (skip == 0) {
|
||||
if (skip == 0)
|
||||
voices2[ix2++] = vp;
|
||||
}
|
||||
|
||||
for (j = 0; (j < vp->xx1) && (n_variants < N_VOICE_VARIANTS);) {
|
||||
if ((variant_number = *p) == 0) {
|
||||
@@ -1560,9 +1541,8 @@ static void GetVoices(const char *path)
|
||||
|
||||
while (regs.r[3] > 0) {
|
||||
error = _kernel_swi(0x0c+0x20000, ®s, ®s); /* OS_GBPB 10, read directory entries */
|
||||
if ((error != NULL) || (regs.r[3] == 0)) {
|
||||
if ((error != NULL) || (regs.r[3] == 0))
|
||||
break;
|
||||
}
|
||||
type = (int *)(&buf[16]);
|
||||
len = strlen(&buf[20]);
|
||||
sprintf(fname, "%s.%s", path, &buf[20]);
|
||||
@@ -1579,9 +1559,8 @@ static void GetVoices(const char *path)
|
||||
voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, &buf[20]);
|
||||
fclose(f_voice);
|
||||
|
||||
if (voice_data != NULL) {
|
||||
if (voice_data != NULL)
|
||||
voices_list[n_voices_list++] = voice_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -1615,9 +1594,8 @@ static void GetVoices(const char *path)
|
||||
voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, FindFileData.cFileName);
|
||||
fclose(f_voice);
|
||||
|
||||
if (voice_data != NULL) {
|
||||
if (voice_data != NULL)
|
||||
voices_list[n_voices_list++] = voice_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (FindNextFileA(hFind, &FindFileData) != 0);
|
||||
@@ -1653,9 +1631,8 @@ static void GetVoices(const char *path)
|
||||
voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, ent->d_name);
|
||||
fclose(f_voice);
|
||||
|
||||
if (voice_data != NULL) {
|
||||
if (voice_data != NULL)
|
||||
voices_list[n_voices_list++] = voice_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
@@ -1690,9 +1667,8 @@ espeak_ERROR SetVoiceByName(const char *name)
|
||||
// This may avoid the need to call espeak_ListVoices().
|
||||
|
||||
if (LoadVoice(buf, 1) != NULL) {
|
||||
if (variant_name[0] != 0) {
|
||||
if (variant_name[0] != 0)
|
||||
LoadVoice(variant_name, 2);
|
||||
}
|
||||
|
||||
DoVoiceChange(voice);
|
||||
voice_selector.languages = voice->language_name;
|
||||
@@ -1705,9 +1681,8 @@ espeak_ERROR SetVoiceByName(const char *name)
|
||||
|
||||
if ((v = SelectVoiceByName(voices_list, buf)) != NULL) {
|
||||
if (LoadVoice(v->identifier, 0) != NULL) {
|
||||
if (variant_name[0] != 0) {
|
||||
if (variant_name[0] != 0)
|
||||
LoadVoice(variant_name, 2);
|
||||
}
|
||||
DoVoiceChange(voice);
|
||||
voice_selector.languages = voice->language_name;
|
||||
SetVoiceStack(&voice_selector, variant_name);
|
||||
@@ -1796,9 +1771,8 @@ ESPEAK_API const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec)
|
||||
j = 0;
|
||||
for (ix = 0; (v = voices_list[ix]) != NULL; ix++) {
|
||||
if ((v->languages[0] != 0) && (strcmp(&v->languages[1], "variant") != 0)
|
||||
&& (memcmp(v->identifier, "mb/", 3) != 0) && (memcmp(v->identifier, "test/", 5) != 0)) {
|
||||
&& (memcmp(v->identifier, "mb/", 3) != 0) && (memcmp(v->identifier, "test/", 5) != 0))
|
||||
voices[j++] = v;
|
||||
}
|
||||
}
|
||||
voices[j] = NULL;
|
||||
}
|
||||
|
||||
+37
-53
@@ -262,11 +262,10 @@ static unsigned int get_used_mem()
|
||||
&& (aWrite >= myBuffer)
|
||||
&& (aWrite <= myBuffer + BUFFER_LENGTH));
|
||||
|
||||
if (aRead < aWrite) {
|
||||
if (aRead < aWrite)
|
||||
used = aWrite - aRead;
|
||||
} else {
|
||||
else
|
||||
used = aWrite + BUFFER_LENGTH - aRead;
|
||||
}
|
||||
SHOW("get_used_mem > %d\n", used);
|
||||
|
||||
return used;
|
||||
@@ -333,7 +332,7 @@ static int pa_callback(const void *inputBuffer, void *outputBuffer,
|
||||
memset(p, 0, n - aUsedMem);
|
||||
myRead = aWrite;
|
||||
}
|
||||
} else { // myRead > aWrite
|
||||
} else {
|
||||
if ((size_t)(myBuffer + BUFFER_LENGTH - myRead) >= n) {
|
||||
memcpy(outputBuffer, myRead, n);
|
||||
myRead += n;
|
||||
@@ -376,19 +375,17 @@ static int pa_callback(const void *inputBuffer, void *outputBuffer,
|
||||
SHOW("pa_callback > myRead=%x\n", (int)myRead);
|
||||
|
||||
#ifdef ARCH_BIG
|
||||
{
|
||||
// BIG-ENDIAN, swap the order of bytes in each sound sample in the portaudio buffer
|
||||
int c;
|
||||
unsigned char *out_ptr;
|
||||
unsigned char *out_end;
|
||||
out_ptr = (unsigned char *)outputBuffer;
|
||||
out_end = out_ptr + framesPerBuffer*2 * out_channels;
|
||||
while (out_ptr < out_end) {
|
||||
c = out_ptr[0];
|
||||
out_ptr[0] = out_ptr[1];
|
||||
out_ptr[1] = c;
|
||||
out_ptr += 2;
|
||||
}
|
||||
// BIG-ENDIAN, swap the order of bytes in each sound sample in the portaudio buffer
|
||||
int c;
|
||||
unsigned char *out_ptr;
|
||||
unsigned char *out_end;
|
||||
out_ptr = (unsigned char *)outputBuffer;
|
||||
out_end = out_ptr + framesPerBuffer*2 * out_channels;
|
||||
while (out_ptr < out_end) {
|
||||
c = out_ptr[0];
|
||||
out_ptr[0] = out_ptr[1];
|
||||
out_ptr[1] = c;
|
||||
out_ptr += 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -400,9 +397,8 @@ void wave_flush(void *theHandler)
|
||||
{
|
||||
ENTER("wave_flush");
|
||||
|
||||
if (my_stream_could_start) {
|
||||
if (my_stream_could_start)
|
||||
start_stream();
|
||||
}
|
||||
}
|
||||
|
||||
static int wave_open_sound()
|
||||
@@ -418,10 +414,9 @@ static int wave_open_sound()
|
||||
active = Pa_IsStreamActive(pa_stream);
|
||||
#endif
|
||||
|
||||
if (active == 1) {
|
||||
if (active == 1)
|
||||
SHOW_TIME("wave_open_sound > already active");
|
||||
return 0;
|
||||
}
|
||||
if (active < 0) {
|
||||
out_channels = 1;
|
||||
|
||||
@@ -574,9 +569,8 @@ static void select_device(const char *the_api)
|
||||
for (i = 0; i < numDevices; i++) {
|
||||
deviceInfo = Pa_GetDeviceInfo(i);
|
||||
|
||||
if (deviceInfo == NULL) {
|
||||
if (deviceInfo == NULL)
|
||||
break;
|
||||
}
|
||||
const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
|
||||
|
||||
if (hostInfo && hostInfo->type == paALSA) {
|
||||
@@ -612,9 +606,9 @@ static void select_device(const char *the_api)
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedDeviceInfo) {
|
||||
if (selectedDeviceInfo)
|
||||
update_output_parameters(selectedIndex, selectedDeviceInfo);
|
||||
} else {
|
||||
else {
|
||||
i = Pa_GetDefaultOutputDevice();
|
||||
deviceInfo = Pa_GetDeviceInfo(i);
|
||||
update_output_parameters(i, deviceInfo);
|
||||
@@ -641,9 +635,8 @@ int wave_init(int srate)
|
||||
// PortAudio sound output library
|
||||
err = Pa_Initialize();
|
||||
pa_init_err = err;
|
||||
if (err != paNoError) {
|
||||
if (err != paNoError)
|
||||
SHOW_TIME("wave_init > Failed to initialise the PortAudio sound");
|
||||
}
|
||||
return err == paNoError;
|
||||
}
|
||||
|
||||
@@ -683,8 +676,8 @@ static size_t copyBuffer(char *dest, char *src, const size_t theSizeInBytes)
|
||||
a_dest[2*i+1] = a_src[i];
|
||||
}
|
||||
bytes_written = 2*theSizeInBytes;
|
||||
} // end if(out_channels==1)
|
||||
} // end if ((src != NULL) && dest != NULL)
|
||||
}
|
||||
}
|
||||
|
||||
return bytes_written;
|
||||
}
|
||||
@@ -704,14 +697,12 @@ size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSiz
|
||||
return 0;
|
||||
}
|
||||
my_stream_could_start = 1;
|
||||
} else if (!wave_is_busy(NULL)) {
|
||||
} else if (!wave_is_busy(NULL))
|
||||
my_stream_could_start = 1;
|
||||
}
|
||||
assert(BUFFER_LENGTH >= bytes_to_write);
|
||||
|
||||
if (myWrite >= myBuffer + BUFFER_LENGTH) {
|
||||
if (myWrite >= myBuffer + BUFFER_LENGTH)
|
||||
myWrite = myBuffer;
|
||||
} // end if (myWrite >= myBuffer + BUFFER_LENGTH)
|
||||
|
||||
size_t aTotalFreeMem = 0;
|
||||
char *aRead = myRead;
|
||||
@@ -726,26 +717,24 @@ size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSiz
|
||||
aRead = myRead;
|
||||
|
||||
// write pointer is before read pointer?
|
||||
if (myWrite >= aRead) {
|
||||
if (myWrite >= aRead)
|
||||
aTotalFreeMem = aRead + BUFFER_LENGTH - myWrite;
|
||||
} else { // read pointer is before write pointer!
|
||||
else // read pointer is before write pointer!
|
||||
aTotalFreeMem = aRead - myWrite;
|
||||
} // end if (myWrite >= aRead)
|
||||
|
||||
if (aTotalFreeMem > 1) {
|
||||
// -1 because myWrite must be different of aRead
|
||||
// otherwise buffer would be considered as empty
|
||||
aTotalFreeMem -= 1;
|
||||
} // end if (aTotalFreeMem>1)
|
||||
}
|
||||
|
||||
if (aTotalFreeMem >= bytes_to_write) {
|
||||
if (aTotalFreeMem >= bytes_to_write)
|
||||
break;
|
||||
} // end if (aTotalFreeMem >= bytes_to_write)
|
||||
|
||||
SHOW("wave_write > wait: aTotalFreeMem=%d\n", aTotalFreeMem);
|
||||
SHOW("wave_write > aRead=%x, myWrite=%x\n", (int)aRead, (int)myWrite);
|
||||
usleep(10000);
|
||||
} // end while (1)
|
||||
}
|
||||
|
||||
aRead = myRead;
|
||||
|
||||
@@ -770,20 +759,18 @@ size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSiz
|
||||
copyBuffer(myWrite, theMono16BitsWaveBuffer, aFreeMem);
|
||||
myWrite = myBuffer;
|
||||
myWrite += copyBuffer(myWrite, theMono16BitsWaveBuffer+aFreeMem, theSize - aFreeMem);
|
||||
} // end if (out_channels == 2)
|
||||
} // end if (aFreeMem >= bytes_to_write)
|
||||
} // if (myWrite >= aRead)
|
||||
else { // read pointer is ahead the write pointer
|
||||
}
|
||||
}
|
||||
} else { // read pointer is ahead the write pointer
|
||||
SHOW_TIME("wave_write > myWrite <= aRead");
|
||||
myWrite += copyBuffer(myWrite, theMono16BitsWaveBuffer, theSize);
|
||||
} // end if (myWrite >= aRead)
|
||||
}
|
||||
|
||||
bytes_written = bytes_to_write;
|
||||
myWritePosition += theSize/sizeof(uint16_t); // add number of samples
|
||||
|
||||
if (my_stream_could_start && (get_used_mem() >= out_channels * sizeof(uint16_t) * FRAMES_PER_BUFFER)) {
|
||||
if (my_stream_could_start && (get_used_mem() >= out_channels * sizeof(uint16_t) * FRAMES_PER_BUFFER))
|
||||
start_stream();
|
||||
} // end if (my_stream_could_start && (get_used_mem() >= out_channels * sizeof(uint16_t) * FRAMES_PER_BUFFER))
|
||||
|
||||
SHOW_TIME("wave_write > LEAVE");
|
||||
|
||||
@@ -942,9 +929,8 @@ int wave_get_remaining_time(uint32_t sample, uint32_t *time)
|
||||
// TBD: take in account time suplied by portaudio V18 API
|
||||
a_time = sample - myReadPosition;
|
||||
a_time = 0.5 + (a_time * 1000.0) / wave_samplerate;
|
||||
} else {
|
||||
} else
|
||||
a_time = 0;
|
||||
}
|
||||
|
||||
SHOW("wave_get_remaining_time > sample=%d, time=%d\n", sample, (uint32_t)a_time);
|
||||
|
||||
@@ -1007,9 +993,8 @@ void clock_gettime2(struct timespec *ts)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
if (!ts) {
|
||||
if (!ts)
|
||||
return;
|
||||
}
|
||||
|
||||
assert(gettimeofday(&tv, NULL) != -1);
|
||||
ts->tv_sec = tv.tv_sec;
|
||||
@@ -1018,9 +1003,8 @@ void clock_gettime2(struct timespec *ts)
|
||||
|
||||
void add_time_in_ms(struct timespec *ts, int time_in_ms)
|
||||
{
|
||||
if (!ts) {
|
||||
if (!ts)
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t t_ns = (uint64_t)ts->tv_nsec + 1000000 * (uint64_t)time_in_ms;
|
||||
while (t_ns >= ONE_BILLION) {
|
||||
|
||||
@@ -290,9 +290,8 @@ static int pulse_playing(const pa_timing_info *the_timing_info) {
|
||||
for (;;) {
|
||||
CHECK_DEAD_GOTO(fail, 1);
|
||||
|
||||
if ((i = pa_stream_get_timing_info(stream))) {
|
||||
if ((i = pa_stream_get_timing_info(stream)))
|
||||
break;
|
||||
}
|
||||
if (pa_context_errno(context) != PA_ERR_NODATA) {
|
||||
SHOW("pa_stream_get_timing_info() failed: %s", pa_strerror(pa_context_errno(context)));
|
||||
goto fail;
|
||||
@@ -359,11 +358,10 @@ static int drain(void) {
|
||||
}
|
||||
SHOW_TIME("pa_threaded_mainloop_wait (ret)");
|
||||
|
||||
if (!success) {
|
||||
if (!success)
|
||||
SHOW("pa_stream_drain() failed: %s\n", pa_strerror(pa_context_errno(context)));
|
||||
} else {
|
||||
else
|
||||
ret = PULSE_OK;
|
||||
}
|
||||
|
||||
fail:
|
||||
SHOW_TIME("pa_operation_unref (call)");
|
||||
@@ -558,9 +556,8 @@ fail:
|
||||
pa_threaded_mainloop_free(mainloop);
|
||||
mainloop = NULL;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
pulse_close();
|
||||
}
|
||||
|
||||
SHOW_TIME("pulse_open (ret false)");
|
||||
|
||||
@@ -621,9 +618,8 @@ size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSiz
|
||||
}
|
||||
|
||||
// TBD: check if really helpful
|
||||
if (aTotalFreeMem >= MAXLENGTH*2) {
|
||||
if (aTotalFreeMem >= MAXLENGTH*2)
|
||||
aTotalFreeMem = MAXLENGTH*2;
|
||||
}
|
||||
|
||||
SHOW("wave_write > wait: aTotalFreeMem(%d) < bytes_to_write(%d)\n", aTotalFreeMem, bytes_to_write);
|
||||
|
||||
@@ -799,9 +795,8 @@ void clock_gettime2(struct timespec *ts)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
if (!ts) {
|
||||
if (!ts)
|
||||
return;
|
||||
}
|
||||
|
||||
assert(gettimeofday(&tv, NULL) != -1);
|
||||
ts->tv_sec = tv.tv_sec;
|
||||
@@ -810,9 +805,8 @@ void clock_gettime2(struct timespec *ts)
|
||||
|
||||
void add_time_in_ms(struct timespec *ts, int time_in_ms)
|
||||
{
|
||||
if (!ts) {
|
||||
if (!ts)
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t t_ns = (uint64_t)ts->tv_nsec + 1000000 * (uint64_t)time_in_ms;
|
||||
while (t_ns >= ONE_BILLION) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2008, Sun Microsystems, Inc.
|
||||
* Copyright (C) 2015 Reece H. Dunn
|
||||
* eSpeak driver for Solaris Audio Device Architecture (SADA)
|
||||
* Written by Willie Walker, based on the eSpeak PulseAudio driver
|
||||
* from Gilles Casse
|
||||
@@ -99,9 +100,8 @@ int wave_init(int srate) {
|
||||
|
||||
SHOW("wave_init() sun_audio_fd: %d\n", sun_audio_fd);
|
||||
|
||||
if (sun_audio_fd < 0) {
|
||||
if (sun_audio_fd < 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ioctl(sun_audio_fd, AUDIO_GETINFO, &ainfo);
|
||||
SHOW("wave_init() play buffer size: %d\n", ainfo.play.buffer_size);
|
||||
@@ -184,19 +184,17 @@ size_t wave_write(void *theHandler,
|
||||
}
|
||||
|
||||
#if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
|
||||
{
|
||||
// BIG-ENDIAN, swap the order of bytes in each sound sample
|
||||
int c;
|
||||
char *out_ptr;
|
||||
char *out_end;
|
||||
out_ptr = (char *)theMono16BitsWaveBuffer;
|
||||
out_end = out_ptr + theSize;
|
||||
while (out_ptr < out_end) {
|
||||
c = out_ptr[0];
|
||||
out_ptr[0] = out_ptr[1];
|
||||
out_ptr[1] = c;
|
||||
out_ptr += 2;
|
||||
}
|
||||
// BIG-ENDIAN, swap the order of bytes in each sound sample
|
||||
int c;
|
||||
char *out_ptr;
|
||||
char *out_end;
|
||||
out_ptr = (char *)theMono16BitsWaveBuffer;
|
||||
out_end = out_ptr + theSize;
|
||||
while (out_ptr < out_end) {
|
||||
c = out_ptr[0];
|
||||
out_ptr[0] = out_ptr[1];
|
||||
out_ptr[1] = c;
|
||||
out_ptr += 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -208,11 +206,10 @@ size_t wave_write(void *theHandler,
|
||||
//
|
||||
total_samples_sent += num / 2;
|
||||
|
||||
if (num < theSize) {
|
||||
if (num < theSize)
|
||||
SHOW("ERROR: wave_write only wrote %d of %d bytes\n", num, theSize);
|
||||
} else {
|
||||
else
|
||||
SHOW("wave_write wrote %d bytes\n", theSize);
|
||||
}
|
||||
|
||||
SHOW_TIME("wave_write > LEAVE");
|
||||
return num;
|
||||
@@ -293,11 +290,10 @@ int wave_close(void *theHandler)
|
||||
int wave_is_busy(void *theHandler)
|
||||
{
|
||||
uint32_t time;
|
||||
if (total_samples_sent >= 1) {
|
||||
if (total_samples_sent >= 1)
|
||||
wave_get_remaining_time(total_samples_sent - 1, &time);
|
||||
} else {
|
||||
else
|
||||
time = 0;
|
||||
}
|
||||
return time != 0;
|
||||
}
|
||||
|
||||
@@ -540,9 +536,8 @@ void clock_gettime2(struct timespec *ts)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
if (!ts) {
|
||||
if (!ts)
|
||||
return;
|
||||
}
|
||||
|
||||
assert(gettimeofday(&tv, NULL) != -1);
|
||||
ts->tv_sec = tv.tv_sec;
|
||||
@@ -551,9 +546,8 @@ void clock_gettime2(struct timespec *ts)
|
||||
|
||||
void add_time_in_ms(struct timespec *ts, int time_in_ms)
|
||||
{
|
||||
if (!ts) {
|
||||
if (!ts)
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t t_ns = (uint64_t)ts->tv_nsec + 1000000 * (uint64_t)time_in_ms;
|
||||
while (t_ns >= ONE_BILLION) {
|
||||
|
||||
+30
-51
@@ -609,9 +609,8 @@ int WavegenCloseSound()
|
||||
pa_stream = NULL;
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
WavegenOpenSound(); // still items in the queue, shouldn't be closed
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -804,27 +803,23 @@ int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control)
|
||||
h = ((p->freq - p->left) / pitch) + 1;
|
||||
if (h <= 0) h = 1;
|
||||
|
||||
for (f = pitch*h; f < fp; f += pitch) {
|
||||
for (f = pitch*h; f < fp; f += pitch)
|
||||
htab[h++] += pk_shape[(fp-f)/(p->left>>8)] * p->height;
|
||||
}
|
||||
for (; f < fhi; f += pitch) {
|
||||
for (; f < fhi; f += pitch)
|
||||
htab[h++] += pk_shape[(f-fp)/(p->right>>8)] * p->height;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int y;
|
||||
int h2;
|
||||
// increase bass
|
||||
y = peaks[1].height * 10; // addition as a multiple of 1/256s
|
||||
h2 = (1000<<16)/pitch; // decrease until 1000Hz
|
||||
if (h2 > 0) {
|
||||
x = y/h2;
|
||||
h = 1;
|
||||
while (y > 0) {
|
||||
htab[h++] += y;
|
||||
y -= x;
|
||||
}
|
||||
int y;
|
||||
int h2;
|
||||
// increase bass
|
||||
y = peaks[1].height * 10; // addition as a multiple of 1/256s
|
||||
h2 = (1000<<16)/pitch; // decrease until 1000Hz
|
||||
if (h2 > 0) {
|
||||
x = y/h2;
|
||||
h = 1;
|
||||
while (y > 0) {
|
||||
htab[h++] += y;
|
||||
y -= x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -849,9 +844,8 @@ int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control)
|
||||
x = htab[h] >> 15;
|
||||
htab[h] = (x * x) >> 8;
|
||||
|
||||
if ((ix = (f >> 19)) < N_TONE_ADJUST) {
|
||||
if ((ix = (f >> 19)) < N_TONE_ADJUST)
|
||||
htab[h] = (htab[h] * wvoice->tone_adjust[ix]) >> 13; // index tone_adjust with Hz/8
|
||||
}
|
||||
}
|
||||
|
||||
// adjust the amplitude of the first harmonic, affects tonal quality
|
||||
@@ -861,9 +855,8 @@ int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control)
|
||||
|
||||
// calc intermediate increments of LF harmonics
|
||||
if (control & 1) {
|
||||
for (h = 1; h < N_LOWHARM; h++) {
|
||||
for (h = 1; h < N_LOWHARM; h++)
|
||||
harm_inc[h] = (htab[h] - harmspect[h]) >> 3;
|
||||
}
|
||||
}
|
||||
|
||||
return hmax; // highest harmonic number
|
||||
@@ -910,9 +903,8 @@ static void AdvanceParameters()
|
||||
if (ix < 3) {
|
||||
peaks[ix].right1 += peaks[ix].right_inc;
|
||||
peaks[ix].right = (int)peaks[ix].right1;
|
||||
} else {
|
||||
} else
|
||||
peaks[ix].right = peaks[ix].left;
|
||||
}
|
||||
}
|
||||
for (; ix < 8; ix++) {
|
||||
// formants 6,7,8 don't have a width parameter
|
||||
@@ -984,9 +976,8 @@ void InitBreath(void)
|
||||
minus_pi_t = -PI / samplerate;
|
||||
two_pi_t = -2.0 * minus_pi_t;
|
||||
|
||||
for (ix = 0; ix < N_PEAKS; ix++) {
|
||||
for (ix = 0; ix < N_PEAKS; ix++)
|
||||
setresonator(&rbreath[ix], 2000, 200, 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1089,9 +1080,8 @@ int Wavegen()
|
||||
|
||||
SetBreath();
|
||||
} else if ((samplecount & 0x07) == 0) {
|
||||
for (h = 1; h < N_LOWHARM && h <= maxh2 && h <= maxh; h++) {
|
||||
for (h = 1; h < N_LOWHARM && h <= maxh2 && h <= maxh; h++)
|
||||
harmspect[h] += harm_inc[h];
|
||||
}
|
||||
|
||||
// bring automctic gain control back towards unity
|
||||
if (agc < 256) agc++;
|
||||
@@ -1130,9 +1120,8 @@ int Wavegen()
|
||||
// This is the start of the second cycle, reduce its amplitude
|
||||
glottal_flag = 2;
|
||||
amplitude2 = (amplitude2 * glottal_reduce)/256;
|
||||
} else {
|
||||
} else
|
||||
glottal_flag--;
|
||||
}
|
||||
}
|
||||
|
||||
if (amplitude_env != NULL) {
|
||||
@@ -1162,9 +1151,8 @@ int Wavegen()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
wavephase += phaseinc;
|
||||
}
|
||||
waveph = (unsigned short)(wavephase >> 16);
|
||||
total = 0;
|
||||
|
||||
@@ -1201,14 +1189,12 @@ int Wavegen()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (voicing != 64) {
|
||||
if (voicing != 64)
|
||||
total = (total >> 6) * voicing;
|
||||
}
|
||||
|
||||
#ifndef PLATFORM_RISCOS
|
||||
if (wvoice->breath[0]) {
|
||||
if (wvoice->breath[0])
|
||||
total += ApplyBreath();
|
||||
}
|
||||
#endif
|
||||
|
||||
// mix with sampled wave if required
|
||||
@@ -1378,9 +1364,8 @@ static void SetPitchFormants()
|
||||
factor = 256 + (25 * (pitch_value - 50))/50;
|
||||
}
|
||||
|
||||
for (ix = 0; ix <= 5; ix++) {
|
||||
for (ix = 0; ix <= 5; ix++)
|
||||
wvoice->freq[ix] = (wvoice->freq2[ix] * factor)/256;
|
||||
}
|
||||
|
||||
factor = embedded_value[EMBED_T]*3;
|
||||
wvoice->height[0] = (wvoice->height2[0] * (256 - factor*2))/256;
|
||||
@@ -1671,9 +1656,8 @@ int WavegenFill2(int fill_zeros)
|
||||
break;
|
||||
|
||||
case WCMD_PAUSE:
|
||||
if (resume == 0) {
|
||||
if (resume == 0)
|
||||
echo_complete -= length;
|
||||
}
|
||||
wdata.n_mix_wavefile = 0;
|
||||
wdata.amplitude_fmt = 100;
|
||||
#ifdef INCLUDE_KLATT
|
||||
@@ -1725,9 +1709,8 @@ int WavegenFill2(int fill_zeros)
|
||||
case WCMD_MARKER:
|
||||
marker_type = q[0] >> 8;
|
||||
MarkerEvent(marker_type, q[1], q[2], q[3], out_ptr);
|
||||
if (marker_type == 1) { // word marker
|
||||
if (marker_type == 1) // word marker
|
||||
current_source_index = q[1] & 0xffffff;
|
||||
}
|
||||
break;
|
||||
|
||||
case WCMD_AMPLITUDE:
|
||||
@@ -1762,9 +1745,8 @@ int WavegenFill2(int fill_zeros)
|
||||
if (result == 0) {
|
||||
WcmdqIncHead();
|
||||
resume = 0;
|
||||
} else {
|
||||
} else
|
||||
resume = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1776,12 +1758,10 @@ int WavegenFill2(int fill_zeros)
|
||||
static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text)
|
||||
{
|
||||
if (length_in > 0) {
|
||||
if (sonicSpeedupStream == NULL) {
|
||||
if (sonicSpeedupStream == NULL)
|
||||
sonicSpeedupStream = sonicCreateStream(22050, 1);
|
||||
}
|
||||
if (sonicGetSpeed(sonicSpeedupStream) != sonicSpeed) {
|
||||
if (sonicGetSpeed(sonicSpeedupStream) != sonicSpeed)
|
||||
sonicSetSpeed(sonicSpeedupStream, sonicSpeed);
|
||||
}
|
||||
|
||||
sonicWriteShortToStream(sonicSpeedupStream, outbuf, length_in);
|
||||
}
|
||||
@@ -1789,9 +1769,8 @@ static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text
|
||||
if (sonicSpeedupStream == NULL)
|
||||
return 0;
|
||||
|
||||
if (end_of_text) {
|
||||
if (end_of_text)
|
||||
sonicFlushStream(sonicSpeedupStream);
|
||||
}
|
||||
return sonicReadShortFromStream(sonicSpeedupStream, outbuf, length_out);
|
||||
}
|
||||
#endif
|
||||
|
||||
+6
-12
@@ -154,9 +154,8 @@ void DisplayVoices(FILE *f_out, char *language)
|
||||
voice_select.gender = 0;
|
||||
voice_select.name = NULL;
|
||||
voices = espeak_ListVoices(&voice_select);
|
||||
} else {
|
||||
} else
|
||||
voices = espeak_ListVoices(NULL);
|
||||
}
|
||||
|
||||
fprintf(f_out, "Pty Language Age/Gender VoiceName File Other Languages\n");
|
||||
|
||||
@@ -182,9 +181,8 @@ void DisplayVoices(FILE *f_out, char *language)
|
||||
}
|
||||
fprintf(f_out, "%2d %-12s%s%c %-20s %-13s ",
|
||||
p[0], lang_name, age_buf, genders[v->gender], buf, v->identifier);
|
||||
} else {
|
||||
} else
|
||||
fprintf(f_out, "(%s %d)", lang_name, p[0]);
|
||||
}
|
||||
count++;
|
||||
p += len+2;
|
||||
}
|
||||
@@ -344,9 +342,8 @@ static void init_path(char *argv0, char *path_specified)
|
||||
}
|
||||
|
||||
snprintf(path_home, sizeof(path_home), "%s/espeak-data", getenv("HOME"));
|
||||
if (access(path_home, R_OK) != 0) {
|
||||
if (access(path_home, R_OK) != 0)
|
||||
strcpy(path_home, PATH_ESPEAK_DATA);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -497,9 +494,8 @@ int main(int argc, char **argv)
|
||||
c = long_options[ix].val;
|
||||
optarg2 = NULL;
|
||||
|
||||
if ((long_options[ix].has_arg != 0) && (p[len] == '=')) {
|
||||
if ((long_options[ix].has_arg != 0) && (p[len] == '='))
|
||||
optarg2 = &p[len+1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -760,9 +756,8 @@ int main(int argc, char **argv)
|
||||
if (flag_stdin == 0)
|
||||
option_linelength = -1; // single input lines on stdin
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
f_text = fopen(filename, "r");
|
||||
}
|
||||
|
||||
if ((f_text == NULL) && (p_text == NULL)) {
|
||||
fprintf(stderr, "%sfile '%s'\n", err_load, filename);
|
||||
@@ -802,9 +797,8 @@ int main(int argc, char **argv)
|
||||
break; // finished, wavegen command queue is empty
|
||||
}
|
||||
|
||||
if (Generate(phoneme_list, &n_phoneme_list, 1) == 0) {
|
||||
if (Generate(phoneme_list, &n_phoneme_list, 1) == 0)
|
||||
ix = SpeakNextClause(NULL, NULL, 1);
|
||||
}
|
||||
}
|
||||
|
||||
CloseWaveFile();
|
||||
|
||||
Reference in New Issue
Block a user