diff --git a/QGCExternalLibs.pri b/QGCExternalLibs.pri index cfc3685e1b36dd003c97ae154a756b2d7e0d37d8..b5fb920c6c434acac1b54502e7aa54e2a894d381 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 3dfa5314218cdb3f41689b167294ab11ae39913d..fd360796301b83d80ee7ead2d8c0571fb952d470 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 020ccea7c000b7433ad2dd78f6179162177a9fcb..456ba9765441f9a95aad76d679a349eac843f0cf 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)