[1.43.48]

Add mbrowrap.cpp to emulate the mbrola library which is available in Windows, but not on Linux.  mbrola voices in command-line espeak and libespeak now call mbrola directly rather than generating phoneme information as text.  Mbrola phonemes as text is still available with the new --pho command-line option.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@248 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2010-06-28 15:50:12 +00:00
parent fb9338ad14
commit a9fedd94db
33 changed files with 1693 additions and 714 deletions
+49 -28
View File
@@ -66,8 +66,10 @@ static const char *help_text =
"\t directory. <voice name> specifies the language\n"
"--path=\"<path>\"\n"
"\t Specifies the directory containing the espeak-data directory\n"
"--pho\n"
"\t Write mbrola phoneme data (.pho) to stdout, or to the file in --phonout\n"
"--phonout=\"<filename>\"\n"
"\t Write output from -x -X commands, and mbrola phoneme data, to this file\n"
"\t Write phoneme output from -x -X and --pho to this file\n"
"--punct=\"<characters>\"\n"
"\t Speak the names of punctuation characters during speaking. If\n"
"\t =<characters> is omitted, all punctuation is spoken.\n"
@@ -87,6 +89,7 @@ int samplerate;
int quiet = 0;
unsigned int samples_total = 0;
unsigned int samples_split = 0;
unsigned int samples_split_seconds = 0;
unsigned int wavefile_count = 0;
FILE *f_wavfile = NULL;
@@ -218,15 +221,18 @@ int OpenWavFile(char *path, int rate)
else
f_wavfile = fopen(path,"wb");
if(f_wavfile != NULL)
if(f_wavfile == NULL)
{
fwrite(wave_hdr,1,24,f_wavfile);
Write4Bytes(f_wavfile,rate);
Write4Bytes(f_wavfile,rate * 2);
fwrite(&wave_hdr[32],1,12,f_wavfile);
return(0);
fprintf(stderr,"Can't write to: '%s'\n",path);
return(1);
}
return(1);
fwrite(wave_hdr,1,24,f_wavfile);
Write4Bytes(f_wavfile,rate);
Write4Bytes(f_wavfile,rate * 2);
fwrite(&wave_hdr[32],1,12,f_wavfile);
return(0);
} // end of OpenWavFile
@@ -266,25 +272,40 @@ static int SynthCallback(short *wav, int numsamples, espeak_EVENT *events)
return(0);
}
if(samples_split > 0)
while(events->type != 0)
{
// start a new WAV file when this limit is reached, at the next sentence boundary
while(events->type != 0)
if(events->type == espeakEVENT_SAMPLERATE)
{
if((events->type == espeakEVENT_SENTENCE) && (samples_total > samples_split))
samplerate = events->id.number;
samples_split = samples_split_seconds * samplerate;
}
else
if(events->type == espeakEVENT_SENTENCE)
{
// start a new WAV file when the limit is reached, at this sentence boundary
if((samples_split > 0) && (samples_total > samples_split))
{
CloseWavFile();
samples_total = 0;
wavefile_count++;
}
events++;
}
events++;
}
if(f_wavfile == NULL)
{
sprintf(fname,"%s_%.2d%s",wavefile,++wavefile_count,filetype);
if(OpenWavFile(fname, samplerate) != 0)
return(1);
if(samples_split > 0)
{
sprintf(fname,"%s_%.2d%s",wavefile,wavefile_count+1,filetype);
if(OpenWavFile(fname, samplerate) != 0)
return(1);
}
else
{
if(OpenWavFile(wavefile, samplerate) != 0)
return(1);
}
}
if(numsamples > 0)
@@ -332,7 +353,8 @@ int main (int argc, char **argv)
{"stdout", no_argument, 0, 0x105},
{"split", optional_argument, 0, 0x106},
{"path", required_argument, 0, 0x107},
{"phonout", required_argument, 0, 0x108},
{"phonout", required_argument, 0, 0x108},
{"pho", no_argument, 0, 0x109},
{0, 0, 0, 0}
};
@@ -360,7 +382,8 @@ int main (int argc, char **argv)
int wordgap = -1;
int option_capitals = -1;
int option_punctuation = -1;
int option_phonemes = -1;
int option_phonemes = 0;
int option_mbrola_phonemes = 0;
int option_linelength = 0;
int option_waveout = 0;
@@ -550,9 +573,9 @@ int main (int argc, char **argv)
case 0x106: // -- split
if(optarg2 == NULL)
samples_split = 30; // default 30 minutes
samples_split = 30 * 60; // default 30 minutes
else
samples_split = atoi(optarg2);
samples_split = atoi(optarg2) * 60;
break;
case 0x107: // --path
@@ -566,6 +589,10 @@ int main (int argc, char **argv)
}
break;
case 0x109: // --pho
option_mbrola_phonemes = 8;
break;
default:
exit(0);
}
@@ -576,7 +603,7 @@ int main (int argc, char **argv)
{
// writing to a file (or no output), we can use synchronous mode
samplerate = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,0,data_path,0);
samples_split = (samplerate * samples_split) * 60;
samples_split = samplerate * samples_split_seconds;
espeak_SetSynthCallback(SynthCallback);
if(samples_split)
@@ -589,12 +616,6 @@ int main (int argc, char **argv)
*extn = 0;
}
}
else
if(option_waveout)
{
if(OpenWavFile(wavefile,samplerate) != 0)
exit(4);
}
}
else
{
@@ -641,7 +662,7 @@ int main (int argc, char **argv)
espeak_SetParameter(espeakLINELENGTH,option_linelength,0);
if(option_punctuation == 2)
espeak_SetPunctuationList(option_punctlist);
espeak_SetPhonemeTrace(option_phonemes,f_phonemes_out);
espeak_SetPhonemeTrace(option_phonemes | option_mbrola_phonemes,f_phonemes_out);
if(filename[0]==0)
{