tts.google#

Description#

Advanced text-to-speech engine that leverages the Google Cloud TTS API. See https://cloud.google.com/text-to-speech/docs/quickstart-client-libraries#client-libraries-install-python for how to enable the API on your account and get your credentials.

param kwargs:

Extra arguments to be passed to the TtsPlugin constructor.

Configuration#

tts.google:
  # [Optional]
  # Language code, see
  # https://cloud.google.com/text-to-speech/docs/basics for supported
  # languages.
  # language: en-US  # type=str

  # [Optional]
  # Voice type, see
  # https://cloud.google.com/text-to-speech/docs/basics for supported
  # voices.
  # voice:   # type=Optional[str]

  # [Optional]
  # Voice gender (MALE, FEMALE or NEUTRAL).
  # gender: FEMALE  # type=str

  # [Optional]
  # Where your GCloud credentials for TTS are
  # stored, see https://cloud.google.com/text-to-speech/docs/basics.
  # credentials_file: ~/.credentials/platypush/google/platypush-tts.json  # type=str

Dependencies#

pip

pip install numpy sounddevice google-cloud-texttospeech

Alpine

apk add py3-numpy ffmpeg portaudio-dev

Debian

apt install python3-numpy portaudio19-dev ffmpeg

Fedora

yum install python-numpy portaudio-devel ffmpeg

Arch Linux

pacman -S python-numpy python-sounddevice portaudio ffmpeg

Actions#

Module reference#

class platypush.plugins.tts.google.TtsGooglePlugin(language: str = 'en-US', voice: str | None = None, gender: str = 'FEMALE', credentials_file: str = '~/.credentials/platypush/google/platypush-tts.json', **kwargs)[source]#

Bases: TtsPlugin

Advanced text-to-speech engine that leverages the Google Cloud TTS API. See https://cloud.google.com/text-to-speech/docs/quickstart-client-libraries#client-libraries-install-python for how to enable the API on your account and get your credentials.

__init__(language: str = 'en-US', voice: str | None = None, gender: str = 'FEMALE', credentials_file: str = '~/.credentials/platypush/google/platypush-tts.json', **kwargs)[source]#
Parameters:
say(text: str, language: str | None = None, voice: str | None = None, gender: str | None = None, **player_args)[source]#

Say a phrase.

Parameters:
  • text – Text to say.

  • language – Language code override.

  • voice – Voice type override.

  • gender – Gender override.

  • player_args – Extends the additional arguments to be passed to platypush.plugins.sound.SoundPlugin.play() (like volume, duration, channels etc.).

stop()#

Stop the playback.