ESPEAK_NG_API espeak_ng_STATUS espeak_ng_Synthesize(const void *text, size_t size, unsigned int position, espeak_POSITION_TYPE position_type, unsigned int end_position, unsigned int flags, unsigned int *unique_identifier, void *user_data) { (void)size; // unused in non-async modes static unsigned int temp_identifier; if (unique_identifier == NULL) unique_identifier = &temp_identifier; *unique_identifier = 0; if (my_mode & ENOUTPUT_MODE_SYNCHRONOUS) return sync_espeak_Synth(0, text, position, position_type, end_position, flags, user_data); #ifdef USE_ASYNC // Create the text command t_espeak_command *c1 = create_espeak_text(text, size, position, position_type, end_position, flags, user_data); if (c1) { // Retrieve the unique identifier *unique_identifier = c1->u.my_text.unique_identifier; } // Create the "terminated msg" command (same uid) t_espeak_command *c2 = create_espeak_terminated_msg(*unique_identifier, user_data); // Try to add these 2 commands (single transaction) if (c1 && c2) { espeak_ng_STATUS status = fifo_add_commands(c1, c2); if (status != ENS_OK) { delete_espeak_command(c1); delete_espeak_command(c2); } return status; } delete_espeak_command(c1); delete_espeak_command(c2); return ENOMEM; #else return sync_espeak_Synth(0, text, position, position_type, end_position, flags, user_data); #endif }
ESPEAK_API espeak_ERROR espeak_Synth(const void *text, size_t size, unsigned int position, espeak_POSITION_TYPE position_type, unsigned int end_position, unsigned int flags, unsigned int* unique_identifier, void* user_data) {//===================================================================================== #ifdef DEBUG_ENABLED ENTER("espeak_Synth"); SHOW("espeak_Synth > position=%d, position_type=%d, end_position=%d, flags=%d, user_data=0x%x, text=%s\n", position, position_type, end_position, flags, user_data, text); #endif espeak_ERROR a_error=EE_INTERNAL_ERROR; static unsigned int temp_identifier; if (unique_identifier == NULL) { unique_identifier = &temp_identifier; } *unique_identifier = 0; if(synchronous_mode) { return(sync_espeak_Synth(0,text,size,position,position_type,end_position,flags,user_data)); } #ifdef USE_ASYNC // Create the text command t_espeak_command* c1 = create_espeak_text(text, size, position, position_type, end_position, flags, user_data); // Retrieve the unique identifier *unique_identifier = c1->u.my_text.unique_identifier; // Create the "terminated msg" command (same uid) t_espeak_command* c2 = create_espeak_terminated_msg(*unique_identifier, user_data); // Try to add these 2 commands (single transaction) if (c1 && c2) { a_error = fifo_add_commands(c1, c2); if (a_error != EE_OK) { delete_espeak_command(c1); delete_espeak_command(c2); c1=c2=NULL; } } else { delete_espeak_command(c1); delete_espeak_command(c2); } #endif return a_error; } // end of espeak_Synth
//> //< process_espeak_command void process_espeak_command( t_espeak_command* the_command) { ENTER("process_espeak_command"); SHOW("command=0x%x\n", the_command); if (the_command == NULL) { return; } the_command->state = CS_PROCESSED; switch(the_command->type) { case ET_TEXT: { t_espeak_text* data = &(the_command->u.my_text); sync_espeak_Synth( data->unique_identifier, data->text, data->size, data->position, data->position_type, data->end_position, data->flags, data->user_data); } break; case ET_MARK: { t_espeak_mark* data = &(the_command->u.my_mark); sync_espeak_Synth_Mark( data->unique_identifier, data->text, data->size, data->index_mark, data->end_position, data->flags, data->user_data); } break; case ET_TERMINATED_MSG: { t_espeak_terminated_msg* data = &(the_command->u.my_terminated_msg); sync_espeak_terminated_msg( data->unique_identifier, data->user_data); } break; case ET_KEY: { const char* data = the_command->u.my_key.key_name; sync_espeak_Key(data); } break; case ET_CHAR: { const wchar_t data = the_command->u.my_char.character; sync_espeak_Char( data); } break; case ET_PARAMETER: { t_espeak_parameter* data = &(the_command->u.my_param); SetParameter( data->parameter, data->value, data->relative); } break; case ET_PUNCTUATION_LIST: { const wchar_t* data = the_command->u.my_punctuation_list; sync_espeak_SetPunctuationList( data); } break; case ET_VOICE_NAME: { const char* data = the_command->u.my_voice_name; SetVoiceByName( data); } break; case ET_VOICE_SPEC: { espeak_VOICE* data = &(the_command->u.my_voice_spec); SetVoiceByProperties(data); } break; default: assert(0); break; } }