Skip to content

Commit

Permalink
Speech library now uses QGC_SPEECH_ENABLED macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryant committed Feb 13, 2014
1 parent beea559 commit 1ea5313
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
5 changes: 4 additions & 1 deletion QGCExternalLibs.pri
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
26 changes: 13 additions & 13 deletions src/GAudioOutput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,27 @@ This file is part of the QGROUNDCONTROL project

#include <QDebug>

#if defined Q_OS_MAC && !defined DISABLE_SPEECH
#if defined Q_OS_MAC && defined QGC_SPEECH_ENABLED
#include <ApplicationServices/ApplicationServices.h>
#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 <sapi.h>

//using System;
//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 <flite/flite.h>
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

Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand All @@ -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");

Expand All @@ -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;
Expand Down Expand Up @@ -339,22 +339,22 @@ 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
}

/*
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
}*/
Expand Down
12 changes: 6 additions & 6 deletions src/GAudioOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This file is part of the PIXHAWK project
#include <AudioOutput>
#endif
#ifdef Q_OS_LINUX
#if !defined DISABLE_SPEECH
#if defined QGC_SPEECH_ENABLED
//#include <flite/flite.h>
#endif
#include <phonon/MediaObject>
Expand All @@ -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 <NSSpeechSynthesizer.h>
#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 <sapi.h>
#endif
Expand Down Expand Up @@ -111,13 +111,13 @@ public slots:
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)
Expand Down

0 comments on commit 1ea5313

Please sign in to comment.