QTextToSpeech Class
The QTextToSpeech class provides a convenient access to text-to-speech engines 更多...
头文件: | #include <QTextToSpeech> |
qmake: | QT += texttospeech |
基类: | QObject |
公有类型
enum | State { Ready, Speaking, Paused, BackendError } |
属性
- 1 个属性继承自 QObject
公有函数
QTextToSpeech(QObject *parent = nullptr) | |
QTextToSpeech(const QString &engine, QObject *parent = nullptr) | |
QVector<QLocale> | availableLocales() const |
QVector<QVoice> | availableVoices() const |
QLocale | locale() const |
double | pitch() const |
double | rate() const |
State | state() const |
QVoice | voice() const |
double | volume() const |
- 32 个公有函数继承自 QObject
公有槽函数
void | pause() |
void | resume() |
void | say(const QString &text) |
void | setLocale(const QLocale &locale) |
void | setPitch(double pitch) |
void | setRate(double rate) |
void | setVoice(const QVoice &voice) |
void | setVolume(double volume) |
void | stop() |
- 1 个公有槽函数继承自 QObject
信号
void | localeChanged(const QLocale &locale) |
void | pitchChanged(double pitch) |
void | rateChanged(double rate) |
void | stateChanged(QTextToSpeech::State state) |
void | voiceChanged(const QVoice &voice) |
void | volumeChanged(int volume) |
- 2 个信号继承自 QObject
静态公有成员
QStringList | availableEngines() |
- 10 个静态公有成员继承自 QObject
其他继承的成员
详细描述
The QTextToSpeech class provides a convenient access to text-to-speech engines
Use say() to start synthesizing text. It is possible to specify the language with setLocale(). To select between the available voices use setVoice(). The languages and voices depend on the available synthesizers on each platform. On Linux, speech-dispatcher
is used by default.
成员类型
enum QTextToSpeech::State
Constant | Value | Description |
---|---|---|
QTextToSpeech::Ready | 0 | The synthesizer is ready to start a new text. This is also the state after a text was finished. |
QTextToSpeech::Speaking | 1 | The current text is being spoken. |
QTextToSpeech::Paused | 2 | The synthesis was paused and can be resumed with resume(). |
QTextToSpeech::BackendError | 3 | The backend was unable to synthesize the current string. |
属性
locale : QLocale
This property holds the current locale in use. By default, the system locale is used.
访问函数:
QLocale | locale() const |
void | setLocale(const QLocale &locale) |
Notifier signal:
void | localeChanged(const QLocale &locale) |
pitch : double
This property holds the voice pitch, ranging from -1.0 to 1.0. The default of 0.0 is the normal speech pitch.
访问函数:
double | pitch() const |
void | setPitch(double pitch) |
Notifier signal:
void | pitchChanged(double pitch) |
rate : double
This property holds the current voice rate, ranging from -1.0 to 1.0. The default value of 0.0 is normal speech flow.
访问函数:
double | rate() const |
void | setRate(double rate) |
Notifier signal:
void | rateChanged(double rate) |
state : const State
This property holds the current state of the speech synthesizer. Use say() to start synthesizing text with the current voice and locale.
访问函数:
State | state() const |
Notifier signal:
void | stateChanged(QTextToSpeech::State state) |
voice : QVoice
This property holds the current voice used for the speech.
访问函数:
QVoice | voice() const |
void | setVoice(const QVoice &voice) |
Notifier signal:
void | voiceChanged(const QVoice &voice) |
volume : int
This property holds the current volume, ranging from 0.0 to 1.0. The default value is the platform's default volume.
访问函数:
double | volume() const |
void | setVolume(double volume) |
Notifier signal:
void | volumeChanged(int volume) |
成员函数
QTextToSpeech::QTextToSpeech(QObject *parent = nullptr)
Loads a text-to-speech engine from a plug-in that uses the default engine plug-in and constructs a QTextToSpeech object as the child of parent.
The default engine may be platform-specific.
If the plugin fails to load, QTextToSpeech::state() returns QTextToSpeech::BackendError.
参见 availableEngines().
QTextToSpeech::QTextToSpeech(const QString &engine, QObject *parent = nullptr)
Loads a text-to-speech engine from a plug-in that matches parameter engine and constructs a QTextToSpeech object as the child of parent.
If engine is empty, the default engine plug-in is used. The default engine may be platform-specific.
If the plugin fails to load, QTextToSpeech::state() returns QTextToSpeech::BackendError.
参见 availableEngines().
[static]
QStringList QTextToSpeech::availableEngines()
Gets the list of supported text-to-speech engine plug-ins.
QVector<QLocale> QTextToSpeech::availableLocales() const
Gets a vector of locales that are currently supported.
Note: On some platforms these can change, for example, when the backend changes synthesizers.
QVector<QVoice> QTextToSpeech::availableVoices() const
Gets a vector of voices available for the current locale.
Note: if no locale has been set, the system locale is used.
[slot]
void QTextToSpeech::pause()
Pauses the current speech.
Note:
- This function depends on the platform and the backend. It may not work at all, it may take several seconds before it takes effect, or it may pause instantly. Some synthesizers will look for a break that they can later resume from, such as a sentence end.
- Due to Android platform limitations, pause() stops what is presently being said, while resume() starts the previously queued sentence from the beginning.
参见 resume().
[slot]
void QTextToSpeech::resume()
Resume speaking after pause() has been called.
参见 pause().
[slot]
void QTextToSpeech::say(const QString &text)
Start synthesizing the text. This function will start the asynchronous reading of the text. The current state is available using the state property. Once the synthesis is done, a stateChanged() signal with the Ready state is emitted.
[slot]
void QTextToSpeech::setLocale(const QLocale &locale)
Sets the locale to a given locale if possible. The default is the system locale.
Note: Setter function for property locale.
参见 locale().
[slot]
void QTextToSpeech::setVoice(const QVoice &voice)
Sets the voice to use.
Note: On some platforms, setting the voice changes other voice attributes such as locale, pitch, and so on. These changes trigger the emission of signals.
Note: Setter function for property voice.
参见 voice().
[slot]
void QTextToSpeech::stop()
Stop the text that is being read.