bool stardict_tts_plugin_init(StarDictTtsPlugInObject *obj) { festival_initialize(1, 210000); std::string res = get_cfg_filename(); if (!g_file_test(res.c_str(), G_FILE_TEST_EXISTS)) { g_file_set_contents(res.c_str(), "[festival]\nvoice=\n", -1, NULL); } GKeyFile *keyfile = g_key_file_new(); g_key_file_load_from_file(keyfile, res.c_str(), G_KEY_FILE_NONE, NULL); gchar *str = g_key_file_get_string(keyfile, "festival", "voice", NULL); g_key_file_free(keyfile); if (str) { voice_engine = str; g_free(str); } if (!voice_engine.empty()) { std::string command = "("; command += voice_engine; command += ")"; festival_eval_command(command.c_str()); } obj->saytext_func = saytext; obj->tts_name = _("Festival TTS"); g_print(_("Festival plug-in loaded.\n")); return false; }
static void on_tts_combobox_changed(GtkComboBox *widget, gpointer data) { gint index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); if (index == 1) voice_engine = "voice_kal_diphone"; else if (index == 2) voice_engine = "voice_ked_diphone"; else if (index == 3) voice_engine = "voice_cmu_us_jmk_arctic_hts"; else if (index == 4) voice_engine = "voice_cmu_us_bdl_arctic_hts"; else if (index == 5) voice_engine = "voice_cmu_us_awb_arctic_hts"; else if (index == 6) voice_engine = "voice_cmu_us_slt_arctic_hts"; else voice_engine.clear(); if (!voice_engine.empty()) { std::string command = "("; command += voice_engine; command += ")"; festival_eval_command(command.c_str()); } gchar *data1 = g_strdup_printf("[festival]\nvoice=%s\n", voice_engine.c_str()); std::string res = get_cfg_filename(); g_file_set_contents(res.c_str(), data1, -1, NULL); g_free(data1); }
int main(void) { EST_Wave wave; int heap_size = 210000; // default scheme heap size int load_init_files = 1; // we want the festival init files loaded festival_initialize(load_init_files,heap_size); //festival_say_file("/etc/issue.text"); //festival_eval_command("(voice_msu_ru_nsh_clunits)"); //festival_say_text("а"); festival_eval_command("(voice_ked_diphone)"); festival_say_text("privet, suchka. blyahui"); festival_text_to_wave("hello world",wave); wave.save("/tmp/wave.wav","riff"); // festival_say_file puts the system in async mode so we better // wait for the spooler to reach the last waveform before exiting // This isn't necessary if only festival_say_text is being used (and // your own wave playing stuff) festival_wait_for_spooler(); return 0; }
// Ejecuta un comando Festival después de formatearlo al estilo de // printf. // Entradas: // - format: formato del comando (igual que en printf) // - ...: (Opcional): variables para sustituir en el formato. void run_command(const char *format, ...) { char *command=new char[COMMAND_LENGTH]; va_list ap; va_start(ap, format); vsprintf(command, format, ap); va_end(ap); festival_eval_command(command); delete[] command; }
/** Select a voice to use for the output * @param voicename * the name of the voice to use * @return 0 on success, -1 otherwise */ int tts_select_voice(const char *voicename) { char voice_selection[64]; int res; if (!festival_initialized) { tts_init(); } sprintf(voice_selection, "(%s)", voicename); res = festival_eval_command((EST_String)voice_selection); voice_selected = true; return res; }
extern void voice_init() { int heap_size = 2100000; int load_init_files = 1; voice_volume_set(); festival_initialize(load_init_files, heap_size); // put system into async mode festival_eval_command("(audio_mode 'async)"); festival_say_text("Hello my name is ClaraBell"); // fprintf(stderr, "Voice subsystem initialized\n"); }
SpeechSynch::SpeechSynch() { festival_initialize(1,210000); // This must be called before any other festival functions may be called. It sets up the //synthesizer system. The first argument if true, causes the system set up files to be loaded //(which is normallly what is necessary), the second argument is the initial size of the Scheme heap, //this should normally be 210000 unless you envisage processing very large Lisp structures. festival_eval_command("(voice_el_diphone)"); festival_say_text("Welcome to Flying Object Madness"); // // festival_wait_for_spooler(); setTrigger(Message::MSG_COL_PLAYER_LETTER); // Say some text; // festival_say_text("hello world"); }
// Sintetiza y reproduce en español el mensaje pasado como argumento // Entradas: // - text: texto a sintetizar void say_text(const char *text) { festival_eval_command("(voice_el_diphone)"); // voz en español festival_say_text(text); //festival_wait_for_spooler(); // bloquear ejecución hasta que acabe de decirlo }
int TTS::evalCommand(const char *expr) { EST_String str(expr); return festival_eval_command(str); }
void FestivalSynthesizer::initFestival() { int heap_size = 210000; // default scheme heap size int load_init_files = 1; // we want the festival init files loaded festival_initialize(load_init_files, heap_size); try { const char* cfgFilename = "../config.cfg"; Config cfg(cfgFilename); std::string voice = cfg.get("Voice"); if ( voice == "female" ) { festival_eval_command( "(voice_us1_mbrola)" ); festival_eval_command( "(defvar Styles '((default 140 22 1.0)) \"Available voice styles\")" ); festival_eval_command( "(defvar style_default 'default \"Default voice style\")" ); festival_eval_command( "(defvar current_style 'none \"Current voice style\")" ); festival_eval_command( "(define (Style selected_style) (let ((style (assoc selected_style Styles)))" "(if (not style) (set! style (assoc 'default Styles)))" "(let ((model_mean (cadr (assoc 'model_f0_mean int_lr_params)))" "(model_std (cadr (assoc 'model_f0_std int_lr_params)))" "(new_mean (cadr style)) (new_std (cadr (cdr style)))" "(new_stretch (cadr (cdr (cdr style)))))" "(set! int_lr_params (list (list 'target_f0_mean new_mean)" "(list 'target_f0_std new_std) (list 'model_f0_mean model_mean)" "(list 'model_f0_std model_std)))" "(Parameter.set 'Duration_Stretch new_stretch)" "(set! current_style (car style)) (list (car style) new_mean new_std new_stretch) ) ) )" ); festival_eval_command( "(define (NewStyle style_name mean std stretch)" "(set! Styles (cons (list style_name mean std stretch) Styles)))" ); festival_eval_command( "(NewStyle 'lisa 280 50 1.2)" ); festival_eval_command( "(Style 'lisa)" ); } } catch(const std::exception& e) { std::cerr << e.what() << std::endl; } // Check sampling rate EST_Wave wave; festival_text_to_wave( "init", wave ); // Init pulse audio pa_sample_spec sample_spec; sample_spec.format = PA_SAMPLE_S16NE; sample_spec.channels = 1; sample_spec.rate = wave.sample_rate(); pa_simple_ = pa_simple_new( NULL, // Use the default server. "FestivalSynthesizer", // Our application's name. PA_STREAM_PLAYBACK, // Playback stream. NULL, // Use the default device. "Festival Synthesizer (TalkingHead)", // Description of our stream. &sample_spec, // Our sample format. NULL, // Use default channel map NULL, // Use default buffering attributes. NULL // Ignore error code. ); if ( !pa_simple_ ) { ROS_ERROR ( "Error initializing PulseAudio!" ); } }
static void configure() { GtkWidget *window = gtk_dialog_new_with_buttons(_("Festival TTS configuration"), GTK_WINDOW(plugin_info->pluginwin), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); GtkWidget *hbox = gtk_hbox_new(false, 5); GtkWidget *label = gtk_label_new(_("Voice type:")); gtk_box_pack_start(GTK_BOX(hbox), label, false, false, 0); GtkWidget *combobox = gtk_combo_box_new_text(); gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), _("Default")); gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), "Male1-kal"); gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), "Male2-ked"); gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), "Male3-jmk"); gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), "Male4-bdl"); gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), "Male5-awb"); gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), "Female1-slt"); gint old_index; if (voice_engine == "voice_kal_diphone") old_index = 1; else if (voice_engine == "voice_ked_diphone") old_index = 2; else if (voice_engine == "voice_cmu_us_jmk_arctic_hts") old_index = 3; else if (voice_engine == "voice_cmu_us_bdl_arctic_hts") old_index = 4; else if (voice_engine == "voice_cmu_us_awb_arctic_hts") old_index = 5; else if (voice_engine == "voice_cmu_us_slt_arctic_hts") old_index = 6; else old_index = 0; gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), old_index); gtk_box_pack_start(GTK_BOX(hbox), combobox, false, false, 0); gtk_widget_show_all(hbox); gtk_container_add (GTK_CONTAINER (GTK_DIALOG(window)->vbox), hbox); gtk_dialog_run(GTK_DIALOG(window)); gint index = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox)); if (index != old_index) { if (index == 1) voice_engine = "voice_kal_diphone"; else if (index == 2) voice_engine = "voice_ked_diphone"; else if (index == 3) voice_engine = "voice_cmu_us_jmk_arctic_hts"; else if (index == 4) voice_engine = "voice_cmu_us_bdl_arctic_hts"; else if (index == 5) voice_engine = "voice_cmu_us_awb_arctic_hts"; else if (index == 6) voice_engine = "voice_cmu_us_slt_arctic_hts"; else voice_engine.clear(); if (!voice_engine.empty()) { std::string command = "("; command += voice_engine; command += ")"; festival_eval_command(command.c_str()); } gchar *data = g_strdup_printf("[festival]\nvoice=%s\n", voice_engine.c_str()); std::string res = get_cfg_filename(); g_file_set_contents(res.c_str(), data, -1, NULL); g_free(data); } gtk_widget_destroy (window); }