[1.27.07] Fixed crash when espeak_Initialize() is called after espeak_Terminate()

espeakedit: setlocale(LC_NUMERIC,"C") before opening spectrum.dat file.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@62 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2007-07-09 11:08:12 +00:00
parent f3a4623535
commit 0c3b856173
20 changed files with 222 additions and 103 deletions
+45
View File
@@ -1164,6 +1164,50 @@ int x;
}
#endif
#define OUTPUT_MODE AUDIO_OUTPUT_PLAYBACK
#define TEXT "Hello world."
#define TEXT_SSML ("<speak>" TEXT "</speak>")
static void
speak(char *text)
{
int result;
result = espeak_Synth(text, strlen(text) + 1, 0, POS_CHARACTER, 0, espeakSSML, NULL, NULL);
assert(result == EE_OK);
}
int test4() {
espeak_ERROR result;
int sample_rate;
sample_rate = espeak_Initialize(OUTPUT_MODE, 2000, NULL, 0);
assert(sample_rate != EE_INTERNAL_ERROR);
espeak_SetSynthCallback(synth_callback);
espeak_VOICE voice;
memset(&voice, 0, sizeof(espeak_VOICE));
voice.languages = "en";
//voice.gender = 2;
voice.age = 4;
result = espeak_SetVoiceByProperties(&voice);
assert(result == EE_OK);
speak(TEXT_SSML);
speak(TEXT_SSML);
espeak_Synchronize();
#ifdef deleted
/* Now the same ting without ssml tags. */
result = espeak_SetVoiceByProperties(&voice);
assert(result == EE_OK);
speak(TEXT);
speak(TEXT);
espeak_Synchronize();
#endif
result = espeak_Terminate();
assert(result == EE_OK);
return 0;
}
char* text1 = "Hello World2. <audio src=\"here\"> Some text</audio> This is the second sentence";
@@ -1181,6 +1225,7 @@ void TestTest(int control)
//CharsetToUnicode("ISO-8859-4");
//CharsetToUnicode("ISCII");
test4();
return;
if(control==2)
+23 -1
View File
@@ -921,6 +921,26 @@ int AddNameData(const char *name, int wide)
} // end of AddNameData
void SetVoiceStack(espeak_VOICE *v)
{//================================
SSML_STACK *sp;
sp = &ssml_stack[0];
if(v == NULL)
{
memset(sp,0,sizeof(ssml_stack[0]));
return;
}
if(v->languages != NULL)
strcpy(sp->language,v->languages);
if(v->name != NULL)
strcpy(sp->voice_name,v->name);
sp->voice_variant = v->variant;
sp->voice_age = v->age;
sp->voice_gender = v->gender;
}
static int GetVoiceAttributes(wchar_t *pw, int tag_type)
{//=====================================================
// Determines whether voice attribute are specified in this tag, and if so, whether this means
@@ -1367,7 +1387,7 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int &outix, int n_outb
return(CLAUSE_VOICE);
case SSML_SPEAK + SSML_CLOSE:
terminator = CLAUSE_PARAGRAPH;
terminator = CLAUSE_PERIOD;
case SSML_VOICE + SSML_CLOSE:
// unwind stack until the previous <voice> or <speak> tag
while((n_ssml_stack > 1) && (ssml_stack[n_ssml_stack-1].tag_type != (tag_type - SSML_CLOSE)))
@@ -1853,6 +1873,7 @@ void InitText2(void)
option_punctuation = speech_parameters[espeakPUNCTUATION];
option_capitals = speech_parameters[espeakCAPITALS];
//#ifdef deleted
pvoice = espeak_GetCurrentVoice();
ssml_sp = &ssml_stack[0];
@@ -1865,6 +1886,7 @@ void InitText2(void)
strncpy0(ssml_sp->voice_name,pvoice->name,sizeof(ssml_sp->voice_name));
strncpy0(ssml_sp->language,&pvoice->languages[1],sizeof(ssml_sp->language));
}
//#endif
current_voice_id[0] = 0;
n_param_stack = 1;
+1
View File
@@ -288,6 +288,7 @@ static int initialise(void)
#ifndef PLATFORM_WINDOWS
LoadConfig(); // causes problem on Windows, don't know why
#endif
SetVoiceStack(NULL);
SynthesizeInit();
for(param=0; param<N_SPEECH_PARAM; param++)
+1
View File
@@ -349,6 +349,7 @@ static int initialise(void)
}
voice_selected = NULL;
SetVoiceStack(NULL);
SynthesizeInit();
InitNamedata();
+1
View File
@@ -426,6 +426,7 @@ int initialise(void)
WavegenInit(22050,0);
LoadPhData();
SetVoiceStack(NULL);
SynthesizeInit();
return(0);
}
+2
View File
@@ -951,6 +951,8 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
}
wxFileName path = wxFileName(filename);
leaf = path.GetName();
setlocale(LC_NUMERIC,"C"); // read numbers in the form 1.23456
spectseq->Load(stream);
spectseq->name = leaf;
spectseq->MakePitchenv(spectseq->pitchenv);
+4 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.27.06 07.Jul.07";
const char *version_string = "1.27.07 09.Jul.07";
const int version_phdata = 0x012701;
int option_device_number = -1;
@@ -160,6 +160,9 @@ void FreePhData(void)
Free(phoneme_tab_data);
Free(phoneme_index);
Free(spects_data);
phoneme_tab_data=NULL;
phoneme_index=NULL;
spects_data=NULL;
}
+1
View File
@@ -526,5 +526,6 @@ void InitText2(void);
int IsDigit(unsigned int c);
int IsAlpha(unsigned int c);
int isspace2(unsigned int c);
void SetVoiceStack(espeak_VOICE *v);
extern FILE *f_trans; // for logging
+14 -2
View File
@@ -1189,6 +1189,7 @@ static espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name)
espeak_VOICE *SelectVoice(espeak_VOICE *voice_select, int *variant)
{//================================================================
// Returns a path within espeak-voices, with a possible +variant suffix
// variant is an output-only parameter
int nv; // number of candidates
int ix, ix2;
int j;
@@ -1382,6 +1383,7 @@ void GetVoices(const char *path)
espeak_ERROR SetVoiceByName(const char *name)
{//=========================================
espeak_VOICE *v;
espeak_VOICE voice_selector;
int variant=0;
char *p;
char variant_name[20];
@@ -1395,7 +1397,13 @@ espeak_ERROR SetVoiceByName(const char *name)
variant = atoi(p+1);
}
memset(&voice_selector,0,sizeof(voice_selector));
voice_selector.variant = variant;
voice_selector.name = (char *)name;
// first check for a voice with this filename
// This may avoid the need to call espeak_ListVoices().
if((first_voice == NULL) && (LoadVoice(buf,1) != NULL))
{
voice_selected = first_voice;
@@ -1408,6 +1416,7 @@ espeak_ERROR SetVoiceByName(const char *name)
}
WavegenSetVoice(voice);
SetVoiceStack(&voice_selector);
return(EE_OK);
}
@@ -1420,11 +1429,12 @@ espeak_ERROR SetVoiceByName(const char *name)
{
voice_selected = v;
WavegenSetVoice(voice);
SetVoiceStack(&voice_selector);
return(EE_OK);
}
}
return(EE_INTERNAL_ERROR); // voice name not found
} // end of espeak_SetVoiceByName
} // end of SetVoiceByName
@@ -1436,8 +1446,10 @@ espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector)
LoadVoiceVariant(voice_selected->identifier,variant);
WavegenSetVoice(voice);
SetVoiceStack(voice_selector);
return(EE_OK);
} // end of espeak_SetVoiceByProperties
} // end of SetVoiceByProperties