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/QLoggingCategory>
4#include <QtCore/QObject>
5
6class QTextToSpeech;
7class Fact;
8class AudioOutputTest;
9
10Q_DECLARE_LOGGING_CATEGORY(AudioOutputLog)
11
12
13class AudioOutput : public QObject
14{
15 Q_OBJECT
16
17 friend AudioOutputTest;
18
19public:
21 enum class TextMod {
22 None = 0,
23 Translate = 1 << 0,
24 };
25 Q_FLAG(TextMod)
26 Q_DECLARE_FLAGS(TextMods, TextMod)
27
28
30 explicit AudioOutput(QObject *parent = nullptr);
31
34
37 static AudioOutput *instance();
38
40 void init(Fact *mutedFact);
41
44 bool isMuted() const { return _muted; }
45
48 void setMuted(bool muted);
49
53 void say(const QString &text, TextMods textMods = TextMod::None);
54
55private:
56 QTextToSpeech *_engine = nullptr;
57 QAtomicInteger<qsizetype> _textQueueSize = 0;
58 bool _initialized = false;
59 std::atomic_bool _muted = false;
60
61 static const QHash<QString, QString> _textHash;
62
63 static constexpr qsizetype kMaxTextQueueSize = 20;
64
68 static QString _fixTextMessageForAudio(const QString &string);
69
73 static QString _replaceAbbreviations(const QString &input);
74
76 static QString _replaceNegativeSigns(const QString &input);
77
79 static QString _replaceDecimalPoints(const QString &input);
80
82 static QString _replaceMeters(const QString &input);
83
85 static QString _convertMilliseconds(const QString &input);
86
92 static bool _getMillisecondString(const QString &string, QString &match, int &number);
93
94};
95Q_DECLARE_OPERATORS_FOR_FLAGS(AudioOutput::TextMods)
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
The AudioOutput class provides functionality for audio output using text-to-speech.
Definition AudioOutput.h:14
TextMod
Enumeration for text modification options.
Definition AudioOutput.h:21
bool isMuted() const
Definition AudioOutput.h:44
A Fact is used to hold a single value within the system.
Definition Fact.h:19