Merge branch 'development'

This commit is contained in:
Reece H. Dunn
2013-02-20 08:21:16 +00:00
26 changed files with 1202 additions and 342 deletions
+44 -19
View File
@@ -630,6 +630,7 @@ static FILE *f_phtab;
static FILE *f_phcontents;
static FILE *f_errors = stderr;
static FILE *f_prog_log = NULL;
static FILE *f_report;
static FILE *f_in;
@@ -642,6 +643,7 @@ static int count_references = 0;
static int duplicate_references = 0;
static int count_frames = 0;
static int error_count = 0;
static int resample_count = 0;
static int then_count = 0;
static int after_if = 0;
@@ -733,27 +735,21 @@ static void CompileReport(void)
int n;
REF_HASH_TAB *p;
REF_HASH_TAB **list;
FILE *f_report;
const char *data_path;
int prev_table;
int prev_mnemonic;
char fname[sizeof(path_source)+20];
if(f_report == NULL)
return;
// make a list of all the references and sort it
list = (REF_HASH_TAB **)malloc((count_references)* sizeof(REF_HASH_TAB *));
if(list == NULL)
return;
sprintf(fname,"%scompile_report",path_source);
f_report = fopen(fname,"w");
if(f_report == NULL)
{
free(list);
return;
}
fprintf(f_report,"%d phoneme tables\n",n_phoneme_tabs);
fprintf(f_report," new total\n");
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++)
{
fprintf(f_report,"%8s %3d %4d\n",phoneme_tab_list2[ix].name, phoneme_tab_list2[ix].n_phonemes, n_phcodes_list[ix]+1);
@@ -1824,20 +1820,31 @@ static int LoadWavefile(FILE *f, const char *fname)
if((fd_temp = mkstemp(fname_temp)) >= 0)
{
close(fd_temp);
sprintf(command,"sox \"%s%s.wav\" -r %d -c 1 -w %s polyphase\n",path_source,fname,samplerate_native,fname_temp);
sprintf(command,"sox \"%s%s.wav\" -c1 -t wav %s rate -h %d\n",path_source,fname,fname_temp,samplerate_native);
if(system(command) < 0)
{
error("Failed to resample: %s",command);
remove(fname_temp);
return(0);
}
}
if(GetFileLength(fname_temp) <= 0)
{
error("Failed to resample: %s",command);
remove(fname_temp);
return(0);
}
f = fopen(fname_temp,"rb");
if(f == NULL)
{
error("Can't read temp file: %s",fname_temp);
return(0);
}
if(f_report != NULL)
fprintf(f_report, "resampled %s\n", fname);
resample_count++;
resample_wav = 1;
fseek(f,40,SEEK_SET); // skip past the WAV header, up to before "data length"
}
@@ -3408,9 +3415,13 @@ static void CompilePhonemeData2(const char *source)
wxString report;
wxString report_dict;
#ifdef MAKE_ENVELOPES
make_envs();
#endif
n_envelopes = 0;
error_count = 0;
memset(markers_used,0,sizeof(markers_used));
memset(markers_used,0,sizeof(markers_used));
f_errors = stderr;
@@ -3471,6 +3482,10 @@ static void CompilePhonemeData2(const char *source)
if((f_errors = fopen_log(f_errors,fname,"w")) == NULL)
f_errors = stderr;
sprintf(fname,"%s%s",path_source,"compile_report");
f_report = fopen_log(f_errors, fname,"w");
sprintf(fname,"%s/%s",path_home,"phondata-manifest");
if((f_phcontents = fopen_log(f_phcontents,fname,"w")) == NULL)
f_phcontents = stderr;
@@ -3534,8 +3549,6 @@ static void CompilePhonemeData2(const char *source)
fprintf(f_errors,"\nRefs %d, Reused %d\n",count_references,duplicate_references);
fclose(f_in);
fclose(f_phdata);
if(f_errors != stderr)
fclose(f_errors);
if(f_prog_log != NULL)
fclose(f_prog_log);
fclose(f_phindex);
@@ -3545,18 +3558,30 @@ fprintf(f_errors,"\nRefs %d, Reused %d\n",count_references,duplicate_references
LoadPhData();
LoadVoice(voice_name2,0);
CompileReport();
report_dict = CompileAllDictionaries();
//#ifdef deleted
DrawEnvelopes();
//#endif
if(gui_flag)
{
delete progress;
}
report.Printf(_T("Compiled phonemes: %d errors."),error_count);
if(resample_count > 0)
{
fprintf(f_errors, "\n%d WAV files resampled to %d Hz\n", resample_count, samplerate_native);
report.Printf(_T("Compiled phonemes: %d errors, %d files resampled to %d Hz. "),error_count, resample_count, samplerate_native);
}
else
{
report.Printf(_T("Compiled phonemes: %d errors."),error_count);
}
if(f_errors != stderr)
fclose(f_errors);
if(error_count > 0)
{
report += _T(" See file: 'phsource/error_log'.");
@@ -3734,6 +3759,7 @@ void CompileIntonation()
char buf[sizeof(path_source)+120];
error_count = 0;
resample_count = 0;
sprintf(fname_errors,"%s%s",path_source,"error_intonation");
if((f_errors = fopen(fname_errors,"w")) == NULL)
@@ -4002,7 +4028,6 @@ void CompileIntonation()
fwrite(tune_data, n_tune_names, sizeof(TUNE), f_out);
fclose(f_in);
fclose(f_out);
fclose(f_errors);
report.Printf(_T("Compiled %d intonation tunes: %d errors."),n_tune_names, error_count);
wxLogStatus(report);
+6 -2
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -51,11 +51,15 @@ static char letterGroupsDefined[N_LETTER_GROUPS];
MNEM_TAB mnem_rules[] = {
{"unpr", 0x01},
{"w_alt1", 0x11},
{"w_alt2", 0x12},
{"w_alt3", 0x13},
// {"w_alt4", 0x14},
{"w_alt", 0x11}, // note: put longer names before their sub-strings
{"p_alt1", 0x21},
{"p_alt2", 0x22},
{"p_alt3", 0x23},
// {"p_alt4", 0x24},
{"p_alt", 0x21},
{NULL, -1} };
@@ -1586,7 +1590,7 @@ static int compile_lettergroup(char *input, FILE *f_out)
items[n_items] = p_start = p;
while((*p & 0xff) > ' ')
{
if (*p == '_') *p = ' '; // allow '_' for word break
if (*p == '_') *p = ' '; // allow '_' for word break
p++;
}
*p++ = 0;
+10
View File
@@ -296,6 +296,10 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
// set up indices into data_dictrules
InitGroups(tr);
if(tr->groups1[0] == NULL)
{
fprintf(stderr,"Error in %s_rules, no default rule group\n",name);
}
// set up hash table for data_dictlist
p = &(tr->data_dictlist[8]);
@@ -2732,6 +2736,12 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
if(word_flags & FLAG_UNPRON_TEST)
return(match1.end_type | 1);
#ifdef deleted
// ?? allow $unpr while translating rules, not just on initial FLAG_UNPRON_TEST
if((match1.end_type & SUFX_UNPRON) && !(word_flags & FLAG_SUFFIX_REMOVED))
return(match1.end_type);
#endif
if((match1.phonemes[0] == phonSWITCH) && ((word_flags & FLAG_DONT_SWITCH_TRANSLATOR)==0))
{
// an instruction to switch language, return immediately so we can re-translate
+6 -2
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2006 to 2007 by Jonathan Duddington *
* Copyright (C) 2006 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -768,7 +768,11 @@ int main (int argc, char **argv)
fclose(f_text);
}
espeak_Synchronize();
if(espeak_Synchronize() != EE_OK)
{
fprintf(stderr, "espeak_Synchronize() failed, maybe error when opening output device\n");
exit(4);
}
if(f_phonemes_out != stdout)
fclose(f_phonemes_out); // needed for WinCE
+2 -2
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -685,7 +685,7 @@ void DisplayErrorFile(const char *fname)
if(len > 0)
{
if(len > 1500)
len = 1500; // restrict length to pppppevent crash in wxLogMessage()
len = 1500; // restrict length to prevent crash in wxLogMessage()
msg = (char *)malloc(len+1);
if(msg != NULL)
{
+3 -3
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -162,8 +162,8 @@ void ProsodyDisplay::SelectPh(int index)
}
y1 = p->pitch1;
y2 = p->pitch2;
sprintf(buf,"Stress %s%d Amp %2d LenMod %2d Pitch %3d %3d %s PhFlags %.2x ",
emphasized,p->stresslevel&0x7,p->amp,p->length,y1,y2,name,p->ph->phflags);
sprintf(buf,"Stress %s%d Amp %2d StdLength %2d LengthMod %2d Pitch %3d %3d %s PhFlags %.2x ",
emphasized,p->stresslevel&0x7,p->amp,p->std_length*2, p->length,y1,y2,name,p->ph->phflags);
wxLogStatus(wxString(buf,wxConvLocal));
}
+17 -6
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2011 by Jonathan Duddington *
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -60,6 +60,7 @@ static espeak_AUDIO_OUTPUT my_mode=AUDIO_OUTPUT_SYNCHRONOUS;
static int synchronous_mode = 1;
static int out_samplerate = 0;
static int voice_samplerate = 22050;
static espeak_ERROR err = EE_OK;
t_espeak_callback* synth_callback = NULL;
int (* uri_callback)(int, const char *, const char *) = NULL;
@@ -114,7 +115,11 @@ static int dispatch_audio(short* outbuf, int length, espeak_EVENT* event)
sleep(1);
}
out_samplerate = voice_samplerate;
wave_init(voice_samplerate);
if(!wave_init(voice_samplerate))
{
err = EE_INTERNAL_ERROR;
return(-1);
}
wave_set_callback_is_output_enabled( fifo_is_command_enabled);
my_audio = wave_open("alsa");
event_init();
@@ -166,8 +171,8 @@ static int dispatch_audio(short* outbuf, int length, espeak_EVENT* event)
}
SHOW_TIME("LEAVE dispatch_audio\n");
return (a_wave_can_be_played==0); // 1 = stop synthesis
return (a_wave_can_be_played==0); // 1 = stop synthesis, -1 = error
}
@@ -373,6 +378,7 @@ static int initialise(int control)
int param;
int result;
err = EE_OK;
LoadConfig();
WavegenInit(22050,0); // 22050
if((result = LoadPhData()) != 1)
@@ -487,6 +493,8 @@ static espeak_ERROR Synthesize(unsigned int unique_identifier, const void *text,
{
#ifdef USE_ASYNC
finished = create_events((short *)outbuf, length, event_list, a_write_pos);
if(finished < 0)
return EE_INTERNAL_ERROR;
length = 0; // the wave data are played once.
#endif
}
@@ -516,7 +524,8 @@ static espeak_ERROR Synthesize(unsigned int unique_identifier, const void *text,
#ifdef USE_ASYNC
if (my_mode==AUDIO_OUTPUT_PLAYBACK)
{
dispatch_audio(NULL, 0, NULL); // TBD: test case
if(dispatch_audio(NULL, 0, NULL) < 0) // TBD: test case
return err = EE_INTERNAL_ERROR;
}
else
{
@@ -1198,6 +1207,7 @@ ESPEAK_API int espeak_IsPlaying(void)
ESPEAK_API espeak_ERROR espeak_Synchronize(void)
{//=============================================
espeak_ERROR berr = err;
#ifdef USE_ASYNC
SHOW_TIME("espeak_Synchronize > ENTER");
while (espeak_IsPlaying())
@@ -1205,8 +1215,9 @@ ESPEAK_API espeak_ERROR espeak_Synchronize(void)
usleep(20000);
}
#endif
err = EE_OK;
SHOW_TIME("espeak_Synchronize > LEAVE");
return EE_OK;
return berr;
} // end of espeak_Synchronize
+2 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.46.34 12.Feb.13";
const char *version_string = "1.46.35 14.Feb.13";
const int version_phdata = 0x014631;
int option_device_number = -1;
@@ -1215,6 +1215,7 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
memcpy(&worddata->prev_vowel, &plist[0], sizeof(PHONEME_LIST));
}
plist->std_length = phdata->pd_param[i_SET_LENGTH];
} // end of InterpretPhoneme
+1
View File
@@ -220,6 +220,7 @@ typedef struct {
unsigned char newword; // bit 0=start of word, bit 1=end of clause, bit 2=start of sentence
unsigned char pitch1;
unsigned char pitch2;
unsigned char std_length;
} PHONEME_LIST;
+12 -1
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2011 by Jonathan Duddington *
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -1135,6 +1135,17 @@ if((wmark > 0) && (wmark < 8))
return(0);
}
#ifdef deleted
// ?? allow $unpr while translating rules, not just on initial FLAG_UNPRON_TEST
if(end_type & SUFX_UNPRON)
{
phonemes[0] = 0; // discard and retranslate as individual letters
SpeakIndividualLetters(tr, wordx, phonemes, 0);
strcpy(word_phonemes, phonemes);
return(0);
}
#endif
if((phonemes[0] == 0) && (end_phonemes[0] == 0))
{
int wc;
+1 -1
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2011 by Jonathan Duddington *
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
+8 -7
View File
@@ -62,7 +62,7 @@ enum {ONE_BILLION=1000000000};
static int pulse_running;
// wave.cpp (this file)
void wave_port_init(int);
int wave_port_init(int);
void* wave_port_open(const char* the_api);
size_t wave_port_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize);
int wave_port_close(void* theHandler);
@@ -77,7 +77,7 @@ int wave_port_get_remaining_time(uint32_t sample, uint32_t* time);
// wave_pulse.cpp
int is_pulse_running();
void wave_pulse_init(int);
int wave_pulse_init(int);
void* wave_pulse_open(const char* the_api);
size_t wave_pulse_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize);
int wave_pulse_close(void* theHandler);
@@ -91,13 +91,13 @@ void* wave_pulse_test_get_write_buffer();
int wave_pulse_get_remaining_time(uint32_t sample, uint32_t* time);
// wrappers
void wave_init(int srate) {
int wave_init(int srate) {
pulse_running = is_pulse_running();
if (pulse_running)
wave_pulse_init(srate);
return wave_pulse_init(srate);
else
wave_port_init(srate);
return wave_port_init(srate);
}
void* wave_open(const char* the_api) {
@@ -756,7 +756,7 @@ void wave_set_callback_is_output_enabled(t_wave_callback* cb)
//<wave_init
// TBD: the arg could be "alsa", "oss",...
void wave_init(int srate)
int wave_init(int srate)
{
ENTER("wave_init");
PaError err;
@@ -773,6 +773,7 @@ void wave_init(int srate)
{
SHOW_TIME("wave_init > Failed to initialise the PortAudio sound");
}
return err == paNoError;
}
//>
@@ -1194,7 +1195,7 @@ void *wave_test_get_write_buffer()
// notdef USE_PORTAUDIO
void wave_init(int srate) {}
int wave_init(int srate) {}
void* wave_open(const char* the_api) {return (void *)1;}
size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {return theSize;}
int wave_close(void* theHandler) {return 0;}
+1 -1
View File
@@ -7,7 +7,7 @@
extern int option_device_number;
extern void wave_init(int samplerate);
extern int wave_init(int samplerate);
// TBD: the arg could be "alsa", "oss",...
extern void* wave_open(const char* the_api);
+3 -3
View File
@@ -660,14 +660,14 @@ void wave_set_callback_is_output_enabled(t_wave_callback* cb)
//>
//<wave_init
void wave_init(int srate)
int wave_init(int srate)
{
ENTER("wave_init");
stream = NULL;
wave_samplerate = srate;
pulse_open();
return pulse_open() == PULSE_OK;
}
//>
@@ -870,7 +870,7 @@ void *wave_test_get_write_buffer()
// notdef USE_PULSEAUDIO
void wave_init() {}
int wave_init() {}
void* wave_open(const char* the_api) {return (void *)1;}
size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {return theSize;}
int wave_close(void* theHandler) {return 0;}
+4 -3
View File
@@ -78,7 +78,7 @@ static uint32_t wave_samplerate;
//
//<wave_init
void wave_init(int srate) {
int wave_init(int srate) {
ENTER("wave_init");
audio_info_t ainfo;
@@ -104,7 +104,7 @@ void wave_init(int srate) {
SHOW("wave_init() sun_audio_fd: %d\n", sun_audio_fd);
if (sun_audio_fd < 0) {
return;
return(0);
}
ioctl(sun_audio_fd, AUDIO_GETINFO, &ainfo);
@@ -117,8 +117,9 @@ void wave_init(int srate) {
if (ioctl(sun_audio_fd, AUDIO_SETINFO, &ainfo) == -1) {
SHOW("wave_init() failed to set audio params: %s\n", strerror(errno));
close(sun_audio_fd);
return;
return(0);
}
return(1);
}
//>