]> err.no Git - mapper/commitdiff
Allow speaking even if currently speaking.
authorKaj-Michael Lang <milang@angel.tal.org>
Fri, 19 Oct 2007 11:00:10 +0000 (14:00 +0300)
committerKaj-Michael Lang <milang@angel.tal.org>
Fri, 19 Oct 2007 11:00:10 +0000 (14:00 +0300)
src/speak.c

index ba0d7659a98abe434d465495a87431c27cd188a6..6d3943f225d9cf2ad132bedb1d1e210b36faf368 100644 (file)
@@ -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;
 }