[1.28.05] Changed names of voice variant files (espeak-data/voices/!v).

Moves "wisper" and "croak" into voices/!v.
Voice variants can now be specified as  en+wisper, en+f2 (for female 2), etc.
espeak --voices=variant  lists the voice variants.
Moves some lines from speech.h into other header files.
Possible fix for data version check on big-endian.
Fixed crash error iin LoadConfig().
Fixed crash in espeakedit: press Tab in enpty Prosody window.

git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@74 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2007-08-17 12:58:34 +00:00
parent d4ff77a7d5
commit 5019e65842
44 changed files with 186 additions and 414 deletions
+2 -2
View File
@@ -30,11 +30,11 @@
#include "speak_lib.h"
#include "main.h"
#include "speech.h"
#include "voice.h"
#include "spect.h"
#include "options.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "spect.h"
#define tNUMBER 1
+1 -1
View File
@@ -33,10 +33,10 @@
#include "speak_lib.h"
#include "main.h"
#include "speech.h"
#include "voice.h"
#include "options.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "spect.h"
#include "translate.h"
#include "prosodydisplay.h"
+2 -2
View File
@@ -28,10 +28,10 @@
#include "speak_lib.h"
#include "main.h"
#include "speech.h"
#include "voice.h"
#include "spect.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "spect.h"
#include "translate.h"
#include "options.h"
+3
View File
@@ -24,8 +24,11 @@
#include "wx/mdi.h"
#include "speak_lib.h"
#include "main.h"
#include "speech.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "spect.h"
+1 -1
View File
@@ -25,9 +25,9 @@
#include "speak_lib.h"
#include "speech.h"
#include "voice.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "translate.h"
+1
View File
@@ -20,6 +20,7 @@
#include "wx/wx.h"
#include "wx/fileconf.h"
#include "wx/filename.h"
#include <sys/stat.h>
#include "speech.h"
+8 -1
View File
@@ -125,7 +125,7 @@ void ProsodyDisplay::SelectPh(int index)
if(index < 0) return;
p = &phlist[index];
if(p == NULL) return;
if((p == NULL) || (p->ph == NULL)) return;
sprintf(buf,"Stress %d Amp %2d LenMod %2d Pitch %3d %3d [env=%d] Flags %.2x ",
p->tone,p->amp,p->length,p->pitch1,p->pitch2,p->env,p->ph->phflags);
@@ -293,7 +293,14 @@ void ProsodyDisplay::OnKey(wxKeyEvent& event)
p->length++;
break;
case WXK_TAB:
display = 0;
event.Skip();
transldlg->SetFocus();
break;
default:
display = 0;
event.Skip();
break;
}
+1 -1
View File
@@ -29,9 +29,9 @@
#include "speak_lib.h"
#include "speech.h"
#include "voice.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "translate.h"
#include <locale.h>
+1 -1
View File
@@ -25,9 +25,9 @@
#include "speak_lib.h"
#include "speech.h"
#include "voice.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "translate.h"
extern int GetAmplitude(void);
+1 -1
View File
@@ -43,9 +43,9 @@
#include <sys/stat.h>
#include "speak_lib.h"
#include "voice.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "translate.h"
+2 -2
View File
@@ -36,9 +36,9 @@
#endif
#include "speak_lib.h"
#include "voice.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "translate.h"
#include "debug.h"
@@ -265,7 +265,7 @@ int GetFileLength(const char *filename)
char *Alloc(int size)
{//==================
char *p;
if((p = (char *)malloc(size+1)) == NULL)
if((p = (char *)malloc(size)) == NULL)
fprintf(stderr,"Can't allocate memory\n"); // I was told that size+1 fixes a crash on 64-bit systems
return(p);
}
+1 -1
View File
@@ -23,9 +23,9 @@
#include "speak_lib.h"
#include "speech.h"
#include "main.h"
#include "voice.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "spect.h"
#include "options.h"
#include "wx/txtstrm.h"
+4 -1
View File
@@ -29,8 +29,11 @@
#include <ctype.h>
#include "main.h"
#include "speak_lib.h"
#include "speech.h"
#include "main.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "spect.h"
#include "options.h"
+3
View File
@@ -21,7 +21,10 @@
#include "wx/wx.h"
#include <math.h>
#include "speak_lib.h"
#include "speech.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "spect.h"
#include "main.h"
+3 -26
View File
@@ -54,9 +54,6 @@ typedef double DOUBLEX;
#define N_PEAKS 9
#define N_MARKERS 8
typedef struct {
const char *mnem;
@@ -65,32 +62,12 @@ typedef struct {
int LookupMnem(MNEM_TAB *table, char *string);
typedef struct {
short pkfreq;
short pkheight;
short pkwidth;
short pkright;
} peak_t;
typedef struct {
short frflags;
unsigned char length;
unsigned char rms;
short ffreq[9];
unsigned char fheight[9];
unsigned char fwidth[6]; // width/4
unsigned char fright[6]; // width/4
} frame_t;
int GetFileLength(const char *filename);
char *Alloc(int size);
void Free(void *ptr);
#define N_PATH_HOME 120
extern char path_home[N_PATH_HOME]; // this is the espeak-data directory
extern const char *version_string;
extern const int version_phdata;
extern void strncpy0(char *to,const char *from, int size);
int GetFileLength(const char *filename);
char *Alloc(int size);
void Free(void *ptr);
+10 -4
View File
@@ -29,13 +29,13 @@
#include "speak_lib.h"
#include "speech.h"
#include "voice.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "translate.h"
#include "wave.h"
const char *version_string = "1.28.04 15.Aug.07";
const char *version_string = "1.28.05 17.Aug.07";
const int version_phdata = 0x012801;
int option_device_number = -1;
@@ -125,7 +125,13 @@ int LoadPhData()
return(-1);
wavefile_data = (unsigned char *)spects_data;
version = *((unsigned int *)spects_data);
// read the version number from the first 4 bytes of phondata
version = 0;
for(ix=0; ix<4; ix++)
{
version += (wavefile_data[ix] << (ix*8));
}
if(version != version_phdata)
{
result = version;
@@ -635,7 +641,7 @@ void LoadConfig(void)
if(ix==2)
{
soundicon_tab[n_soundicon_tab].name = c1;
p = Alloc(strlen(string+1));
p = Alloc(strlen(string)+1);
strcpy(p,string);
soundicon_tab[n_soundicon_tab].filename = p;
soundicon_tab[n_soundicon_tab++].length = 0;
+1 -1
View File
@@ -28,9 +28,9 @@
#include "speak_lib.h"
#include "speech.h"
#include "voice.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "translate.h"
#define PITCHfall 0
+24
View File
@@ -65,6 +65,28 @@ extern int embedded_value[N_EMBEDDED_VALUES];
extern int embedded_default[N_EMBEDDED_VALUES];
#define N_PEAKS 9
#define N_MARKERS 8
typedef struct {
short pkfreq;
short pkheight;
short pkwidth;
short pkright;
} peak_t;
typedef struct {
short frflags;
unsigned char length;
unsigned char rms;
short ffreq[9];
unsigned char fheight[9];
unsigned char fwidth[6]; // width/4
unsigned char fright[6]; // width/4
} frame_t;
// formant data used by wavegen
typedef struct {
int freq; // Hz<<16
@@ -237,6 +259,8 @@ extern int event_list_ix;
extern espeak_EVENT *event_list;
extern t_espeak_callback* synth_callback;
extern int option_log_frames;
extern const char *version_string;
extern const int version_phdata;
#define N_SOUNDICON_TAB 100
extern int n_soundicon_tab;
+1 -1
View File
@@ -29,9 +29,9 @@
#include "speak_lib.h"
#include "speech.h"
#include "voice.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "translate.h"
#define WORD_STRESS_CHAR '*'
+1 -1
View File
@@ -25,9 +25,9 @@
#include "speak_lib.h"
#include "speech.h"
#include "phoneme.h"
#include "voice.h"
#include "main.h"
#include "synthesize.h"
#include "voice.h"
#include "translate.h"
#include "prosodydisplay.h"
+3
View File
@@ -21,8 +21,11 @@
#include "wx/wx.h"
#include "speak_lib.h"
#include "main.h"
#include "speech.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "spect.h"
#include "options.h"
+80 -54
View File
@@ -35,9 +35,9 @@
#endif
#include "speak_lib.h"
#include "voice.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "translate.h"
@@ -306,26 +306,6 @@ static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname, const char*lea
if(n_languages == 0)
{
#ifdef deleted
// Read voice variant files
// Don't use this, instead preset the variants_* arrays
// no language is specified, this voice file only affects the voice characteristics
if(memcmp(leafname,"!variant",8)==0)
{
if(((variant = atoi(&leafname[8])) > 0) && (strlen(variants_either) < N_VOICE_VARIANTS))
{
char string[2];
string[0] = variant;
string[1] = 0;
strcat(variants_either,string);
if(gender == 1)
strcat(variants_male,string);
if(gender == 2)
strcat(variants_female,string);
}
}
#endif
return(NULL); // no language lines in the voice file
}
@@ -442,11 +422,17 @@ static void VoiceFormant(char *p)
static voice_t *VoiceLookup(char *voicename)
{//=========================================
// Keep a cache of previously used voices.
int ix;
voice_t *v;
for(ix=0; ix < N_VOICES; ix++)
{
if((ix < n_voices_tab) && (strcmp(voices_tab[ix]->name,voicename)==0))
{
return(voices_tab[ix]); // found the entry for the specified voice name
}
if(ix == n_voices_tab)
{
// found a free slot
@@ -457,13 +443,8 @@ static voice_t *VoiceLookup(char *voicename)
strncpy0(v->name,voicename,sizeof(v->name));
return(v);
}
else
if(strcmp(voices_tab[ix]->name,voicename)==0)
{
return(voices_tab[ix]); // found the entry for the specified voice name
}
}
return(NULL); // table is full
return(voices_tab[0]); // table is full, reuse the first entry
} // end of VoiceLookup
@@ -640,6 +621,9 @@ voice_t *LoadVoice(const char *vname, int control)
break;
sscanf(p,"%s",language_name);
if(strcmp(language_name,"variant")==0)
break;
language_type = strtok(language_name,"-");
language_set = 1;
strcpy(translator_name,language_type);
@@ -908,24 +892,63 @@ voice_t *LoadVoice(const char *vname, int control)
} // end of LoadVoice
voice_t *LoadVoiceVariant(const char *vname, int variant)
{//======================================================
voice_t *v;
char *p;
char buf[40];
char *ExtractVoiceVariantName(char *vname, int variant_num)
{//========================================================
// Remove any voice variant suffix (name or number) from a voice name
// Returns the voice variant name
strcpy(buf,vname);
if((p = strchr(buf,'+')) != NULL)
char *p;
static char variant_name[20];
variant_name[0] = 0;
if((p = strchr(vname,'+')) != NULL)
{
// The voice name has a +variant suffix
*p = 0;
variant = atoi(p+1);
*p++ = 0; // delete the suffix from the voice name
if(isdigit(*p))
{
variant_num = atoi(p); // variant number
}
else
{
// voice variant name, not number
strcpy(variant_name,"!v/");
strncpy0(&variant_name[3],p,sizeof(variant_name)-3);
}
}
v = LoadVoice(buf,0);
if((v != NULL) && (variant > 0))
if(variant_num > 0)
{
sprintf(buf,"!varnt%d",variant); // changed from !variant1 to !varnt1 to avoid 8 char filenames on DOS
v = LoadVoice(buf,2);
if(variant_num < 10)
sprintf(variant_name,"!v/m%d",variant_num); // male
else
sprintf(variant_name,"!v/f%d",variant_num-10); // female
}
return(variant_name);
} // end of ExtractVoiceVariantName
voice_t *LoadVoiceVariant(const char *vname, int variant_num)
{//==========================================================
// Load a voice file.
// Also apply a voice variant if specified by "variant", or by "+number" or "+name" in the "vname"
voice_t *v;
char *variant_name;
char buf[60];
strncpy0(buf,vname,sizeof(buf));
variant_name = ExtractVoiceVariantName(buf,variant_num);
if((v = LoadVoice(buf,0)) == NULL)
return(NULL);
if(variant_name[0] != 0)
{
v = LoadVoice(variant_name,2);
}
return(v);
}
@@ -982,6 +1005,12 @@ static int ScoreVoice(espeak_VOICE *voice_spec, int spec_n_parts, int spec_lang_
}
else
{
if((*p == 0) && (strcmp(voice_spec->languages,"variants")==0))
{
// match on a voice with no languages if the required language is "variants"
score = 100;
}
// compare the required language with each of the languages of this voice
while(*p != 0)
{
@@ -1337,6 +1366,7 @@ void GetVoices(const char *path)
HANDLE hFind = INVALID_HANDLE_VALUE;
DWORD dwError;
#undef UNICODE // we need FindFirstFileA() which takes an 8-bit c-string
sprintf(fname,"%s\\*",path);
hFind = FindFirstFile(fname, &FindFileData);
if(hFind == INVALID_HANDLE_VALUE)
@@ -1420,21 +1450,14 @@ espeak_ERROR SetVoiceByName(const char *name)
{//=========================================
espeak_VOICE *v;
espeak_VOICE voice_selector;
int variant=0;
char *p;
char variant_name[20];
char *variant_name;
static char buf[60];
strncpy0(buf,name,sizeof(buf));
if((p = strchr(buf,'+')) != NULL)
{
// remove the voice variant suffix, from eg. en+3
*p = 0;
variant = atoi(p+1);
}
variant_name = ExtractVoiceVariantName(buf,0);
memset(&voice_selector,0,sizeof(voice_selector));
voice_selector.name = (char *)name;
voice_selector.name = buf;
// first check for a voice with this filename
// This may avoid the need to call espeak_ListVoices().
@@ -1443,10 +1466,8 @@ espeak_ERROR SetVoiceByName(const char *name)
{
voice_selected = first_voice;
if(variant > 0)
if(variant_name[0] != 0)
{
// apply a voice variant
sprintf(variant_name,"!varnt%d",variant);
LoadVoice(variant_name,2);
}
@@ -1460,9 +1481,14 @@ espeak_ERROR SetVoiceByName(const char *name)
if((v = SelectVoiceByName(voices_list,buf)) != NULL)
{
if(LoadVoiceVariant(v->identifier,variant) != NULL)
if(LoadVoice(v->identifier,0) != NULL)
{
voice_selected = v;
if(variant_name[0] != 0)
{
LoadVoice(variant_name,2);
}
WavegenSetVoice(voice);
SetVoiceStack(&voice_selector);
return(EE_OK);
+2 -2
View File
@@ -30,10 +30,10 @@
#include "speak_lib.h"
#include "main.h"
#include "speech.h"
#include "voice.h"
#include "spect.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#include "spect.h"
#include "translate.h"
#include "options.h"
+1 -1
View File
@@ -30,9 +30,9 @@
#include "speak_lib.h"
#include "speech.h"
#include "voice.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
#ifdef USE_PORTAUDIO
#include "portaudio.h"