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 google-cloud-texttospeech numpy sounddevice

Alpine

apk add portaudio-dev py3-numpy ffmpeg

Debian

apt install python3-numpy ffmpeg portaudio19-dev

Fedora

yum install portaudio-devel python-numpy ffmpeg

Arch Linux

pacman -S python-sounddevice portaudio ffmpeg python-numpy

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.