Add callback event: espeakEVENT_PHONEME git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@39 d46cf337-b52f-0410-862d-fd96e6ae7743master
@@ -418,7 +418,7 @@ int main (int argc, char **argv) | |||
break; | |||
case 0x104: // --voices | |||
espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,0,NULL); | |||
espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,0,NULL,0); | |||
DisplayVoices(stdout,optarg); | |||
exit(0); | |||
@@ -431,7 +431,7 @@ int main (int argc, char **argv) | |||
if(option_waveout || quiet) | |||
{ | |||
// writing to a file (or no output), we can use synchronous mode | |||
samplerate = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,0,NULL); | |||
samplerate = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,0,NULL,0); | |||
espeak_SetSynthCallback(SynthCallback); | |||
if(option_waveout) | |||
@@ -443,7 +443,7 @@ int main (int argc, char **argv) | |||
else | |||
{ | |||
// play the sound output | |||
samplerate = espeak_Initialize(AUDIO_OUTPUT_PLAYBACK,0,NULL); | |||
samplerate = espeak_Initialize(AUDIO_OUTPUT_PLAYBACK,0,NULL,0); | |||
} | |||
@@ -121,6 +121,7 @@ int TestSynthCallback(short *wav, int numsamples, espeak_EVENT *events) | |||
{//==================================================================== | |||
int type; | |||
fprintf(f_events,"--\n"); | |||
if(f_wavtest == NULL) return(0); | |||
if(wav == NULL) | |||
@@ -137,6 +138,9 @@ fprintf(f_events,"Finished\n"); | |||
fprintf(f_events,"%5d %4d (%2d) %d ",events->audio_position,events->text_position,events->length,type); | |||
if((type==3) || (type==4)) | |||
fprintf(f_events,"'%s'\n",events->id.name); | |||
else | |||
if(type==espeakEVENT_PHONEME) | |||
fprintf(f_events,"[%s]\n",WordToString(events->id.number)); | |||
else | |||
fprintf(f_events,"%d\n",events->id.number); | |||
@@ -1105,7 +1109,7 @@ void Test3() | |||
espeak_VOICE *newvoice; | |||
int x; | |||
espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,100,NULL); | |||
espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,100,NULL,0); | |||
memset(&voicespec,0,sizeof(voicespec)); | |||
voicespec.languages = "de"; | |||
espeak_SetVoiceByProperties(&voicespec); | |||
@@ -1161,7 +1165,7 @@ if(control==2) | |||
f_events = fopen("/home/jsd1/speechdata/text/events","w"); | |||
fprintf(f_events,"Audio Text Length Type Id\n"); | |||
espeak_Initialize(AUDIO_OUTPUT_SYNCH_PLAYBACK,0,NULL); | |||
espeak_Initialize(AUDIO_OUTPUT_RETRIEVAL,0,NULL,1); | |||
espeak_SetSynthCallback(TestSynthCallback); | |||
unsigned int unique_identifier=0; |
@@ -635,8 +635,8 @@ ESPEAK_API void espeak_SetUriCallback(int (* UriCallback)(int, const char*, cons | |||
uri_callback = UriCallback; | |||
} | |||
ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output_type, int buf_length, const char *path) | |||
{//================================================================================================ | |||
ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output_type, int buf_length, const char *path, int options) | |||
{//============================================================================================================= | |||
ENTER("espeak_Initialize"); | |||
int param; | |||
@@ -665,13 +665,14 @@ ENTER("espeak_Initialize"); | |||
if((out_start = outbuf) == NULL) | |||
return(EE_INTERNAL_ERROR); | |||
// allocate space for event list. Allow 500 events per minute | |||
n_event_list = (buf_length*500)/1000; | |||
// allocate space for event list. Allow 200 events per second | |||
n_event_list = (buf_length*200)/1000; | |||
if((event_list = (espeak_EVENT *)realloc(event_list,sizeof(espeak_EVENT) * n_event_list)) == NULL) | |||
return(EE_INTERNAL_ERROR); | |||
option_phonemes = 0; | |||
option_phoneme_events = (options & 1); | |||
SetVoiceByName("default"); | |||
for(param=0; param<N_SPEECH_PARAM; param++) |
@@ -40,7 +40,8 @@ typedef enum { | |||
espeakEVENT_MARK, // Mark | |||
espeakEVENT_PLAY, // Audio element | |||
espeakEVENT_END, // End of sentence | |||
espeakEVENT_MSG_TERMINATED // End of message | |||
espeakEVENT_MSG_TERMINATED, // End of message | |||
espeakEVENT_PHONEME // Phoneme, if enabled in espeak_Initialize() | |||
} espeak_EVENT_TYPE; | |||
@@ -54,7 +55,7 @@ typedef struct { | |||
int sample; // sample id (internal use) | |||
void* user_data; // pointer supplied by the calling program | |||
union { | |||
int number; // used for WORD and SENTENCE events | |||
int number; // used for WORD and SENTENCE events. For PHONEME events this is the phoneme mnemonic. | |||
const char *name; // used for MARK and PLAY events. UTF8 string | |||
} id; | |||
} espeak_EVENT; | |||
@@ -137,7 +138,7 @@ typedef enum { | |||
#ifdef __cplusplus | |||
extern "C" | |||
#endif | |||
int espeak_Initialize(espeak_AUDIO_OUTPUT output, int buflength, const char *path); | |||
int espeak_Initialize(espeak_AUDIO_OUTPUT output, int buflength, const char *path, int options); | |||
/* Must be called before any synthesis functions are called. | |||
output: the audio data can either be played by eSpeak or passed back by the SynthCallback function. | |||
@@ -145,6 +146,9 @@ int espeak_Initialize(espeak_AUDIO_OUTPUT output, int buflength, const char *pat | |||
path: The directory which contains the espeak-data directory, or NULL for the default location. | |||
options: bit 0: 1=allow espeakEVENT_PHONEME events. | |||
Returns: sample rate in Hz, or -1 (EE_INTERNAL_ERROR). | |||
*/ | |||
@@ -35,7 +35,7 @@ | |||
#include "translate.h" | |||
#include "wave.h" | |||
const char *version_string = "1.26 09.Jun.07"; | |||
const char *version_string = "1.26.01 09.Jun.07"; | |||
const int version_phdata = 0x012601; | |||
int option_device_number = -1; |
@@ -1101,7 +1101,11 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume) | |||
if(p->prepause > 0) | |||
DoPause(p->prepause); | |||
// printf("phoneme [%s]\n",WordToString(p->ph->mnemonic)); | |||
if(option_phoneme_events) | |||
{ | |||
DoMarker(espeakEVENT_PHONEME, (p->sourceix & 0x7ff) + clause_start_char, 0, p->ph->mnemonic); | |||
} | |||
switch(p->type) | |||
{ | |||
case phPAUSE: |
@@ -45,6 +45,7 @@ FILE *f_trans = NULL; // phoneme output text | |||
int option_tone1 = 0; | |||
int option_tone2 = 0; | |||
int option_phonemes = 0; | |||
int option_phoneme_events = 0; | |||
int option_quiet = 0; | |||
int option_endpause = 0; // suppress pause after end of text | |||
int option_capitals = 0; |
@@ -448,6 +448,7 @@ extern int option_tone2; | |||
extern int option_waveout; | |||
extern int option_quiet; | |||
extern int option_phonemes; | |||
extern int option_phoneme_events; | |||
extern int option_linelength; // treat lines shorter than this as end-of-clause | |||
extern int option_harmonic1; | |||
extern int option_multibyte; |