Move CompileMbrola to libespeak-ng.

This commit is contained in:
Reece H. Dunn
2015-12-12 11:26:20 +00:00
parent 4e4a0e8f40
commit 257b6b33a5
4 changed files with 139 additions and 100 deletions
-98
View File
@@ -3718,104 +3718,6 @@ fprintf(f_errors,"\nRefs %d, Reused %d\n",count_references,duplicate_references
ReadPhondataManifest();
} // end of CompilePhonemeData
#include <errno.h>
void CompileMbrola(const wxChar *mbrola_file)
{//=================
char *p;
FILE *f_in;
FILE *f_out;
int percent;
int n;
int *pw;
int *pw_end;
int count = 0;
int control;
char phoneme[40];
char phoneme2[40];
char name1[40];
char name2[40];
char mbrola_voice[40];
char buf[sizeof(path_home)+30];
int mbrola_ctrl = 20; // volume in 1/16 ths
MBROLA_TAB data[N_PHONEME_TAB];
wxString filepath;
if (mbrola_file == NULL)
{
filepath = wxFileSelector(_T("Read Mbrola phonemes file"),path_phsource+_T("/mbrola"),_T(""),_T(""),_T("*"),wxOPEN);
}
else
{
filepath = mbrola_file;
}
strcpy(buf,filepath.mb_str(wxConvLocal));
if((f_in = fopen(buf,"r")) == NULL)
{
wxLogError(_T("Can't read: ")+filepath);
return;
}
while(fgets(buf,sizeof(phoneme),f_in) != NULL)
{
buf[sizeof(phoneme)-1] = 0;
if((p = strstr(buf,"//")) != NULL)
*p = 0; // truncate line at comment
if(memcmp(buf,"volume",6)==0)
{
mbrola_ctrl = atoi(&buf[6]);
continue;
}
n = sscanf(buf,"%d %s %s %d %s %s",&control,phoneme,phoneme2,&percent,name1,name2);
if(n >= 5)
{
data[count].name = StringToWord(phoneme);
if(strcmp(phoneme2,"NULL")==0)
data[count].next_phoneme = 0;
else
if(strcmp(phoneme2,"VWL")==0)
data[count].next_phoneme = 2;
else
data[count].next_phoneme = StringToWord(phoneme2);
data[count].mbr_name = 0;
data[count].mbr_name2 = 0;
data[count].percent = percent;
data[count].control = control;
if(strcmp(name1,"NULL")!=0)
data[count].mbr_name = StringToWord(name1);
if(n == 6)
data[count].mbr_name2 = StringToWord(name2);
count++;
}
}
fclose(f_in);
wxFileName filename = wxFileName(filepath);
strcpy(mbrola_voice,filename.GetName().mb_str(wxConvLocal));
sprintf(buf,"%s/mbrola_ph/%s_phtrans",path_home,mbrola_voice);
if((f_out = fopen(buf,"wb")) == NULL)
{
wxLogError(_T("Can't write to: ")+wxString(buf,wxConvLocal));
return;
}
data[count].name = 0; // list terminator
Write4Bytes(f_out, mbrola_ctrl);
pw_end = (int *)(&data[count+1]);
for(pw = (int *)data; pw < pw_end; pw++)
{
Write4Bytes(f_out, *pw);
}
fclose(f_out);
wxLogStatus(_T("Mbrola translation file: %d phonemes"),count);
} // end of CompileMbrola
static const char *preset_tune_names[] = {
"s1", "c1", "q1", "e1", NULL};