Skip to main content

Python SDK for Voxygen TTS HTTP API

This folder provides lightweight Python tools for interacting with a Voxygen TTS HTTP API, including the Voxygen Cloud API (https://api.voxygen.fr/) or local deployments.


Python SDK Structure

├─/examples       # Examples of common usages for the Python Client
├─/tts            # Python package
| └─ client.py    # Python Client
├─ speak.py       # Python CLI
└─ README.md      # This documentation

Installation

Install the official Voxygen Python client from PyPI:

pip install voxygen-tts

Client usage examples in your own Python application

Convert text to audio stream

from voxygen.tts import Client

parameters = {
    "text": "Hello. How can I help you ?",
    "language": "en-US",
    "voice": "Mary"
}

with Client(token="YOUR_TOKEN") as client:
    request = client.build_request(parameters)
    response = client.send(request)

    if client.content_type(response) == voxygen_client.MimeType.AUDIO:
        while data := client.read_data(response):
            print(f"received chunk of audio data: {len(data)} bytes")

Retrieve all available voices from your subscription

from voxygen.tts import Client

with Client(token="YOUR_TOKEN", url="info") as client:

    request = client.build_request({})
    response = client.send(request)

    if response.status == 200:
        info = client.read_json(response)

        print("Available voices:")
        for voice in info.get("voices", []):
            print(voice["name"])
    else:
        print("Error:", response.status, response.read().decode())

Command-Line usage examples

The CLI tool is called voxygen-speak and can call any compatible Voxygen TTS API.

Quick Start example

export VOXYGEN_TOKEN="your_token_here"
voxygen-speak 
  -t $VOXYGEN_TOKEN \
  -p text="Hello world" \
  -p voice=Mary \
  -o output.wav

If you don’t want to pass the -t (--token) option for each command, you can modify the default value of token in main() from the speak.py file

You can also run the CLI tool directly with Python:

python speak.py [options]

Generate an audio from a text file

voxygen-speak \
  -i input-text.txt \
  -o output.wav

JSON response mode

voxygen-speak \
  -j \
  -p text="Hello as JSON" \
  -p voice=Mary

** Retrieve from /tts/info request **

voxygen-speak info

CLI options

Option Long Description
-t TOKEN --token TOKEN Bearer token authentication
-p key=value --param key=value TTS parameters
-i file — Read text from file
-o file — Save audio to file
-j --json Request JSON response
-h --help Help text

Troubleshooting

401 Unauthorized

Common causes:

  • Token not provided
  • Invalid token
  • Token expired or revoked

400 Bad Request

Common causes:

  • Missing required TTS parameters
  • Incorrect endpoint URL (for example, missing or extra /tts)
  • Unsupported parameter values

503 Service Unavailable

The service may be temporarily unavailable due to high load or maintenance.

The Python client automatically retries requests when a 503 Service Unavailable response is returned.

Default retry settings:

  • 6 retries
  • 10 seconds between attempts

You can customize this behavior:

client.set_retry_policy(max_retries=2, retry_after=5)

Retries apply only to 503 responses. Other errors are returned immediately.

If the issue persists after multiple retries, wait a few minutes before sending a new request.

Metadata

Release files for voxygen-tts 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for voxygen-tts 1.4.0
File Size Uploaded
voxygen_tts-1.4.0.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for voxygen-tts 1.4.0
File Interpreter ABI Platform
voxygen_tts-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.7 kB

Release files / voxygen_tts-1.4.0.tar.gz

Download URL voxygen_tts-1.4.0.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0dfee681162fff5804f1aee3e7e0227e3ce0d6aba7c99466b913d5933c0ed7e0
BLAKE2b-256 checksum
How to use checksums
a0280a727485c8dbc75bf30a85955a155525facf8126a3149c43f78e30c59aa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / voxygen_tts-1.4.0-py3-none-any.whl

Download URL voxygen_tts-1.4.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4720495be35be696169c4214924d593b53ca1a60ed95920c9dfc3f3bafb22080
BLAKE2b-256 checksum
How to use checksums
458058a5788bb17830fe23fe2f3fb0b4f985783382361b2c3256825e4c22fca4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page