QTextToSpeech¶
The
QTextToSpeech
class provides a convenient access to text-to-speech engines. More…
Synopsis¶
Functions¶
def
availableLocales
()def
availableVoices
()def
locale
()def
pitch
()def
rate
()def
state
()def
voice
()def
volume
()
Slots¶
Signals¶
def
localeChanged
(locale)def
pitchChanged
(pitch)def
rateChanged
(rate)def
stateChanged
(state)def
voiceChanged
(voice)def
volumeChanged
(volume)def
volumeChanged
(volume)
Static functions¶
def
availableEngines
()
Detailed Description¶
Use
say()
to start synthesizing text. It is possible to specify the language withsetLocale()
. To select between the available voices usesetVoice()
. The languages and voices depend on the available synthesizers on each platform. On Linux,speech-dispatcher
is used by default.
- class PySide2.QtTextToSpeech.QTextToSpeech([parent=None])¶
PySide2.QtTextToSpeech.QTextToSpeech(engine[, parent=None])
- param parent:
- param engine:
str
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 ofparent
.The default engine may be platform-specific.
If the plugin fails to load,
state()
returnsBackendError
.See also
Loads a text-to-speech engine from a plug-in that matches parameter
engine
and constructs aQTextToSpeech
object as the child ofparent
.If
engine
is empty, the default engine plug-in is used. The default engine may be platform-specific.If the plugin fails to load,
state()
returnsBackendError
.See also
- PySide2.QtTextToSpeech.QTextToSpeech.State¶
Constant
Description
QTextToSpeech.Ready
The synthesizer is ready to start a new text. This is also the state after a text was finished.
QTextToSpeech.Speaking
The current text is being spoken.
QTextToSpeech.Paused
The synthesis was paused and can be resumed with
resume()
.QTextToSpeech.BackendError
The backend was unable to synthesize the current string.
- static PySide2.QtTextToSpeech.QTextToSpeech.availableEngines()¶
- Return type:
list of strings
Gets the list of supported text-to-speech engine plug-ins.
- PySide2.QtTextToSpeech.QTextToSpeech.availableLocales()¶
- Return type:
Gets a vector of locales that are currently supported.
Note
On some platforms these can change, for example, when the backend changes synthesizers.
- PySide2.QtTextToSpeech.QTextToSpeech.availableVoices()¶
- Return type:
Gets a vector of voices available for the current locale.
Note
if no locale has been set, the system locale is used.
- PySide2.QtTextToSpeech.QTextToSpeech.locale()¶
- Return type:
This property holds the current locale in use. By default, the system locale is used.
- PySide2.QtTextToSpeech.QTextToSpeech.localeChanged(locale)¶
- Parameters:
locale –
PySide2.QtCore.QLocale
- PySide2.QtTextToSpeech.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, stops what is presently being said, while
resume()
starts the previously queued sentence from the beginning.
See also
- PySide2.QtTextToSpeech.QTextToSpeech.pitch()¶
- Return type:
double
This property holds the voice pitch, ranging from -1.0 to 1.0. The default of 0.0 is the normal speech pitch.
- PySide2.QtTextToSpeech.QTextToSpeech.pitchChanged(pitch)¶
- Parameters:
pitch –
double
- PySide2.QtTextToSpeech.QTextToSpeech.rate()¶
- Return type:
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.
- PySide2.QtTextToSpeech.QTextToSpeech.rateChanged(rate)¶
- Parameters:
rate –
double
- PySide2.QtTextToSpeech.QTextToSpeech.resume()¶
Resume speaking after
pause()
has been called.See also
- PySide2.QtTextToSpeech.QTextToSpeech.say(text)¶
- Parameters:
text – str
Start synthesizing the
text
. This function will start the asynchronous reading of the text. The current state is available using thestate
property. Once the synthesis is done, astateChanged()
signal with theReady
state is emitted.
- PySide2.QtTextToSpeech.QTextToSpeech.setLocale(locale)¶
- Parameters:
locale –
PySide2.QtCore.QLocale
This property holds the current locale in use. By default, the system locale is used.
- PySide2.QtTextToSpeech.QTextToSpeech.setPitch(pitch)¶
- Parameters:
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.
- PySide2.QtTextToSpeech.QTextToSpeech.setRate(rate)¶
- Parameters:
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.
- PySide2.QtTextToSpeech.QTextToSpeech.setVoice(voice)¶
- Parameters:
voice –
PySide2.QtTextToSpeech.QVoice
This property holds the current voice used for the speech.
- PySide2.QtTextToSpeech.QTextToSpeech.setVolume(volume)¶
- Parameters:
volume –
double
This property holds the current volume, ranging from 0.0 to 1.0. The default value is the platform’s default volume.
- PySide2.QtTextToSpeech.QTextToSpeech.state()¶
- Return type:
This property holds the current state of the speech synthesizer. Use
say()
to start synthesizing text with the current voice and locale.
- PySide2.QtTextToSpeech.QTextToSpeech.stop()¶
Stop the text that is being read.
- PySide2.QtTextToSpeech.QTextToSpeech.voice()¶
- Return type:
This property holds the current voice used for the speech.
- PySide2.QtTextToSpeech.QTextToSpeech.voiceChanged(voice)¶
- Parameters:
voice –
PySide2.QtTextToSpeech.QVoice
- PySide2.QtTextToSpeech.QTextToSpeech.volume()¶
- Return type:
double
This property holds the current volume, ranging from 0.0 to 1.0. The default value is the platform’s default volume.
- PySide2.QtTextToSpeech.QTextToSpeech.volumeChanged(volume)¶
- Parameters:
volume –
double
- PySide2.QtTextToSpeech.QTextToSpeech.volumeChanged(volume)
- Parameters:
volume – int
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.