libosmscout 0.1
Loading...
Searching...
No Matches
osmscout::TTSEngine Class Referenceabstract

Abstract text-to-speech engine. More...

#include <TTSEngine.h>

+ Inheritance diagram for osmscout::TTSEngine:

Public Types

enum class  TTSEngineState { Idle , Initializing , Synthesizing , Error }
 State of a TTSEngine, useful for showing synthesis progress in the UI (initial synthesis of a message may take a noticeable amount of time). More...
 

Public Slots

virtual void initVoice (const Voice &voice)=0
 Initialize the engine for the given voice.
 
virtual void playMessage (QString message)=0
 Prepare the message (when it is not cached yet) and play it right away.
 
virtual void prepareMessage (QString message)=0
 Synthesize the message to an audio file (cached in a temporary directory) without playing it.
 

Signals

void error (const QString &message)
 Emitted when the engine encounters an error (e.g.
 
void playAudioFilesRequest (const QList< QUrl > &audioFiles)
 
void stateChange (TTSEngineState state)
 Emitted whenever the engine's state changes, e.g.
 

Public Member Functions

TTSEngineState getState () const
 
virtual Voice getVoice ()=0
 
TTSEngineoperator= (const TTSEngine &)=delete
 
TTSEngineoperator= (TTSEngine &&)=delete
 
 Q_ENUM (TTSEngineState)
 
 TTSEngine ()
 
 TTSEngine (const TTSEngine &)=delete
 
 TTSEngine (TTSEngine &&)=delete
 
 ~TTSEngine () override
 

Protected Member Functions

virtual void cleanCache ()
 Called on the engine thread when the background thread starts.
 

Protected Attributes

QThread * thread
 engine background thread (owns itself, deleted on finish)
 

Properties

TTSEngineState state {TTSEngineState::Idle}
 current state of the engine
 

Detailed Description

Abstract text-to-speech engine.

It synthesizes spoken navigation instructions and plays them through the provided VoiceCorePlayer.

Speech synthesis may be a slow, synchronous operation (see PiperTTSEngine), so the engine runs in its own background thread. All operations (initVoice, prepareMessage, playMessage) are executed asynchronously on that thread, they should be invoked through a queued connection (e.g. QMetaObject::invokeMethod with Qt::QueuedConnection).

The background thread is created and started by the base constructor. When it starts, cleanCache() is invoked on the engine thread (default implementation is empty, a derived class may override it to prune its cache).

Member Enumeration Documentation

◆ TTSEngineState

State of a TTSEngine, useful for showing synthesis progress in the UI (initial synthesis of a message may take a noticeable amount of time).

Enumerator
Idle 

engine is idle, not synthesizing anything at the moment

Initializing 

engine is initializing the voice (e.g. loading a model)

Synthesizing 

engine is currently synthesizing a message

Error 

the last operation failed (see TTSEngine::error signal for details)

Constructor & Destructor Documentation

◆ TTSEngine() [1/3]

osmscout::TTSEngine::TTSEngine ( )

References cleanCache(), and thread.

◆ TTSEngine() [2/3]

osmscout::TTSEngine::TTSEngine ( const TTSEngine )
delete

◆ TTSEngine() [3/3]

osmscout::TTSEngine::TTSEngine ( TTSEngine &&  )
delete

◆ ~TTSEngine()

osmscout::TTSEngine::~TTSEngine ( )
override

References thread.

Member Function Documentation

◆ cleanCache()

void osmscout::TTSEngine::cleanCache ( )
protectedvirtual

Called on the engine thread when the background thread starts.

The default implementation does nothing; a derived class may override it to clean up its on-disk cache. Runs on the engine thread.

Reimplemented in osmscout::PiperTTSEngine.

Referenced by TTSEngine().

◆ error

void osmscout::TTSEngine::error ( const QString &  message)
signal

Emitted when the engine encounters an error (e.g.

synthesis or voice loading failure). message is a localized, human readable description suitable for direct display in the UI.

Referenced by osmscout::PiperTTSEngine::initVoice().

◆ getState()

TTSEngineState osmscout::TTSEngine::getState ( ) const
inline

◆ getVoice()

virtual Voice osmscout::TTSEngine::getVoice ( )
pure virtual

◆ initVoice

virtual void osmscout::TTSEngine::initVoice ( const Voice voice)
pure virtualslot

Initialize the engine for the given voice.

Runs asynchronously on the engine thread.

Implemented in osmscout::PiperTTSEngine.

◆ operator=() [1/2]

TTSEngine & osmscout::TTSEngine::operator= ( const TTSEngine )
delete

◆ operator=() [2/2]

TTSEngine & osmscout::TTSEngine::operator= ( TTSEngine &&  )
delete

◆ playAudioFilesRequest

void osmscout::TTSEngine::playAudioFilesRequest ( const QList< QUrl > &  audioFiles)
signal

◆ playMessage

virtual void osmscout::TTSEngine::playMessage ( QString  message)
pure virtualslot

Prepare the message (when it is not cached yet) and play it right away.

Runs asynchronously on the engine thread.

Implemented in osmscout::PiperTTSEngine.

◆ prepareMessage

virtual void osmscout::TTSEngine::prepareMessage ( QString  message)
pure virtualslot

Synthesize the message to an audio file (cached in a temporary directory) without playing it.

Runs asynchronously on the engine thread.

Implemented in osmscout::PiperTTSEngine.

◆ Q_ENUM()

osmscout::TTSEngine::Q_ENUM ( TTSEngineState  )

◆ stateChange

void osmscout::TTSEngine::stateChange ( TTSEngineState  state)
signal

Emitted whenever the engine's state changes, e.g.

when it starts or finishes synthesizing a message. Useful for showing synthesis progress in the UI, as the initial synthesis of a message may take a while.

Referenced by osmscout::PiperTTSEngine::initVoice().

Member Data Documentation

◆ thread

QThread* osmscout::TTSEngine::thread
protected

engine background thread (owns itself, deleted on finish)

Referenced by TTSEngine(), and ~TTSEngine().

Property Documentation

◆ state

TTSEngineState osmscout::TTSEngine::state {TTSEngineState::Idle}
read

current state of the engine

Referenced by osmscout::PiperTTSEngine::initVoice().


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