![]() |
digiKam
|
Provides TTS URL generation. More...
#include <donlinetranslator.h>
Classes | |
class | Private |
Public Types | |
enum | Emotion { NoEmotion = -1 , Neutral , Good , Evil } |
Defines emotion to use. More... | |
enum | TtsError { NoError , UnsupportedEngine , UnsupportedLanguage , UnsupportedVoice , UnsupportedEmotion } |
Indicates all possible error conditions found during the processing of the URLs generation. More... | |
enum | Voice { NoVoice = -1 , Zahar , Ermil , Jane , Oksana , Alyss , Omazh } |
Defines voice to use. More... | |
Public Member Functions | |
DOnlineTts (QObject *const parent=nullptr) | |
Create object. | |
TtsError | error () const |
Last error. | |
QString | errorString () const |
Last error string. | |
void | generateUrls (const QString &text, DOnlineTranslator::Engine engine, DOnlineTranslator::Language lang, Voice voice=NoVoice, Emotion emotion=NoEmotion) |
Create TTS urls. | |
QList< QUrl > | media () const |
Generated media. | |
~DOnlineTts () override | |
Static Public Member Functions | |
static Emotion | emotion (const QString &emotionCode) |
Emotion from code. | |
static QString | emotionCode (Emotion emotion) |
Code of the emotion. | |
static Voice | voice (const QString &voiceCode) |
Voice from code. | |
static QString | voiceCode (Voice voice) |
Code of the voice. | |
Provides TTS URL generation.
Example:
Indicates all possible error conditions found during the processing of the URLs generation.
|
explicit |
Create object.
Constructs an object with empty data and with parent. You can use generateUrls() to create URLs for use in QMediaPlayer.
parent | the parent object |
|
override |
|
static |
Emotion from code.
Used only by Yandex.
emotionCode | emotion code |
References emotionCode(), NoEmotion, and Digikam::DOnlineTts::Private::s_emotionCodes.
Referenced by emotionCode(), and generateUrls().
|
static |
Code of the emotion.
Used only by Yandex.
emotion | the emotion to use |
References emotion(), and Digikam::DOnlineTts::Private::s_emotionCodes.
Referenced by emotion().
DOnlineTts::TtsError Digikam::DOnlineTts::error | ( | ) | const |
Last error.
Error that was found during the generating tts. If no error was found, returns TtsError::NoError. The text of the error can be obtained by errorString().
References Digikam::DOnlineTts::Private::error.
QString Digikam::DOnlineTts::errorString | ( | ) | const |
Last error string.
A human-readable description of the last tts URL generation error that occurred.
References Digikam::DOnlineTts::Private::errorString.
void Digikam::DOnlineTts::generateUrls | ( | const QString & | text, |
DOnlineTranslator::Engine | engine, | ||
DOnlineTranslator::Language | lang, | ||
Voice | voice = NoVoice , |
||
Emotion | emotion = NoEmotion |
||
) |
Create TTS urls.
Splits text into parts (engines have a limited number of characters per request) and returns list with the generated API URLs to play.
text | the text to speak |
engine | online translation engine |
lang | text language |
voice | the voice to use (used only by Yandex) |
emotion | the emotion to use (used only by Yandex) |
References Digikam::DOnlineTranslator::Bing, emotion(), Digikam::DOnlineTranslator::Google, Digikam::DOnlineTranslator::LibreTranslate, Digikam::DOnlineTranslator::Lingva, Digikam::DOnlineTts::Private::media, NoEmotion, NoVoice, Digikam::DOnlineTts::Private::s_googleTtsLimit, Digikam::DOnlineTts::Private::s_yandexTtsLimit, UnsupportedEmotion, UnsupportedEngine, UnsupportedVoice, voice(), and Digikam::DOnlineTranslator::Yandex.
QList< QUrl > Digikam::DOnlineTts::media | ( | ) | const |
|
static |
Voice from code.
Used only by Yandex.
voiceCode | voice code |
References NoVoice, Digikam::DOnlineTts::Private::s_voiceCodes, and voiceCode().
Referenced by generateUrls(), and voiceCode().
|
static |
Code of the voice.
voice | the voice to use |
References Digikam::DOnlineTts::Private::s_voiceCodes, and voice().
Referenced by voice().