digiKam Developer Documentation
Professional Photo Management with the Power of Open Source
Loading...
Searching...
No Matches
Digikam::DOnlineTts Class Reference

Provides TTS URL generation. More...

+ Inheritance diagram for Digikam::DOnlineTts:

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.
 

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

Example:

tts.generateUrls(QLatin1String("Hello World!"), DOnlineTranslator::Google, DOnlineTranslator::English);
// Get list of Urls to play with media player.
QList<QUrl> urls = tts.media();

Member Enumeration Documentation

◆ Emotion

Used only by Yandex.

◆ TtsError

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

Used only by Yandex.

Constructor & Destructor Documentation

◆ DOnlineTts()

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

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

Parameters
parentthe parent object

Member Function Documentation

◆ emotion()

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

Used only by Yandex.

Parameters
emotionCodeemotion code
Returns
corresponding emotion

◆ emotionCode()

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

Used only by Yandex.

Parameters
emotionthe emotion to use
Returns
code for emotion

◆ error()

DOnlineTts::TtsError Digikam::DOnlineTts::error ( ) const

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

◆ errorString()

QString Digikam::DOnlineTts::errorString ( ) const

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

Returns
last error string

◆ generateUrls()

void Digikam::DOnlineTts::generateUrls ( const QString &  text,
DOnlineTranslator::Engine  engine,
DOnlineTranslator::Language  lang,
Voice  voice = NoVoice,
Emotion  emotion = NoEmotion 
)

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)

◆ media()

QList< QUrl > Digikam::DOnlineTts::media ( ) const
Returns
List of generated URLs

◆ voice()

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

Used only by Yandex.

Parameters
voiceCodevoice code
Returns
corresponding voice

◆ voiceCode()

QString Digikam::DOnlineTts::voiceCode ( Voice  voice)
static
Parameters
voicethe voice to use
Returns
code for voice