The QTextToSpeech class provides a convenient access to text-to-speech engines. 更多...
| 頭: | #include <QTextToSpeech> |
| qmake: | QT += texttospeech |
| 繼承: | QObject |
| enum | State { Ready, Speaking, Paused, BackendError } |
| 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 |
| QTextToSpeech::State | state () const |
| QVoice | voice () const |
| double | volume () const |
| 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 () |
| 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 ) |
| void | volumeChanged (double volume ) |
| QStringList | availableEngines () |
| const QMetaObject | staticMetaObject |
The QTextToSpeech class provides a convenient access to text-to-speech engines.
使用
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
被使用默認情況下。
| 常量 | 值 | 描述 |
|---|---|---|
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. |
This property holds the current locale in use. By default, the system locale is used.
訪問函數:
| QLocale | locale () const |
| void | setLocale (const QLocale & locale ) |
通知程序信號:
| void | localeChanged (const QLocale & locale ) |
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 ) |
通知程序信號:
| void | pitchChanged (double pitch ) |
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 ) |
通知程序信號:
| void | rateChanged (double rate ) |
This property holds the current state of the speech synthesizer. Use say () to start synthesizing text with the current voice and locale.
訪問函數:
| QTextToSpeech::State | state () const |
通知程序信號:
| void | stateChanged (QTextToSpeech::State state ) |
This property holds the current voice used for the speech.
訪問函數:
| QVoice | voice () const |
| void | setVoice (const QVoice & voice ) |
通知程序信號:
| void | voiceChanged (const QVoice & voice ) |
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 ) |
通知程序信號:
| void | volumeChanged (int volume ) |
| void | volumeChanged (double volume ) |
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.
若插件加載失敗, QTextToSpeech::state () 返迴 QTextToSpeech::BackendError .
另請參閱 availableEngines ().
Loads a text-to-speech engine from a plug-in that matches parameter engine and constructs a QTextToSpeech object as the child of parent .
若 engine is empty, the default engine plug-in is used. The default engine may be platform-specific.
若插件加載失敗, QTextToSpeech::state () 返迴 QTextToSpeech::BackendError .
另請參閱 availableEngines ().
[static]
QStringList
QTextToSpeech::
availableEngines
()
Gets the list of supported text-to-speech engine plug-ins.
Gets a vector of locales that are currently supported.
注意: On some platforms these can change, for example, when the backend changes synthesizers.
Gets a vector of voices available for the current locale.
注意: if no locale has been set, the system locale is used.
[slot]
void
QTextToSpeech::
pause
()
暫停當前語音。
注意:
另請參閱 resume ().
[slot]
void
QTextToSpeech::
resume
()
Resume speaking after pause () 被調用。
另請參閱 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 () 信號采用 Ready state is emitted.
[slot]
void
QTextToSpeech::
setLocale
(const
QLocale
&
locale
)
設置 locale to a given locale if possible. The default is the system locale.
注意: setter 函數對於特性 locale .
另請參閱 locale ().
[slot]
void
QTextToSpeech::
setVoice
(const
QVoice
&
voice
)
設置 voice to use.
注意: On some platforms, setting the voice changes other voice attributes such as locale, pitch, and so on. These changes trigger the emission of signals.
注意: setter 函數對於特性 voice .
另請參閱 voice ().
[slot]
void
QTextToSpeech::
stop
()
Stop the text that is being read.