tts.openai#

Description#

This plugin provides an interface to the OpenAI text-to-speech API.

It requires the platypush.plugins.openai.OpenaiPlugin plugin to be configured.

Configuration#

tts.openai:
  # [Optional]
  # Model to be used for the text-to-speech conversion.
  # See the `OpenAI API models documentation
  # <https://platform.openai.com/docs/models/tts>`_ for the list of
  # available models (default: ``tts-1``).
  # model: tts-1  # type=str

  # [Optional]
  # Default voice to be used. See the `OpenAI API
  # voices documentation
  # <https://platform.openai.com/docs/guides/text-to-speech/voice-options>`_
  # for the list of available voices (default: ``nova``).
  # voice: nova  # type=str

  # [Optional]
  # Default timeout for the API requests (default: 10s).
  # timeout: 10  # type=float

  # [Optional]
  # Language code (default: ``en-US``).
  # language: en-US

Dependencies#

pip

pip install sounddevice numpy

Alpine

apk add ffmpeg portaudio-dev py3-numpy

Debian

apt install ffmpeg portaudio19-dev python3-numpy

Fedora

yum install ffmpeg python-numpy portaudio-devel

Arch Linux

pacman -S ffmpeg python-numpy python-sounddevice portaudio

Actions#

Module reference#

class platypush.plugins.tts.openai.TtsOpenaiPlugin(model: str = 'tts-1', voice: str = 'nova', timeout: float = 10, **kwargs)[source]#

Bases: TtsPlugin

This plugin provides an interface to the OpenAI text-to-speech API.

It requires the platypush.plugins.openai.OpenaiPlugin plugin to be configured.

__init__(model: str = 'tts-1', voice: str = 'nova', timeout: float = 10, **kwargs)[source]#
Parameters:
  • model – Model to be used for the text-to-speech conversion. See the OpenAI API models documentation for the list of available models (default: tts-1).

  • voice – Default voice to be used. See the OpenAI API voices documentation for the list of available voices (default: nova).

  • timeout – Default timeout for the API requests (default: 10s).

say(text: str, *_, model: str | None = None, voice: str | None = None, **player_args)[source]#

Say some text.

Parameters:
  • text – Text to say.

  • model – Default model override.

  • voice – Default voice override.

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

stop()[source]#

Stop the playback.