QtLingo 1
QtLingo is an Application to make Qt Computer Translations easier
qonlinetts.h
Go to the documentation of this file.
1/*
2 * Copyright © 2018-2021 Hennadii Chernyshchyk <genaloner@gmail.com>
3 *
4 * This file is part of QOnlineTranslator.
5 *
6 * QOnlineTranslator is free library; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a get of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#ifndef QONLINETTS_H
22#define QONLINETTS_H
23
24#include <QMetaEnum>
25#include <QUrl>
26#include "qonlinetranslator.h"
27
28
32class QOnlineTts : public QObject
33{
34 Q_OBJECT
35 Q_DISABLE_COPY(QOnlineTts)
36
37 public:
38 enum Voice
39 {
40 // All
41 NoVoice = -1,
42 // Yandex
48 Omazh
49 };
50 Q_ENUM(Voice)
51
53 {
54 // All
55 NoEmotion = -1,
56 // Yandex
59 Evil
60 };
61 Q_ENUM(Emotion)
62
64 {
70 };
71
72 explicit QOnlineTts(QObject *parent = nullptr);
73
75 QList<QMediaContent> media() const;
76
77 TtsError error() const;
78 QString errorString() const;
79
80 static QString voiceCode(Voice voice);
81 static QString emotionCode(Emotion emotion);
82 static Emotion emotion(const QString &emotionCode);
83 static Voice voice(const QString &voiceCode);
84
85 private:
86 void setError(TtsError error, const QString &errorString);
87
88 QString languageApiCode(QOnlineTranslator::Engine engine, QOnlineTranslator::Language lang);
89 QString voiceApiCode(QOnlineTranslator::Engine engine, Voice voice);
90 QString emotionApiCode(QOnlineTranslator::Engine engine, Emotion emotion);
91
92 static const QMap<Emotion, QString> s_emotionCodes;
93 static const QMap<Voice, QString> s_voiceCodes;
94
95 static constexpr int s_googleTtsLimit = 200;
96 static constexpr int s_yandexTtsLimit = 1400;
97
98 QList<QMediaContent> m_media;
99 QString m_errorString;
100 TtsError m_error = NoError;
101};
102
103#endif // QONLINETTS_H
104
Q Online Tts.
Definition: qonlinetts.h:33
QString errorString() const
errorString
Definition: qonlinetts.cpp:152
static Voice voice(const QString &voiceCode)
voice
Definition: qonlinetts.cpp:192
QOnlineTts(QObject *parent=nullptr)
QOnlineTts.
Definition: qonlinetts.cpp:50
@ Good
Good
Definition: qonlinetts.h:58
@ NoEmotion
NoEmotion
Definition: qonlinetts.h:55
@ Neutral
Neutral
Definition: qonlinetts.h:57
@ Evil
Evil
Definition: qonlinetts.h:59
TtsError error() const
error
Definition: qonlinetts.cpp:160
static Emotion emotion(const QString &emotionCode)
emotion
Definition: qonlinetts.cpp:184
static QString emotionCode(Emotion emotion)
emotionCode
Definition: qonlinetts.cpp:176
QList< QMediaContent > media() const
media
Definition: qonlinetts.cpp:144
@ Jane
Jane
Definition: qonlinetts.h:45
@ NoVoice
NoVoice
Definition: qonlinetts.h:41
@ Ermil
Ermil
Definition: qonlinetts.h:44
@ Omazh
Omazh
Definition: qonlinetts.h:48
@ Zahar
Zahar
Definition: qonlinetts.h:43
@ Oksana
Oksana
Definition: qonlinetts.h:46
@ Alyss
Alyss
Definition: qonlinetts.h:47
void generateUrls(const QString &text, QOnlineTranslator::Engine engine, QOnlineTranslator::Language lang, Voice voice=NoVoice, Emotion emotion=NoEmotion)
generateUrls
Definition: qonlinetts.cpp:57
@ UnsupportedEmotion
UnsupportedEmotion
Definition: qonlinetts.h:69
@ UnsupportedVoice
UnsupportedVoice
Definition: qonlinetts.h:68
@ NoError
NoError
Definition: qonlinetts.h:65
@ UnsupportedEngine
UnsupportedEngine
Definition: qonlinetts.h:66
@ UnsupportedLanguage
UnsupportedLanguage
Definition: qonlinetts.h:67
static QString voiceCode(Voice voice)
voiceCode
Definition: qonlinetts.cpp:168