tts#
Description#
Default Text-to-Speech plugin. It leverages Google Translate’s unofficial frontend API.
- param player_args:
Additional arguments to be passed to SoundPlugin.play (like volume, duration, channels etc.).
Configuration#
tts:
# [Optional]
# Language code (default: ``en-US``).
# language: en-US
# [Optional]
# Audio output device to use for playback.
# Supported formats: PortAudio/sounddevice device index,
# PortAudio/sounddevice device name, or PulseAudio/PipeWire sink name
# (e.g. ``alsa_output.pci-...``; requires ``pactl``). If specified,
# it is passed as the ``device`` argument to
# `SoundPlugin.play <https://docs.platypush.tech/platypush/plugins/sound.html#platypush.plugins.sound.SoundPlugin.play>`_.
# output_device: # type=int | str | None
# [Optional]
# Playback volume, as a percentage. ``100`` means
# unchanged, values below ``100`` attenuate, and values above ``100``
# amplify with clipping in the playback path. It is passed as the
# ``volume`` argument to `SoundPlugin.play <https://docs.platypush.tech/platypush/plugins/sound.html#platypush.plugins.sound.SoundPlugin.play>`_.
# output_volume: # type=float | None
Dependencies#
pip
pip install numpy sounddevice num2words
Alpine
apk add py3-numpy portaudio-dev ffmpeg
Debian
apt install portaudio19-dev python3-numpy ffmpeg
Fedora
yum install python-numpy portaudio-devel ffmpeg
Arch Linux
pacman -S portaudio python-numpy ffmpeg python-sounddevice
Actions#
Module reference#
- class platypush.plugins.tts.TtsPlugin(language='en-US', output_device: int | str | None = None, output_volume: float | None = None, **player_args)[source]#
Bases:
PluginDefault Text-to-Speech plugin. It leverages Google Translate’s unofficial frontend API.
- __init__(language='en-US', output_device: int | str | None = None, output_volume: float | None = None, **player_args)[source]#
- Parameters:
language – Language code (default:
en-US).output_device – Audio output device to use for playback. Supported formats: PortAudio/sounddevice device index, PortAudio/sounddevice device name, or PulseAudio/PipeWire sink name (e.g.
alsa_output.pci-...; requirespactl). If specified, it is passed as thedeviceargument toplatypush.plugins.sound.SoundPlugin.play().output_volume – Playback volume, as a percentage.
100means unchanged, values below100attenuate, and values above100amplify with clipping in the playback path. It is passed as thevolumeargument toplatypush.plugins.sound.SoundPlugin.play().player_args – Additional arguments to be passed to
platypush.plugins.sound.SoundPlugin.play()(like volume, duration, channels etc.).
- say(text: str, language: str | None = None, **player_args)[source]#
Say some text.
- Parameters:
text – Text to say.
language – Language code override.
player_args – Extends the additional arguments to be passed to
platypush.plugins.sound.SoundPlugin.play()(like volume, duration, channels, output_device, output_volume etc.).output_deviceaccepts a PortAudio/sounddevice device index, PortAudio/sounddevice device name, or PulseAudio/PipeWire sink name (requirespactl).output_volumeis an alias for the underlying playbackvolumepercentage.