From 94ed44a8b5b8b19a6ea7c381290647dc9383d219 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Mon, 15 Oct 2007 17:02:57 +0300 Subject: [PATCH] Call espeak terminate on deinit. Add helper to set pitch and speed. --- src/speak.c | 20 ++++++++++++++------ src/speak.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/speak.c b/src/speak.c index 0cc553d..19f7fae 100644 --- a/src/speak.c +++ b/src/speak.c @@ -142,6 +142,13 @@ if (wav==NULL) { return 0; } +void +speak_set_parameters(guint speed, guint pitch) +{ +espeak_SetParameter(espeakRATE, speed, 0); +espeak_SetParameter(espeakPITCH, pitch, 0); +} + gboolean speak_init(gchar *voice, guint speed, guint pitch) { @@ -151,15 +158,14 @@ if (erate==-1) espeak_SetSynthCallback(espeak_cb); espeak_SetVoiceByName(voice); -espeak_SetParameter(espeakRATE, speed, 0); -espeak_SetParameter(espeakPITCH, pitch, 0); +speak_set_parameters(speed, pitch); espeak_SetParameter(espeakVOLUME, 100, 0); if (speak_create_pipeline()==FALSE) return FALSE; -bus=gst_pipeline_get_bus (GST_PIPELINE (ge.pipeline)); +bus=gst_pipeline_get_bus(GST_PIPELINE (ge.pipeline)); g_assert(bus); -gst_bus_add_watch (bus, bus_call, NULL); +gst_bus_add_watch(bus, bus_call, NULL); return TRUE; } @@ -167,10 +173,11 @@ return TRUE; void speak_deinit(void) { -gst_element_set_state (ge.pipeline, GST_STATE_NULL); -gst_object_unref (ge.pipeline); +gst_element_set_state(ge.pipeline, GST_STATE_NULL); +gst_object_unref(ge.pipeline); ge.pipeline=NULL; speaking=FALSE; +espeak_Terminate(); } gboolean @@ -212,6 +219,7 @@ 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;} +void speak_set_parameters(guint speed, guint pitch) {} gboolean speak_text(gchar *text) diff --git a/src/speak.h b/src/speak.h index ae8eb25..218ef9a 100644 --- a/src/speak.h +++ b/src/speak.h @@ -8,5 +8,6 @@ void speak_deinit(void); gboolean speak_stop(void); gboolean speak_speaking(void); gboolean speak_text(gchar *text); +void speak_set_parameters(guint speed, guint pitch); #endif -- 2.39.5