/********************** Main Program **********************/ int main(int argc, char **argv) { INIT_CAVEMAN(bob); INIT_CAVEMAN(bub); GET_ARGS(argc, argv); GET_SHARPNESS(bub); GET_SHARPNESS(bob); CLEAN_UP(); return 0; }
void *_festival_speak(void *nothing) { int ret; int bytes; int wave_cached; FT_Wave *fwave; int debug_count = 0; int r; int terminate = 0; char *callback; log_msg(OTTS_LOG_INFO, "festival: speaking thread starting.......\n"); cache_init(); set_speaking_thread_parameters(); while (1) { sem_wait: sem_wait(festival_semaphore); log_msg(OTTS_LOG_DEBUG, "Semaphore on, speaking\n"); opentts_audio_set_volume(module_audio_id, festival_volume); festival_stopped = 0; festival_speaking = 1; wave_cached = 0; fwave = NULL; terminate = 0; bytes = strlen(*festival_message); module_report_event_begin(); log_msg(OTTS_LOG_INFO, "Going to synthesize: |%s|", *festival_message); if (bytes > 0) { if (!is_text(festival_message_type)) { /* it is a raw text */ log_msg(OTTS_LOG_INFO, "Cache mechanisms..."); fwave = cache_lookup(*festival_message, festival_message_type, 1); if (fwave != NULL) { wave_cached = 1; if (fwave->num_samples != 0) { if (FestivalDebugSaveOutput) { char filename_debug [256]; sprintf(filename_debug, "/tmp/debug-festival-%d.snd", debug_count++); save_FT_Wave_snd(fwave, filename_debug); } festival_send_to_audio(fwave); if (!festival_stopped) { CLEAN_UP(0, module_report_event_end); } else { CLEAN_UP(0, module_report_event_stop); } } else { CLEAN_UP(0, module_report_event_end); } } } /* Set multi-mode for appropriate kind of events */ if (is_text(festival_message_type)) { /* it is a raw text */ ret = FestivalSetMultiMode(festival_info, "t"); if (ret != 0) CLP(0, module_report_event_stop); } else { /* it is some kind of event */ ret = FestivalSetMultiMode(festival_info, "nil"); if (ret != 0) CLP(0, module_report_event_stop); } switch (festival_message_type) { case SPD_MSGTYPE_TEXT: r = festivalStringToWaveRequest(festival_info, *festival_message); break; case SPD_MSGTYPE_SOUND_ICON: r = festivalSoundIcon(festival_info, *festival_message); break; case SPD_MSGTYPE_CHAR: r = festivalCharacter(festival_info, *festival_message); break; case SPD_MSGTYPE_KEY: r = festivalKey(festival_info, *festival_message); break; case SPD_MSGTYPE_SPELL: r = festivalSpell(festival_info, *festival_message); break; default: r = -1; } if (r < 0) { log_msg(OTTS_LOG_WARN, "Couldn't process the request to say the object."); CLP(0, module_report_event_stop); } } while (1) { wave_cached = 0; log_msg(OTTS_LOG_INFO, "Retrieving data\n"); /* (speechd-next) */ if (is_text(festival_message_type)) { if (festival_stopped) { log_msg(OTTS_LOG_INFO, "Module stopped 1"); CLEAN_UP(0, module_report_event_stop); } log_msg(OTTS_LOG_INFO, "Getting data in multi mode"); fwave = festivalGetDataMulti(festival_info, &callback, &festival_stop_request, FestivalReopenSocket); if (callback != NULL) { if ((festival_pause_requested) && (!strncmp (callback, INDEX_MARK_BODY, INDEX_MARK_BODY_LEN))) { log_msg(OTTS_LOG_NOTICE, "Pause requested, pausing."); module_report_index_mark (callback); g_free(callback); festival_pause_requested = 0; CLEAN_UP(0, module_report_event_pause); } else { module_report_index_mark (callback); g_free(callback); continue; } } } else { /* is event */ log_msg(OTTS_LOG_INFO, "Getting data in single mode"); fwave = festivalStringToWaveGetData(festival_info); terminate = 1; callback = NULL; } if (fwave == NULL) { log_msg(OTTS_LOG_INFO, "End of sound samples, terminating this message..."); CLEAN_UP(0, module_report_event_end); } if (festival_message_type == SPD_MSGTYPE_CHAR || festival_message_type == SPD_MSGTYPE_KEY || festival_message_type == SPD_MSGTYPE_SOUND_ICON) { log_msg(OTTS_LOG_DEBUG, "Storing record for %s in cache\n", *festival_message); /* cache_insert takes care of not inserting the same message again */ cache_insert(g_strdup(*festival_message), festival_message_type, fwave); wave_cached = 1; } if (festival_stopped) { log_msg(OTTS_LOG_NOTICE, "Module stopped 2"); CLEAN_UP(0, module_report_event_stop); } if (fwave->num_samples != 0) { log_msg(OTTS_LOG_INFO, "Sending message to audio: %ld bytes\n", (fwave->num_samples) * sizeof(short)); if (FestivalDebugSaveOutput) { char filename_debug[256]; sprintf(filename_debug, "/tmp/debug-festival-%d.snd", debug_count++); save_FT_Wave_snd(fwave, filename_debug); } log_msg(OTTS_LOG_INFO, "Playing sound samples"); festival_send_to_audio(fwave); if (!wave_cached) delete_FT_Wave(fwave); log_msg(OTTS_LOG_NOTICE, "End of playing sound samples"); } if (terminate) { log_msg(OTTS_LOG_INFO, "Ok, end of samples, returning"); CLP(0, module_report_event_end); } if (festival_stopped) { log_msg(OTTS_LOG_NOTICE, "Module stopped 3"); CLP(0, module_report_event_stop); } } } festival_stopped = 0; festival_speaking = 0; log_msg(OTTS_LOG_INFO, "festival: speaking thread ended.......\n"); pthread_exit(NULL); }