From fe9564dc2722c933c4311de6bfa1c7e7ba2d39a4 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Thu, 20 Sep 2007 09:22:56 +0300 Subject: [PATCH] Init gst if enabled. Init speach only if both gst and espeak is enabled. Use voice speed and pitch settings. Add voice name as an option to speak_init() --- src/mapper.c | 6 ++++-- src/speak.c | 18 +++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/mapper.c b/src/mapper.c index 9d96ae9..b956eb8 100644 --- a/src/mapper.c +++ b/src/mapper.c @@ -218,9 +218,8 @@ g_type_init(); if (mapper_osso_init()!=0) return 1; set_var_defaults(); -#if defined (WITH_GST) && defined (WITH_ESPEAK) +#if defined (WITH_GST) gst_init(&argc, &argv); -speak_init(120,50); #endif gtk_init(&argc, &argv); gconf_init(argc, argv, NULL); @@ -231,6 +230,9 @@ gpx_init(); mapper_init(argc, argv); if (mapper_osso_cb_init()!=0) return 1; +#if defined (WITH_GST) && defined (WITH_ESPEAK) +speak_init("en",_voice_speed,_voice_pitch); +#endif gtk_main(); mapper_destroy(); #if defined (WITH_GST) && defined (WITH_ESPEAK) diff --git a/src/speak.c b/src/speak.c index aa2a77c..772fce4 100644 --- a/src/speak.c +++ b/src/speak.c @@ -27,7 +27,6 @@ struct _gst_espeak { GstElement *src; GstElement *queue; GstElement *caps; - GstElement *conv; GstElement *sink; gboolean done; gshort *buffer; @@ -88,10 +87,16 @@ ge.srccaps=gst_caps_new_simple ("audio/x-raw-int", "channels", G_TYPE_INT, 1, NULL); -ge.conv=gst_element_factory_make("audioconverter", "converter"); ge.queue=gst_element_factory_make("queue", "queue"); ge.sink=gst_element_factory_make(AUDIO_SINK, "sink"); +g_assert(ge.pipeline); +g_assert(ge.src); +g_assert(ge.caps); +g_assert(ge.srccaps); +g_assert(ge.queue); +g_assert(ge.sink); + g_object_set(ge.caps, "caps", ge.srccaps, NULL); gst_bin_add_many (GST_BIN(ge.pipeline), ge.src, ge.queue, ge.sink, NULL); @@ -112,7 +117,6 @@ return TRUE; static void espeak_buffer_free(void *p) { -g_print("Buffer free\n"); g_free(p); } @@ -132,21 +136,21 @@ if (wav==NULL) { data=g_memdup(wav, numsamples); buf=gst_app_buffer_new (data, numsamples, espeak_buffer_free, data); gst_buffer_set_caps(buf, ge.srccaps); - gst_app_src_push_buffer (GST_APP_SRC (ge.src), buf); + gst_app_src_push_buffer(GST_APP_SRC (ge.src), buf); } return 0; } gboolean -speak_init(guint speed, guint pitch) +speak_init(gchar voice, guint speed, guint pitch) { erate=espeak_Initialize(AUDIO_OUTPUT_RETRIEVAL, 100, NULL, 0); if (erate==-1) return FALSE; espeak_SetSynthCallback(espeak_cb); -espeak_SetVoiceByName("en"); +espeak_SetVoiceByName(voice); espeak_SetParameter(espeakRATE, speed,0); espeak_SetParameter(espeakPITCH, pitch,0); espeak_SetParameter(espeakVOLUME, 100,0); @@ -203,7 +207,7 @@ return TRUE; #else -gboolean speak_init(guint speed, guint pitch) {return TRUE;} +gboolean speak_init(gchar voice, guint speed, guint pitch) {return TRUE;} void speak_deinit(void) {} gboolean speak_stop(void) {return TRUE;} gboolean speak_speaking(void) {return FALSE;} -- 2.39.5