diff --git a/src/Audio/AudioOutput.cc b/src/Audio/AudioOutput.cc index 4c892b5da416becdf47ffd09aa8bae77791b1d96..98e9498ee9666282440c7470113fe921e603904d 100644 --- a/src/Audio/AudioOutput.cc +++ b/src/Audio/AudioOutput.cc @@ -17,9 +17,17 @@ #include "SettingsManager.h" AudioOutput::AudioOutput(QGCApplication* app, QGCToolbox* toolbox) - : QGCTool(app, toolbox) - , _tts(new QTextToSpeech(this)) + : QGCTool (app, toolbox) + , _tts (nullptr) { + if (qgcApp()->runningUnitTests()) { + // Cloud based unit tests don't have speech capabilty. If you try to crank up + // speech engine it will pop a qWarning which prevents usage of QT_FATAL_WARNINGS + return; + } + + _tts = new QTextToSpeech(this); + //-- Force TTS engine to English as all incoming messages from the autopilot // are in English and not localized. #ifdef Q_OS_LINUX @@ -28,8 +36,13 @@ AudioOutput::AudioOutput(QGCApplication* app, QGCToolbox* toolbox) connect(_tts, &QTextToSpeech::stateChanged, this, &AudioOutput::_stateChanged); } -bool AudioOutput::say(const QString& inText) +void AudioOutput::say(const QString& inText) { + if (!_tts) { + qDebug() << "say" << inText; + return; + } + bool muted = qgcApp()->toolbox()->settingsManager()->appSettings()->audioMuted()->rawValue().toBool(); muted |= qgcApp()->runningUnitTests(); if (!muted && !qgcApp()->runningUnitTests()) { @@ -46,7 +59,6 @@ bool AudioOutput::say(const QString& inText) _tts->say(text); } } - return true; } void AudioOutput::_stateChanged(QTextToSpeech::State state) diff --git a/src/Audio/AudioOutput.h b/src/Audio/AudioOutput.h index b97d81f4e996581f518c3dae0083282e82f3c92d..e6da79c26a0bf49319f144acf2a2b7348d7baa2d 100644 --- a/src/Audio/AudioOutput.h +++ b/src/Audio/AudioOutput.h @@ -29,7 +29,7 @@ public: static QString fixTextMessageForAudio (const QString& string); public slots: - bool say (const QString& text); + void say (const QString& text); private slots: void _stateChanged (QTextToSpeech::State state);