QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
AudioOutput.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QObject>
4
5class QTextToSpeech;
6class Fact;
7class AudioOutputTest;
8
11class AudioOutput : public QObject
12{
13 Q_OBJECT
14
15 friend AudioOutputTest;
16
17public:
19 enum class TextMod {
20 None = 0,
21 Translate = 1 << 0,
22 };
23 Q_FLAG(TextMod)
24 Q_DECLARE_FLAGS(TextMods, TextMod)
25
26
28 explicit AudioOutput(QObject *parent = nullptr);
29
32
35 static AudioOutput *instance();
36
38 void init(Fact *volumeFact, Fact *mutedFact);
39
43 void say(const QString &text, TextMods textMods = TextMod::None);
44
46 void testAudioOutput();
47
48private:
49 QTextToSpeech *_engine = nullptr;
50 qsizetype _textQueueSize = 0;
51 bool _initialized = false;
52 bool _speakCapable = false;
53 Fact *_volumeFact = nullptr;
54 Fact *_mutedFact = nullptr;
55 double _lastVolume = -1.0;
56
58 double _volumeSetting() const;
59
61 bool _mutedSetting() const;
62
64 void _setVolume();
65
67 void _applyEngineSettings();
68
70 void _finishInit();
71
72 static const QHash<QString, QString> _textHash;
73
74 static constexpr qsizetype kMaxTextQueueSize = 20;
75
79 static QString _fixTextMessageForAudio(const QString &string);
80
84 static QString _replaceAbbreviations(const QString &input);
85
87 static QString _replaceNegativeSigns(const QString &input);
88
90 static QString _replaceDecimalPoints(const QString &input);
91
93 static QString _replaceMeters(const QString &input);
94
96 static QString _convertMilliseconds(const QString &input);
97
103 static bool _getMillisecondString(const QString &string, QString &match, int &number);
104
105};
106Q_DECLARE_OPERATORS_FOR_FLAGS(AudioOutput::TextMods)
The AudioOutput class provides functionality for audio output using text-to-speech.
Definition AudioOutput.h:12
void say(const QString &text, TextMods textMods=TextMod::None)
void testAudioOutput()
Tests the audio output. Will stop current output before test.
TextMod
Enumeration for text modification options.
Definition AudioOutput.h:19
static AudioOutput * instance()
~AudioOutput()
Destructor for the AudioOutput class.
void init(Fact *volumeFact, Fact *mutedFact)
Initialize the Singleton.
A Fact is used to hold a single value within the system.
Definition Fact.h:17