Skip to main content

Python HTTP client for Voxygen TTS API

Project description

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.

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

voxygen_tts-0.1.1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

voxygen_tts-0.1.1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file voxygen_tts-0.1.1.tar.gz.

File metadata

  • Download URL: voxygen_tts-0.1.1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for voxygen_tts-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7fd45d3142a6a14e8b858201e6c638b6ab449623c4f3d9eaf0b9d855439b8e6f
MD5 73f7a443d6aae0eeac0e3fb5fe2df3ce
BLAKE2b-256 648ec0ae9efaed85211482c7a196be6f4e3b7dc208aaf8cf775848989c5b226f

See more details on using hashes here.

File details

Details for the file voxygen_tts-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: voxygen_tts-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for voxygen_tts-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 176213d5b6debfab33971495cedfa333dad338e78d8097758838c30dfac63904
MD5 c9adeba92ba37af32c03635ded47888d
BLAKE2b-256 914602678f60bdd457353e1be6bf75644c62edc26e3ecbb5ea649d86bea4adfe

See more details on using hashes here.

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