From 1ea5313b78892a2f0b10ccd81deb0a9b6b8e9dfa Mon Sep 17 00:00:00 2001 From: Bryant Date: Wed, 5 Feb 2014 11:50:33 -0800 Subject: [PATCH] Speech library now uses QGC_SPEECH_ENABLED macro. --- QGCExternalLibs.pri | 5 ++++- src/GAudioOutput.cc | 26 +++++++++++++------------- src/GAudioOutput.h | 12 ++++++------ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/QGCExternalLibs.pri b/QGCExternalLibs.pri index cfc3685e1..b5fb920c6 100644 --- a/QGCExternalLibs.pri +++ b/QGCExternalLibs.pri @@ -532,24 +532,27 @@ MacBuild { # contains (DEFINES, DISABLE_SPEECH) { message("Skipping support for speech output (manual override)") + DEFINES -= DISABLE_SPEECH } else:LinuxBuild { exists(/usr/include/flite) | exists(/usr/local/include/flite) { message("Including support for speech output") + DEFINES += QGC_SPEECH_ENABLED LIBS += \ -lflite_cmu_us_kal \ -lflite_usenglish \ -lflite_cmulex \ -lflite } else { - DEFINES += DISABLE_SPEECH warning("Skipping support for speech output (missing libraries, see README)") } } # Mac support is built into OS 10.6+. else:MacBuild { message("Including support for speech output") + DEFINES += QGC_SPEECH_ENABLED } # Windows supports speech through native API. else:WindowsBuild { message("Including support for speech output") + DEFINES += QGC_SPEECH_ENABLED } diff --git a/src/GAudioOutput.cc b/src/GAudioOutput.cc index 3dfa53142..fd3607963 100644 --- a/src/GAudioOutput.cc +++ b/src/GAudioOutput.cc @@ -37,12 +37,12 @@ This file is part of the QGROUNDCONTROL project #include -#if defined Q_OS_MAC && !defined DISABLE_SPEECH +#if defined Q_OS_MAC && defined QGC_SPEECH_ENABLED #include #endif // Speech synthesis is only supported with MSVC compiler -#if defined _MSC_VER && !defined DISABLE_SPEECH +#if defined _MSC_VER && defined QGC_SPEECH_ENABLED // Documentation: http://msdn.microsoft.com/en-us/library/ee125082%28v=VS.85%29.aspx #include @@ -50,14 +50,14 @@ This file is part of the QGROUNDCONTROL project //using System.Speech.Synthesis; #endif -#if defined Q_OS_LINUX && !defined DISABLE_SPEECH +#if defined Q_OS_LINUX && defined QGC_SPEECH_ENABLED extern "C" { #include cst_voice *register_cmu_us_kal(const char *voxdir); }; #endif -#if defined _MSC_VER && !defined DISABLE_SPEECH +#if defined _MSC_VER && defined QGC_SPEECH_ENABLED ISpVoice *GAudioOutput::pVoice = NULL; #endif @@ -96,11 +96,11 @@ GAudioOutput::GAudioOutput(QObject *parent) : QObject(parent), muted = settings.value(QGC_GAUDIOOUTPUT_KEY + "muted", muted).toBool(); -#if defined Q_OS_LINUX && !defined DISABLE_SPEECH +#if defined Q_OS_LINUX && defined QGC_SPEECH_ENABLED flite_init(); #endif -#if defined _MSC_VER && !defined DISABLE_SPEECH +#if defined _MSC_VER && defined QGC_SPEECH_ENABLED pVoice = NULL; if (FAILED(::CoInitialize(NULL))) @@ -145,7 +145,7 @@ GAudioOutput::GAudioOutput(QObject *parent) : QObject(parent), GAudioOutput::~GAudioOutput() { -#if defined _MSC_VER && !defined DISABLE_SPEECH +#if defined _MSC_VER && defined QGC_SPEECH_ENABLED pVoice->Release(); pVoice = NULL; ::CoUninitialize(); @@ -182,7 +182,7 @@ bool GAudioOutput::say(QString text, int severity) { // Speech synthesis is only supported with MSVC compiler -#if defined _MSC_VER && !defined DISABLE_SPEECH +#if defined _MSC_VER && defined QGC_SPEECH_ENABLED /*SpeechSynthesizer synth = new SpeechSynthesizer(); synth.SelectVoice("Microsoft Anna"); synth.SpeakText(text.toStdString().c_str()); @@ -205,7 +205,7 @@ bool GAudioOutput::say(QString text, int severity) }*/ #endif -#if defined Q_OS_LINUX && !defined DISABLE_SPEECH +#if defined Q_OS_LINUX && defined QGC_SPEECH_ENABLED QTemporaryFile file; file.setFileTemplate("XXXXXX.wav"); @@ -222,7 +222,7 @@ bool GAudioOutput::say(QString text, int severity) #endif -#if defined Q_OS_MAC && !defined DISABLE_SPEECH +#if defined Q_OS_MAC && defined QGC_SPEECH_ENABLED // Slashes necessary to have the right start to the sentence // copying data prevents SpeakString from reading additional chars text = "\\" + text; @@ -339,14 +339,14 @@ void GAudioOutput::beep() void GAudioOutput::selectFemaleVoice() { -#if defined Q_OS_LINUX && !defined DISABLE_SPEECH +#if defined Q_OS_LINUX && defined QGC_SPEECH_ENABLED //this->voice = register_cmu_us_slt(NULL); #endif } void GAudioOutput::selectMaleVoice() { -#if defined Q_OS_LINUX && !defined DISABLE_SPEECH +#if defined Q_OS_LINUX && defined QGC_SPEECH_ENABLED //this->voice = register_cmu_us_rms(NULL); #endif } @@ -354,7 +354,7 @@ void GAudioOutput::selectMaleVoice() /* void GAudioOutput::selectNeutralVoice() { -#if defined Q_OS_LINUX && !defined DISABLE_SPEECH +#if defined Q_OS_LINUX && defined QGC_SPEECH_ENABLED this->voice = register_cmu_us_awb(NULL); #endif }*/ diff --git a/src/GAudioOutput.h b/src/GAudioOutput.h index 020ccea7c..456ba9765 100644 --- a/src/GAudioOutput.h +++ b/src/GAudioOutput.h @@ -40,7 +40,7 @@ This file is part of the PIXHAWK project #include #endif #ifdef Q_OS_LINUX -#if !defined DISABLE_SPEECH +#if defined QGC_SPEECH_ENABLED //#include #endif #include @@ -52,13 +52,13 @@ This file is part of the PIXHAWK project #endif /* For Snow leopard and later -#if defined Q_OS_MAC & !defined DISABLE_SPEECH +#if defined Q_OS_MAC & defined QGC_SPEECH_ENABLED #include #endif */ -#if defined _MSC_VER && !defined DISABLE_SPEECH +#if defined _MSC_VER && defined QGC_SPEECH_ENABLED // Documentation: http://msdn.microsoft.com/en-us/library/ee125082%28v=VS.85%29.aspx #include #endif @@ -111,13 +111,13 @@ signals: void mutedChanged(bool); protected: -#if defined Q_OS_MAC && !defined DISABLE_SPEECH +#if defined Q_OS_MAC && defined QGC_SPEECH_ENABLED //NSSpeechSynthesizer #endif -#if defined Q_OS_LINUX && !defined DISABLE_SPEECH +#if defined Q_OS_LINUX && defined QGC_SPEECH_ENABLED //cst_voice* voice; ///< The flite voice object #endif -#if defined _MSC_VER && !defined DISABLE_SPEECH +#if defined _MSC_VER && defined QGC_SPEECH_ENABLED static ISpVoice *pVoice; #endif int voiceIndex; ///< The index of the flite voice to use (awb, slt, rms) -- 2.22.0