diff --git a/QGCExternalLibs.pri b/QGCExternalLibs.pri index 8b6e9662fca863b11b65113d9798ba94bde0f79c..2f598a6c2c6933c4746f66a3ae5533d1a77d9029 100644 --- a/QGCExternalLibs.pri +++ b/QGCExternalLibs.pri @@ -505,15 +505,38 @@ WindowsBuild { -lSDL } -# -# Festival Lite speech synthesis engine +## +# Speech synthesis library support. +# Can be forcibly disabled by adding a `DEFINES+=DISABLE_SPEECH` argument to qmake. # +# Festival Lite speech synthesis engine LinuxBuild { - LIBS += \ - -lflite_cmu_us_kal \ - -lflite_usenglish \ - -lflite_cmulex \ - -lflite + contains (DEFINES, DISABLE_SPEECH) { + message("Skipping support for speech synthesis (manual override)") + } else:exists(/usr/include/flite) | exists(/usr/local/include/flite) { + message(Enabling support for speech output) + LIBS += \ + -lflite_cmu_us_kal \ + -lflite_usenglish \ + -lflite_cmulex \ + -lflite + } else { + DEFINES += DISABLE_SPEECH + warning("Skipping support for speech synthesis (missing flite libraries, see README)") + } +} + +# Mac support for speech synthesis is currently broken. +# Library support is built into Mac OS X +MacBuild { + message("Including support for speech synthesis.") +} + +# Windows support for speech synthesis is currently broken +# Library support is built into Windows +WindowsBuild { + DEFINES += DISABLE_SPEECH + message("Skipping support for speech synthesis (unsupported on Windows)") } diff --git a/README.md b/README.md index b2d4bbab0e28bc5ff071e5f55724720e91245b65..a545564d3e1f5460ab07244287ef5781b59849cf 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,11 @@ Please make sure to delete your build folder before re-building. Independent of build system you use (this is not related to Qt or your OS) the dependency checking and cleaning is based on the current project revision. So if you change the project and don't remove the build folder before your next build, incremental building can leave you with stale object files. +## Additional functionality +QGroundcontrol has functionality that is dependent on the operating system and libraries installed by the user. The following sections describe these features, their dependencies, and how to disable/alter them during the build process. + ### QUpgrade -QUpgrade is a submodule (a Git feature like a sub-repository) that contains extra functionality. It is compiled in by default if it has initialized and updated. It can be disabled by specifying the DISABLE_QUPGRADE definition when calling qmake `qmake DEFINES=DISABLE_QUPGRADE`. +QUpgrade is a submodule (a Git feature like a sub-repository) that contains extra functionality. It is compiled in by default if it has initialized and updated. It can be disabled by specifying the DISABLE_QUPGRADE definition when calling qmake `qmake DEFINES=DISABLE_QUPGRADE`. Note that multiple defines can be specified like this: `qmake DEFINES="DISABLE_QUPGRADE DISABLE_SPEECH"`. To include QUpgrade functionality run the following (only needs to be done once after cloning the qggroundcontrol git repository): * `git submodule init` @@ -34,6 +37,9 @@ The MAVLink dialect compiled by default by QGC is for the ardupilotmega. This wi The `MAVLINK_CONF` variable can also be specified at the command line as an argument to qmake to allow for easy one-off compilations: `qmake MAVLINK_CONF="sensesoar ardupilotmega"` +### Speech syntehsis +QGroundcontrol can notify the controller of information via speech synthesis on the Mac and Linux platforms. This requires the `flite` library on Linux while on Mac text-to-speech support is built in starting with OS 10.6+ (Snow Leopard). This support is enabled by default on all platforms if the dependencies are met. Disabling this functionality can be done by adding the `DISABLE_SPEECH` define when running `qmake` like: `qmake DEFINES=DISABLE_SPEECH`. Note that multiple defines can be specified like this: `qmake DEFINES="DISABLE_QUPGRADE DISABLE_SPEECH"`. + # Build on Mac OSX To build on Mac OSX (10.6 or later): diff --git a/src/GAudioOutput.cc b/src/GAudioOutput.cc index e4f158d5efe4cd14e7465541d258bcfef8ba94d9..3dfa5314218cdb3f41689b167294ab11ae39913d 100644 --- a/src/GAudioOutput.cc +++ b/src/GAudioOutput.cc @@ -37,12 +37,12 @@ This file is part of the QGROUNDCONTROL project #include -#ifdef Q_OS_MAC +#if defined Q_OS_MAC && !defined DISABLE_SPEECH #include #endif // Speech synthesis is only supported with MSVC compiler -#if _MSC_VER +#if defined _MSC_VER && !defined DISABLE_SPEECH // 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 -#ifdef Q_OS_LINUX +#if defined Q_OS_LINUX && !defined DISABLE_SPEECH extern "C" { #include cst_voice *register_cmu_us_kal(const char *voxdir); }; #endif -#ifdef _MSC_VER +#if defined _MSC_VER && !defined DISABLE_SPEECH ISpVoice *GAudioOutput::pVoice = NULL; #endif @@ -96,11 +96,11 @@ GAudioOutput::GAudioOutput(QObject *parent) : QObject(parent), muted = settings.value(QGC_GAUDIOOUTPUT_KEY + "muted", muted).toBool(); -#ifdef Q_OS_LINUX +#if defined Q_OS_LINUX && !defined DISABLE_SPEECH flite_init(); #endif -#if _MSC_VER +#if defined _MSC_VER && !defined DISABLE_SPEECH pVoice = NULL; if (FAILED(::CoInitialize(NULL))) @@ -145,7 +145,7 @@ GAudioOutput::GAudioOutput(QObject *parent) : QObject(parent), GAudioOutput::~GAudioOutput() { -#ifdef _MSC_VER +#if defined _MSC_VER && !defined DISABLE_SPEECH pVoice->Release(); pVoice = NULL; ::CoUninitialize(); @@ -182,7 +182,7 @@ bool GAudioOutput::say(QString text, int severity) { // Speech synthesis is only supported with MSVC compiler -#ifdef _MSC_VER +#if defined _MSC_VER && !defined DISABLE_SPEECH /*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 -#ifdef Q_OS_LINUX +#if defined Q_OS_LINUX && !defined DISABLE_SPEECH QTemporaryFile file; file.setFileTemplate("XXXXXX.wav"); @@ -222,7 +222,7 @@ bool GAudioOutput::say(QString text, int severity) #endif -#ifdef Q_OS_MAC +#if defined Q_OS_MAC && !defined DISABLE_SPEECH // 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() { -#ifdef Q_OS_LINUX +#if defined Q_OS_LINUX && !defined DISABLE_SPEECH //this->voice = register_cmu_us_slt(NULL); #endif } void GAudioOutput::selectMaleVoice() { -#ifdef Q_OS_LINUX +#if defined Q_OS_LINUX && !defined DISABLE_SPEECH //this->voice = register_cmu_us_rms(NULL); #endif } @@ -354,7 +354,7 @@ void GAudioOutput::selectMaleVoice() /* void GAudioOutput::selectNeutralVoice() { -#ifdef Q_OS_LINUX +#if defined Q_OS_LINUX && !defined DISABLE_SPEECH this->voice = register_cmu_us_awb(NULL); #endif }*/ @@ -362,26 +362,5 @@ void GAudioOutput::selectNeutralVoice() QStringList GAudioOutput::listVoices(void) { QStringList l; -#ifdef Q_OS_LINUX2 - cst_voice *voice; - const cst_val *v; - - - - printf("Voices available: "); - - for (v = flite_voice_list; v; v = val_cdr(v)) - { - voice = val_voice(val_car(v)); - QString s; - s.sprintf("%s", voice->name); - printf("%s", voice->name); - l.append(s); - } - - printf("\n"); - -#endif return l; - } diff --git a/src/GAudioOutput.h b/src/GAudioOutput.h index 2f7ecdf948f281002346175467f459103052a890..020ccea7c000b7433ad2dd78f6179162177a9fcb 100644 --- a/src/GAudioOutput.h +++ b/src/GAudioOutput.h @@ -40,7 +40,9 @@ This file is part of the PIXHAWK project #include #endif #ifdef Q_OS_LINUX +#if !defined DISABLE_SPEECH //#include +#endif #include #include #endif @@ -50,20 +52,13 @@ This file is part of the PIXHAWK project #endif /* For Snow leopard and later -#ifdef Q_OS_MAC +#if defined Q_OS_MAC & !defined DISABLE_SPEECH #include #endif */ -#ifdef Q_OS_LINUX2 -extern "C" { - cst_voice *REGISTER_VOX(const char *voxdir); - void UNREGISTER_VOX(cst_voice *vox); - cst_voice *register_cmu_us_kal16(const char *voxdir); -} -#endif -#if _MSC_VER +#if defined _MSC_VER && !defined DISABLE_SPEECH // Documentation: http://msdn.microsoft.com/en-us/library/ee125082%28v=VS.85%29.aspx #include #endif @@ -116,13 +111,13 @@ signals: void mutedChanged(bool); protected: -#ifdef Q_OS_MAC +#if defined Q_OS_MAC && !defined DISABLE_SPEECH //NSSpeechSynthesizer #endif -#ifdef Q_OS_LINUX +#if defined Q_OS_LINUX && !defined DISABLE_SPEECH //cst_voice* voice; ///< The flite voice object #endif -#ifdef _MSC_VER +#if defined _MSC_VER && !defined DISABLE_SPEECH static ISpVoice *pVoice; #endif int voiceIndex; ///< The index of the flite voice to use (awb, slt, rms)