Skip to main content

MkDocs plugin for generating and serving Piper text-to-speech page audio

Project description

mkdocs-piper-tts

An MkDocs plugin that generates Piper text-to-speech audio for pages and adds an HTML audio control through the piper_tts_button template helper.

Install

pip install mkdocs-piper-tts

For CUDA synthesis, install the CUDA extra on a compatible CUDA 12 system:

pip install 'mkdocs-piper-tts[cuda]'

The plugin invokes ffmpeg to encode MP3 files, so ffmpeg must be available on PATH when generating audio.

Piper Version Policy

This package intentionally pins piper-tts==1.2.0. That release is MIT licensed and is compatible with this package's MIT license. Do not upgrade Piper without first reviewing the license of the target release and its runtime dependencies.

Configure

Store Piper .onnx models and their JSON configuration files outside the published documentation source, then enable the plugin in mkdocs.yml:

plugins:
  - piper-tts:
      model_dir: models/piper-tts
      asset_dir: assets/piper-tts
      audio_dir: audio
      use_cuda: true
      batch_size: 2
      languages:
        en:
          model: en_US-amy-medium.onnx
          label: Listen
        de:
          model: de_DE-thorsten-medium.onnx
          label: Vorlesen

Set lang in a page's front matter. The plugin caches generated MP3 files and sidecar metadata under <docs_dir>/<asset_dir>/<audio_dir>. Cached files are reused when both page source and plugin code are unchanged.

Set generate_audio: false, or PIPER_TTS_GENERATE_AUDIO=false, for cache-only builds. In this mode, missing or stale audio fails the build instead of initializing Piper; use it in CI after restoring a verified audio cache artifact.

Render the control in an MkDocs template with:

{{ piper_tts_button(page) }}

For a more extensive production example, see retoweber.info, which uses this plugin for its English and German pages.

Example And Tests

examples/simple-site is a complete, minimal MkDocs project. It is in the source repository, not the published wheel. Put a Piper model and matching .onnx.json file in examples/simple-site/models, then run:

cd examples/simple-site
mkdocs build --strict

The example uses CPU synthesis by default. Set use_cuda: true in its mkdocs.yml after installing the CUDA extra on a system with a compatible GPU.

The repository's end-to-end tests build the example once with CPU and once with CUDA. They download a cached test voice unless PIPER_TTS_TEST_MODEL_DIR names a directory containing a model and matching configuration:

pip install -e '.[test]'
pytest -m 'not cuda'
PIPER_TTS_TEST_MODEL_DIR=/path/to/models pytest -m cuda

The CUDA test skips when ONNX Runtime cannot create a CUDA execution provider. ffmpeg must be available on PATH for either test.

Published Example

Every release rebuilds the CPU example from an empty generated-output directory, runs its CPU end-to-end test, and deploys the result to mkdocs-piper-tts.retoweber.info. The deployed site includes an E2E Build Status page with the release tag and build timestamp. The workflow deliberately does not cache models, generated audio, or site output.

Releases

Tags named v* build and publish a wheel and source distribution with PyPI trusted publishing. For each release, update the version in pyproject.toml, commit it, and push a matching tag such as v0.2.0. PyPI versions are immutable, so never reuse a published version or tag.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs_piper_tts-0.2.2.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_piper_tts-0.2.2-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_piper_tts-0.2.2.tar.gz.

File metadata

  • Download URL: mkdocs_piper_tts-0.2.2.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mkdocs_piper_tts-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c079b1058b59246bfd6e29b7f573405e796361f78f6d2a8c2c7b3d7d16e2b003
MD5 aaf6efaba908568f84a8fa23672d1db4
BLAKE2b-256 796f39db029656a47eaa6a2883a704d60551c368ab90f06df9cefd01e21dfd7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkdocs_piper_tts-0.2.2.tar.gz:

Publisher: publish-pypi.yml on risajef/mkdocs-piper-tts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mkdocs_piper_tts-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_piper_tts-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 72a84db716f26c182a3ee5c111ffefc4c07c8cdaf8170ece91a4572c557f0431
MD5 6fc136959dcf9e414d8247de24fac7ad
BLAKE2b-256 b9d40f85b6e0cd44f11547903f30d5c8d87f195be6adb39bf8d00bbb1646798b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkdocs_piper_tts-0.2.2-py3-none-any.whl:

Publisher: publish-pypi.yml on risajef/mkdocs-piper-tts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page