digiKam
Loading...
Searching...
No Matches
Digikam::DOnlineTts Class Reference

Provides TTS URL generation. More...

#include <donlinetranslator.h>

+ Inheritance diagram for Digikam::DOnlineTts:

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.
 

Detailed Description

Provides TTS URL generation.

Example:

// Get list of Urls to play with media player.
QList<QUrl> urls = tts.media();
@ Google
Definition donlinetranslator.h:270
@ English
Definition donlinetranslator.h:158
Provides TTS URL generation.
Definition donlinetranslator.h:793
QList< QUrl > media() const
Generated media.
Definition donlinetranslator_tts.cpp:169
void generateUrls(const QString &text, DOnlineTranslator::Engine engine, DOnlineTranslator::Language lang, Voice voice=NoVoice, Emotion emotion=NoEmotion)
Create TTS urls.
Definition donlinetranslator_tts.cpp:32

Member Enumeration Documentation

◆ Emotion

Defines emotion to use.

Used only by Yandex.

Enumerator
NoEmotion 
Neutral 
Good 
Evil 

◆ TtsError

Indicates all possible error conditions found during the processing of the URLs generation.

Enumerator
NoError 

No error condition

UnsupportedEngine 

Specified engine does not support TTS

UnsupportedLanguage 

Unsupported language by specified engine

UnsupportedVoice 

Unsupported voice by specified engine

UnsupportedEmotion 

Unsupported emotion by specified engine

◆ Voice

Defines voice to use.

Used only by Yandex.

Enumerator
NoVoice 
Zahar 
Ermil 
Jane 
Oksana 
Alyss 
Omazh 

Constructor & Destructor Documentation

◆ DOnlineTts()

Digikam::DOnlineTts::DOnlineTts ( QObject *const  parent = nullptr)
explicit

Create object.

Constructs an object with empty data and with parent. You can use generateUrls() to create URLs for use in QMediaPlayer.

Parameters
parentthe parent object

◆ ~DOnlineTts()

Digikam::DOnlineTts::~DOnlineTts ( )
override

Member Function Documentation

◆ emotion()

DOnlineTts::Emotion Digikam::DOnlineTts::emotion ( const QString &  emotionCode)
static

Emotion from code.

Used only by Yandex.

Parameters
emotionCodeemotion code
Returns
corresponding emotion

References emotionCode(), NoEmotion, and Digikam::DOnlineTts::Private::s_emotionCodes.

Referenced by emotionCode(), and generateUrls().

◆ emotionCode()

QString Digikam::DOnlineTts::emotionCode ( Emotion  emotion)
static

Code of the emotion.

Used only by Yandex.

Parameters
emotionthe emotion to use
Returns
code for emotion

References emotion(), and Digikam::DOnlineTts::Private::s_emotionCodes.

Referenced by emotion().

◆ error()

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().

Returns
last error

References Digikam::DOnlineTts::Private::error.

◆ errorString()

QString Digikam::DOnlineTts::errorString ( ) const

Last error string.

A human-readable description of the last tts URL generation error that occurred.

Returns
last error string

References Digikam::DOnlineTts::Private::errorString.

◆ generateUrls()

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.

Parameters
textthe text to speak
engineonline translation engine
langtext language
voicethe voice to use (used only by Yandex)
emotionthe 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.

◆ media()

QList< QUrl > Digikam::DOnlineTts::media ( ) const

Generated media.

Returns
List of generated URLs

References Digikam::DOnlineTts::Private::media.

◆ voice()

DOnlineTts::Voice Digikam::DOnlineTts::voice ( const QString &  voiceCode)
static

Voice from code.

Used only by Yandex.

Parameters
voiceCodevoice code
Returns
corresponding voice

References NoVoice, Digikam::DOnlineTts::Private::s_voiceCodes, and voiceCode().

Referenced by generateUrls(), and voiceCode().

◆ voiceCode()

QString Digikam::DOnlineTts::voiceCode ( Voice  voice)
static

Code of the voice.

Parameters
voicethe voice to use
Returns
code for voice

References Digikam::DOnlineTts::Private::s_voiceCodes, and voice().

Referenced by voice().


The documentation for this class was generated from the following files: