[dasher] Support SpeechDispatcher (in preference to GnomeSpeech)
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher] Support SpeechDispatcher (in preference to GnomeSpeech)
- Date: Wed, 13 Apr 2011 10:06:23 +0000 (UTC)
commit f8f6e7fce15314b1d61c38e23ae1dbbc5b998470
Author: Patrick Welche <prlw1 cam ac uk>
Date: Sun Apr 10 00:55:02 2011 +0200
Support SpeechDispatcher (in preference to GnomeSpeech)
Src/Gtk2/DasherControl.cpp | 2 +-
Src/Gtk2/DasherControl.h | 6 +-
Src/Gtk2/{Speech.cpp => GnomeSpeech.cpp} | 7 +--
Src/Gtk2/Makefile.am | 14 ++++--
Src/Gtk2/Speech.h | 20 ++++++--
Src/Gtk2/SpeechDispatcher.cpp | 27 ++++++++++
configure.ac | 78 ++++++++++++++++++++++--------
7 files changed, 117 insertions(+), 37 deletions(-)
---
diff --git a/Src/Gtk2/DasherControl.cpp b/Src/Gtk2/DasherControl.cpp
index 247577d..6fe31da 100644
--- a/Src/Gtk2/DasherControl.cpp
+++ b/Src/Gtk2/DasherControl.cpp
@@ -218,7 +218,7 @@ void CDasherControl::CopyToClipboard(const std::string &strText) {
gtk_clipboard_set_text(pClipboard, the_text, strlen(the_text));
}
-#ifdef GNOME_SPEECH
+#ifdef WITH_SPEECH
bool CDasherControl::SupportsSpeech() {
return m_Speech.Init();
}
diff --git a/Src/Gtk2/DasherControl.h b/Src/Gtk2/DasherControl.h
index 1f235c1..f6c71a9 100644
--- a/Src/Gtk2/DasherControl.h
+++ b/Src/Gtk2/DasherControl.h
@@ -17,7 +17,7 @@
#include "tilt_input.h"
#endif
-#ifdef GNOME_SPEECH
+#ifdef WITH_SPEECH
#include "Speech.h"
#endif
@@ -143,7 +143,7 @@ public:
virtual bool SupportsClipboard();
virtual void CopyToClipboard(const std::string &strText);
-#ifdef GNOME_SPEECH
+#ifdef WITH_SPEECH
///override default non-implementation if compiling with speech...
virtual bool SupportsSpeech();
virtual void Speak(const std::string &strText, bool bInterrupt);
@@ -216,7 +216,7 @@ private:
//Cache the clipboard object...
GtkClipboard *pClipboard;
-#ifdef GNOME_SPEECH
+#ifdef WITH_SPEECH
CSpeech m_Speech;
#endif
};
diff --git a/Src/Gtk2/Speech.cpp b/Src/Gtk2/GnomeSpeech.cpp
similarity index 96%
rename from Src/Gtk2/Speech.cpp
rename to Src/Gtk2/GnomeSpeech.cpp
index 86590bd..d64e1e6 100644
--- a/Src/Gtk2/Speech.cpp
+++ b/Src/Gtk2/GnomeSpeech.cpp
@@ -1,9 +1,10 @@
-// TODO: Make inclusion in build system conditional
+// Inclusion in build system conditional on USE_GNOMESPEECH
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#ifdef GNOME_SPEECH
+
#include "Speech.h"
+#include <glib/gi18n.h>
CSpeech::CSpeech() : m_speaker(NULL) {
CORBA_exception_init(&m_ev);
@@ -75,5 +76,3 @@ void CSpeech::Speak(const std::string &strText, bool bInterrupt) {
if (Init())
GNOME_Speech_Speaker_say(m_speaker, strText.c_str(), &m_ev);
}
-
-#endif
diff --git a/Src/Gtk2/Makefile.am b/Src/Gtk2/Makefile.am
index 8aec810..c0d05ad 100644
--- a/Src/Gtk2/Makefile.am
+++ b/Src/Gtk2/Makefile.am
@@ -39,7 +39,6 @@ libdashercontrol_la_SOURCES = \
PangoCache.h \
Timer.cpp \
Timer.h \
- Speech.cpp \
Speech.h \
custom_marshal.cpp \
custom_marshal.h \
@@ -59,6 +58,16 @@ libdashercontrol_la_SOURCES += NoStore.cpp
endif
endif
+if USE_GNOMESPEECH
+libdashercontrol_la_SOURCES += GnomeSpeech.cpp
+endif
+if USE_SPEECHDISPATCHER
+libdashercontrol_la_SOURCES += SpeechDispatcher.cpp
+endif
+libdashercontrol_la_CPPFLAGS = @SPEECH_CPPFLAGS@
+libdashercontrol_la_LDFLAGS = @SPEECH_LDFLAGS@
+libdashercontrol_la_LIBADD = @SPEECH_LIBS@
+
libdashergtk_la_SOURCES = \
DasherAppSettings.cpp \
DasherAppSettings.h \
@@ -96,7 +105,4 @@ libdashergtk_la_SOURCES = \
# dasher_maemo_helper.h
# endif
-libdashergtk_la_LIBADD = @SPEECH_SOURCES@
-libdashergtk_la_DEPENDENCIES = @SPEECH_SOURCES@
-
AM_CXXFLAGS = -I$(srcdir)/../DasherCore -DPROGDATA=\"$(pkgdatadir)\" $(GTKBUILD_CFLAGS)
diff --git a/Src/Gtk2/Speech.h b/Src/Gtk2/Speech.h
index 7283352..effbbd0 100644
--- a/Src/Gtk2/Speech.h
+++ b/Src/Gtk2/Speech.h
@@ -1,13 +1,18 @@
-// TODO: Make inclusion in build system conditional
+#ifndef _SPEECH_H_
+#define _SPEECH_H_
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#ifdef GNOME_SPEECH
-
#include <string>
-#include <glib/gi18n.h>
+
+#ifdef GNOME_SPEECH
#include <gnome-speech/gnome-speech.h>
#include <libbonobo.h>
+#endif
+#ifdef HAVE_SPEECHD
+#include <speech-dispatcher/libspeechd.h>
+#endif
class CSpeech {
public:
@@ -16,9 +21,14 @@ public:
bool Init();
void Speak(const std::string &strText, bool bInterrupt);
private:
+#ifdef GNOME_SPEECH
GNOME_Speech_SynthesisDriver m_driver;
GNOME_Speech_Speaker m_speaker;
CORBA_Environment m_ev;
+#endif
+#ifdef HAVE_SPEECHD
+ SPDConnection *m_speaker;
+#endif
};
-#endif
+#endif /* !_SPEECH_H_ */
diff --git a/Src/Gtk2/SpeechDispatcher.cpp b/Src/Gtk2/SpeechDispatcher.cpp
new file mode 100644
index 0000000..8b95189
--- /dev/null
+++ b/Src/Gtk2/SpeechDispatcher.cpp
@@ -0,0 +1,27 @@
+// Inclusion in build system conditional on USE_SPEECHDISPATCHER
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Speech.h"
+
+CSpeech::CSpeech() : m_speaker(NULL) {
+}
+
+CSpeech::~CSpeech() {
+ if (m_speaker) spd_close(m_speaker);
+}
+
+
+bool CSpeech::Init() {
+ if (m_speaker) return true;
+
+ m_speaker = spd_open("dasher", NULL, NULL, SPD_MODE_SINGLE);
+
+ return m_speaker != NULL;
+}
+
+void CSpeech::Speak(const std::string &strText, bool bInterrupt) {
+ if (Init())
+ spd_say(m_speaker, SPD_TEXT, strText.c_str());
+}
diff --git a/configure.ac b/configure.ac
index 24448bb..64be616 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,13 +75,8 @@ AC_ARG_WITH([gnome],
WITHGNOME=true)
AC_ARG_ENABLE([speech],
- AS_HELP_STRING([--enable-speech],[build with speech support (default is NO)]),
- if test "x$enableval" = "xno"; then
- WITHSPEECH=false;
- else
- WITHSPEECH=true;
- fi,
- WITHSPEECH=false)
+ [AS_HELP_STRING([--enable-speech=@<:@speechdispatcher,gnomespeech@:>@],
+ [build with speech support (default is YES)])])
AC_ARG_WITH([qte],
AS_HELP_STRING([--with-qte],[build with QTE support (default is NO -- currently untested)]),
@@ -257,11 +252,58 @@ if test x"$DEBUG" = xtrue; then
AC_DEFINE([DEBUG], 1, [Additional debug checks enabled])
fi
-if test x"$WITHSPEECH" = xtrue; then
- PKG_CHECK_MODULES(gnome_speech, gnome-speech-1.0 bonobo-activation-2.0 libbonobo-2.0 ORBit-2.0)
- AC_DEFINE([GNOME_SPEECH], 1, [gnome_speech-1 libraries are present])
-# SPEECH_SOURCES='speech.$(OBJEXT)'
-fi
+dnl default: enable speech
+dnl if speechdispatcher or default
+dnl check for speechdispatcher
+dnl if gnomespeech or (default and nothing found)
+dnl check for gnomespeech
+dnl if nothing found
+dnl OK if wanted no speech
+dnl warn if default
+dnl error if yes
+dnl error if selected particular
+dnl BTW test: The -a operator has higher precedence than the -o operator.
+speech_module=none
+AS_IF(
+ [test "x$enable_speech" = x],
+ [enable_speech=yes; only_warn_if_speech_not_found=yes])
+AS_IF(
+ [test "x$enable_speech" = xspeechdispatcher -o "x$enable_speech" = xyes],
+ [AC_CHECK_HEADER([speech-dispatcher/libspeechd.h],
+ [AC_CHECK_LIB([speechd], [spd_open],
+ [AC_DEFINE([HAVE_SPEECHD], 1,
+ [speechdispatcher libraries are present])
+ speech_module="speechdispatcher"
+ SPEECH_CPPFLAGS=
+ SPEECH_LDFLAGS=
+ SPEECH_LIBS=-lspeechd])])])
+AS_IF(
+ [test "x$enable_speech" = xgnomespeech -o "x$enable_speech" = xyes -a $speech_module = none],
+ [PKG_CHECK_MODULES([gnome_speech],
+ [gnome-speech-1.0 bonobo-activation-2.0 libbonobo-2.0 ORBit-2.0])
+ AC_DEFINE([GNOME_SPEECH], 1, [gnome_speech-1 libraries are present])
+ SPEECH_CPPFLAGS=$gnome_speech_CFLAGS
+ SPEECH_LDFLAGS=$gnome_speech_LIBS
+ SPEECH_LIBS=$gnome_speech_LIBS
+ speech_module=gnomespeech])
+AS_IF(
+ [test $speech_module = none],
+ [AS_CASE(["x$enable_speech"],
+ [xno],
+ [:],
+ [xyes],
+ [AS_IF([test x$only_warn_if_speech_not_found = xyes],
+ [AC_MSG_WARN([no speech module found])],
+ [AC_MSG_ERROR([speech requested but no speech module found])])],
+ [AC_MSG_ERROR([speech module "$enable_speech" requested but not found])])])
+AC_MSG_CHECKING([which speech module to use])
+AC_MSG_RESULT([$speech_module])
+AS_IF([test $speech_module != none],
+ [AC_DEFINE([WITH_SPEECH], 1, [text-to-speech is present])])
+
+AC_SUBST(SPEECH_CPPFLAGS)
+AC_SUBST(SPEECH_LDFLAGS)
+AC_SUBST(SPEECH_LIBS)
if test x"$WITHA11Y" = xtrue; then
PKG_CHECK_MODULES(gnome_a11y, bonobo-activation-2.0 libbonobo-2.0 ORBit-2.0 cspi-1.0 atk)
@@ -341,13 +383,8 @@ if test x"$BUILDGTK" = xtrue; then
PKG_CHECK_MODULES(gthread, gthread-2.0)
fi
-AC_SUBST(gnome_speech_LIBS)
-AC_SUBST(gnome_speech_CFLAGS)
-AC_SUBST([SPEECH_SOURCES])
-
AC_SUBST(gnome_a11y_LIBS)
AC_SUBST(gnome_a11y_CFLAGS)
-AC_SUBST([A11Y_SOURCES])
AC_SUBST(gthread_LIBS)
AC_SUBST(gthread_CFLAGS)
@@ -361,7 +398,8 @@ AM_CONDITIONAL(USE_GCONF, test x$have_gconf = xtrue)
AM_CONDITIONAL(USE_GSETTINGS, test x$have_gsettings = xtrue)
AM_CONDITIONAL(DOGTK, test x$BUILDGTK = xtrue)
AM_CONDITIONAL(DOQTE, test x$WITHQTE = xtrue)
-AM_CONDITIONAL(GNOME_SPEECH, test x$WITHSPEECH = xtrue)
+AM_CONDITIONAL(USE_GNOMESPEECH, test $speech_module = gnomespeech)
+AM_CONDITIONAL(USE_SPEECHDISPATCHER, test $speech_module = speechdispatcher)
AM_CONDITIONAL(GNOME_A11Y, test x$WITHA11Y = xtrue)
AM_CONDITIONAL(GNOME_HELP, test x$WITHGNOME = xtrue)
AM_CONDITIONAL(WITH_GPE, test x$WITHGPE = xtrue)
@@ -378,9 +416,9 @@ if test x"$WITHGPE" = xtrue ; then
SETTINGS_LIBS="-lgpewidget -lXsettings-client -lXsettings"
fi
-GTKBUILD_CFLAGS="$GTK_CFLAGS $GIO_CFLAGS $SETTINGS_CFLAGS $gthread_CFLAGS $gnome_speech_CFLAGS $gnome_a11y_CFLAGS $hildon_CFLAGS"
+GTKBUILD_CFLAGS="$GTK_CFLAGS $GIO_CFLAGS $SETTINGS_CFLAGS $gthread_CFLAGS $gnome_a11y_CFLAGS $hildon_CFLAGS"
-GTKBUILD_LIBS="$X_LIBS $GTK_LIBS $GIO_LIBS $SETTINGS_LIBS $gthread_LIBS $gnome_speech_LIBS $gnome_a11y_LIBS $hildon_LIBS"
+GTKBUILD_LIBS="$X_LIBS $GTK_LIBS $GIO_LIBS $SETTINGS_LIBS $gthread_LIBS $gnome_a11y_LIBS $hildon_LIBS"
AC_SUBST(GTKBUILD_CFLAGS)
AC_SUBST(GTKBUILD_LIBS)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]