From: Kaj-Michael Lang Date: Fri, 19 Oct 2007 11:00:10 +0000 (+0300) Subject: Allow speaking even if currently speaking. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97441c34944ede9a6bd64d4ed86af3b5c4ece0f2;p=mapper Allow speaking even if currently speaking. --- diff --git a/src/speak.c b/src/speak.c index ba0d765..6d3943f 100644 --- a/src/speak.c +++ b/src/speak.c @@ -58,6 +58,7 @@ static gint erate; static GstBus *bus; static gboolean speaking=FALSE; static gboolean speak_ok; +static gboolean espeak_ok; static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) @@ -172,6 +173,7 @@ espeak_SetParameter(espeakPITCH, pitch, 0); gboolean speak_init(gchar *voice, guint speed, guint pitch) { +espeak_ok=FALSE; erate=espeak_Initialize(AUDIO_OUTPUT_RETRIEVAL, 100, NULL, 0); if (erate==-1) return FALSE; @@ -186,13 +188,16 @@ if (speak_create_pipeline()==FALSE) bus=gst_pipeline_get_bus(GST_PIPELINE (ge.pipeline)); g_assert(bus); gst_bus_add_watch(bus, bus_call, NULL); - +espeak_ok=TRUE; return TRUE; } void speak_deinit(void) { +if (espeak_ok==FALSE) + return; + gst_element_set_state(ge.pipeline, GST_STATE_NULL); gst_object_unref(ge.pipeline); ge.pipeline=NULL; @@ -203,18 +208,22 @@ espeak_Terminate(); gboolean speak_text(gchar *text) { +#if 0 if (speaking==TRUE) return FALSE; +#endif g_printf("Speaking: %s (%d)\n", text, strlen(text)); espeak_Synth(text, strlen(text)+1, 0, POS_CHARACTER, 0, espeakCHARS_UTF8, NULL, NULL); -if (gst_element_set_state (ge.pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { - g_print("Failed to play\n"); - speaking=FALSE; - return FALSE; +if (speaking!=TRUE) { + if (gst_element_set_state (ge.pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { + g_print("Failed to play\n"); + speaking=FALSE; + return FALSE; + } + speaking=TRUE; } -speaking=TRUE; g_print("Playing...\n"); return TRUE; }