1.45.44 -- from the espeak and espeakedit zip file sources

This commit is contained in:
Reece Dunn
2011-09-17 16:31:41 +01:00
parent d928de911d
commit f0cf914a15
553 changed files with 12274 additions and 169 deletions
+203 -17
View File
@@ -57,12 +57,14 @@ extern void RiscosOpenSound();
extern int WcmdqUsed();
extern void FreePhData();
extern void FreeDictionary();
extern void Write4Bytes(FILE *f, int value);
extern int wcmdq_head;
extern int wcmdq_tail;
extern int current_source_index;
FILE *f_text;
FILE *f_wave = NULL;
int (* uri_callback)(int, const char *, const char *) = NULL;
int (* phoneme_callback)(const char *) = NULL;
@@ -74,6 +76,7 @@ char textbuffile[L_tmpnam];
int sample_rate_index; // current value
int current_voice_num=0;
int n_voice_files = 0;
int n_voice_variant_files = 0;
// output sound buffer, 2 bytes per sample
static unsigned short SoundBuf[4096];
@@ -82,7 +85,9 @@ static int callback_inhibit = 0;
static int more_text=0;
#define N_VOICE_NAMES 60
static char *voice_names[40];
#define N_VOICE_VARIANT_NAMES 30
static char *voice_names[N_VOICE_NAMES];
static char *voice_variant_names[N_VOICE_VARIANT_NAMES];
#define N_STATIC_BUF 8000
static char static_buf[N_STATIC_BUF];
@@ -108,7 +113,7 @@ static const char *help_text =
"-p <integer>\n"
"\t Pitch adjustment, 0 to 99, default is 50\n"
"-s <integer>\n"
"\t Speed in words per minute 80 to 370, default is 170\n"
"\t Speed in words per minute 80 to 390, default is 170\n"
"-v <voice name>\n"
"\t Use voice file of this name from espeak-data/voices\n"
"-w <wave file name>\n"
@@ -125,9 +130,9 @@ static const char *help_text =
"--punct=\"<characters>\"\n"
"\t Speak the names of punctuation characters during speaking. If\n"
"\t =<characters> is omitted, all punctuation is spoken.\n"
//"--voices=<langauge>\n"
//"\t List the available voices for the specified language.\n"
//"\t If <language> is omitted, then list all voices.\n"
"--voices=<language>\n"
"\t List the available voices for the specified language.\n"
"\t If <language> is omitted, then list all voices.\n"
"-k <integer>\n"
"\t Indicate capital letters with: 1=sound, 2=the word \"capitals\",\n"
"\t higher values = a pitch increase (try -k20).\n";
@@ -167,6 +172,7 @@ int GetFileLength(const char *filename)
void ReadVoiceNames2(char *directory)
{//==================================
int len;
int path_len;
int *type;
char *p;
_kernel_swi_regs regs;
@@ -182,6 +188,8 @@ void ReadVoiceNames2(char *directory)
regs.r[5] = sizeof(buf);
regs.r[6] = 0;
path_len = strlen(directory);
while(regs.r[3] > 0)
{
error = _kernel_swi(0x0c+os_X,&regs,&regs); /* OS_GBPB 10, read directory entries */
@@ -200,11 +208,25 @@ void ReadVoiceNames2(char *directory)
}
else
{
p = Alloc(len+1);
p = (char *)malloc(len+1);
strcpy(p,&buf[20]);
voice_names[n_voice_files++] = p;
if(n_voice_files >= (N_VOICE_NAMES-1))
break;
if(strcmp(&directory[path_len-3],".!v")==0)
{
if(n_voice_variant_files >= (N_VOICE_VARIANT_NAMES-1))
continue;
voice_variant_names[n_voice_variant_files++] = p;
}
else
{
if(n_voice_files >= (N_VOICE_NAMES-1))
continue;
voice_names[n_voice_files++] = p;
if(strcmp(p,"en")==0)
{
voice_names[n_voice_files++] = "en+f2";
}
}
}
}
}
@@ -214,13 +236,15 @@ void ReadVoiceNames()
{//===================
char directory[sizeof(path_home)+10];
for(n_voice_files=0; n_voice_files<N_VOICE_NAMES; n_voice_files++)
voice_names[n_voice_files] = NULL;
n_voice_files = 0;
n_voice_variant_files = 0;
sprintf(directory,"%s.voices",path_home);
ReadVoiceNames2(directory);
voice_names[n_voice_files] = NULL;
voice_variant_names[n_voice_variant_files] = NULL;
}
@@ -272,12 +296,90 @@ void Free(void **ptr)
#endif
static int OpenWaveFile(const char *path, int rate)
//=================================================
{
// Set the length of 0x7fffffff for --stdout
// This will be changed to the correct length for -w (write to file)
static unsigned char wave_hdr[44] = {
'R','I','F','F',0,0,0,0,'W','A','V','E','f','m','t',' ',
0x10,0,0,0,1,0,1,0, 9,0x3d,0,0,0x12,0x7a,0,0,
2,0,0x10,0,'d','a','t','a', 0xff,0xff,0xff,0x7f};
if(path == NULL)
return(2);
if(strcmp(path,"stdout")==0)
f_wave = stdout;
else
f_wave = fopen(path,"wb");
if(f_wave != NULL)
{
fwrite(wave_hdr,1,24,f_wave);
Write4Bytes(f_wave,rate);
Write4Bytes(f_wave,rate * 2);
fwrite(&wave_hdr[32],1,12,f_wave);
return(0);
}
return(1);
} // end of OpenWaveFile
static void CloseWaveFile(int rate)
//=================================
{
unsigned int pos;
if((f_wave == NULL) || (f_wave == stdout))
return;
fflush(f_wave);
pos = ftell(f_wave);
fseek(f_wave,4,SEEK_SET);
Write4Bytes(f_wave,pos - 8);
fseek(f_wave,40,SEEK_SET);
Write4Bytes(f_wave,pos - 44);
fclose(f_wave);
f_wave = NULL;
} // end of CloseWaveFile
void MarkerEvent(int type, unsigned int char_position, int value, unsigned char *out_ptr)
{//======================================================================================
// Do nothing in the command-line version.
} // end of MarkerEvent
static int WavegenFile(void)
{//=========================
int finished;
unsigned char wav_outbuf[1024];
out_ptr = out_start = wav_outbuf;
out_end = wav_outbuf + sizeof(wav_outbuf);
finished = WavegenFill(0);
if(f_wave != NULL)
{
fwrite(wav_outbuf, 1, out_ptr - wav_outbuf, f_wave);
}
return(finished);
} // end of WavegenFile
void FillSoundBuf(int size)
@@ -335,6 +437,7 @@ void speak_text_string(char *data, int terminator, int len, int wait, int voice_
regs.r[1] = (int)module_data;
_kernel_swi(0x5f, &regs, &regs);
option_endpause = 1;
if((voice_num >= 0) && (voice_num != current_voice_num) && (voice_num < N_VOICE_NAMES))
{
@@ -465,7 +568,6 @@ void set_say_options(int reg2, int reg3)
option_linelength = 0;
option_phonemes = 0;
option_waveout = 0;
option_harmonic1 = 8;
option_multibyte = 0; // auto
option_capitals = 0;
option_punctuation = 0;
@@ -477,10 +579,13 @@ void set_say_options(int reg2, int reg3)
void jsd_swi_functions(int *r)
/****************************/
{
espeak_VOICE voice_select;
switch(r[0])
{
case 0: /* major version */
r[0] = 3;
r[0] = 4;
r[1] = 331;
break;
case 1: /* register user */
@@ -499,6 +604,7 @@ void jsd_swi_functions(int *r)
case 5: /* get table of voice names */
r[0] = (int)voice_names;
r[1] = (int)voice_variant_names;
break;
case 6: /* update voice data, r1 = voice_number */
@@ -514,6 +620,15 @@ void jsd_swi_functions(int *r)
// init_voice((char *)r[1]);
break;
case 8:
// list voices, r[1] contains optional language name (or "variant")
voice_select.languages = (char *)r[1];
voice_select.age = 0;
voice_select.gender = 0;
voice_select.name = NULL;
r[0] = (int)espeak_ListVoices(&voice_select);
break;
default:
r[0] = 0;
r[1] = 0;
@@ -629,6 +744,72 @@ void PitchAdjust(int pitch_adjustment)
void DisplayVoices(FILE *f_out, char *language)
{//============================================
int ix;
const char *p;
int len;
int count;
int scores = 0;
const espeak_VOICE *v;
const char *lang_name;
char age_buf[12];
const espeak_VOICE **voices;
espeak_VOICE voice_select;
static char genders[4] = {' ','M','F',' '};
if(language[0] == '=')
{
// display only voices for the specified language, in order of priority
voice_select.languages = &language[1];
voice_select.age = 0;
voice_select.gender = 0;
voice_select.name = NULL;
voices = espeak_ListVoices(&voice_select);
scores = 1;
}
else
{
voices = espeak_ListVoices(NULL);
}
fprintf(f_out,"Pty Language Age/Gender VoiceName File Other Langs\n");
for(ix=0; (v = voices[ix]) != NULL; ix++)
{
count = 0;
p = v->languages;
while(*p != 0)
{
len = strlen(p+1);
lang_name = p+1;
if(v->age == 0)
strcpy(age_buf," ");
else
sprintf(age_buf,"%3d",v->age);
if(count==0)
{
fprintf(f_out,"%2d %-12s%s%c %-17s %-11s ",
p[0],lang_name,age_buf,genders[v->gender],v->name,v->identifier);
}
else
{
fprintf(f_out,"(%s %d)",lang_name,p[0]);
}
count++;
p += len+2;
}
// if(scores)
// fprintf(f_out,"%3d ",v->score);
fputc('\n',f_out);
}
} // end of DisplayVoices
char *param_string(char **argp)
{//============================
char *p;
@@ -686,7 +867,6 @@ void command_line(char *arg_string, int wait)
option_phonemes = 0;
option_waveout = 0;
option_quiet = 0;
option_harmonic1 = 8;
option_multibyte = 0; // auto
option_capitals = 0;
option_punctuation = 0;
@@ -776,7 +956,13 @@ void command_line(char *arg_string, int wait)
strncpy0(command,param_string(&p),sizeof(command));
if(memcmp(command,"compile=",8)==0)
{
CompileDictionary(NULL,&command[8],NULL,NULL);
CompileDictionary(NULL,&command[8],NULL,NULL,0);
return;
}
else
if(memcmp(command,"voices",6)==0)
{
DisplayVoices(stdout,&command[6]);
return;
}
else
@@ -1075,7 +1261,7 @@ void terminate_module(void)
{
RiscosCloseSound();
RemoveCallback();
delete translator;
DeleteTranslator(translator);
FreePhData();
} /* end of terminate_module */