|
libosmscout 0.1
|
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 |
| TTSEngine & | operator= (const TTSEngine &)=delete |
| TTSEngine & | operator= (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 | |
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).
|
strong |
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) |
| osmscout::TTSEngine::TTSEngine | ( | ) |
References cleanCache(), and thread.
|
delete |
|
delete |
|
override |
References thread.
|
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().
|
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().
|
inline |
|
pure virtual |
Implemented in osmscout::PiperTTSEngine.
Referenced by osmscout::InstalledVoicesModel::playTTSSample().
|
pure virtualslot |
Initialize the engine for the given voice.
Runs asynchronously on the engine thread.
Implemented in osmscout::PiperTTSEngine.
|
signal |
Referenced by osmscout::PiperTTSEngine::playMessage().
|
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.
|
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.
| osmscout::TTSEngine::Q_ENUM | ( | TTSEngineState | ) |
|
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().
|
protected |
engine background thread (owns itself, deleted on finish)
Referenced by TTSEngine(), and ~TTSEngine().
|
read |
current state of the engine
Referenced by osmscout::PiperTTSEngine::initVoice().