# `PhxDemo.TTS.Piper`
[🔗](https://github.com/thenatespack/phoenix_demo/blob/main/lib/phx_demo/tts/piper.ex#L1)

The default narrator: [Piper](https://github.com/OHF-Voice/piper1-gpl), 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)

# `download_voice`

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

# `ensure_model`

Path to the voice model, downloading it if needed.

# `executable`

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`

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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
