PhxDemo.TTS.Piper (phx_demo v0.1.1)

Copy Markdown View Source

The default narrator: Piper, a free, open-source TTS that runs locally on macOS and Linux, so it needs no API key and works in CI.

Install it once with mix phx_demo.piper.setup. That creates a private Python virtualenv in the user cache directory and downloads the default voice. A piper already on your PATH is used if present.

Options:

  • :voice: a Piper voice name (default "en_US-lessac-medium"). See https://huggingface.co/rhasspy/piper-voices. Downloaded on first use.
  • :model: path to an .onnx voice file instead of :voice
  • :executable: path to the piper binary
  • :length_scale: speaking pace; above 1.0 is slower (default 1.0)

Summary

Functions

Downloads a voice (model and its config) into voices_dir/0.

Path to the voice model, downloading it if needed.

The piper executable: the :executable option, the private virtualenv, or PATH.

Directory of the private virtualenv created by mix phx_demo.piper.setup.

Download URL for a voice name.

Directory where voices are downloaded.

Functions

download_voice(voice)

Downloads a voice (model and its config) into voices_dir/0.

ensure_model(opts \\ [])

Path to the voice model, downloading it if needed.

executable(opts \\ [])

The piper executable: the :executable option, the private virtualenv, or PATH.

venv_dir()

Directory of the private virtualenv created by mix phx_demo.piper.setup.

voice_url(voice)

Download URL for a voice name.

iex> PhxDemo.TTS.Piper.voice_url("en_US-lessac-medium")
"https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/lessac/medium/en_US-lessac-medium.onnx"

voices_dir()

Directory where voices are downloaded.