Skip to main content

Python client for the Primvoices API

Project description

Prim Voices API Python Client

A Python client for interacting with the Prim Voices API.

Installation

pip install primvoices

Usage

from primvoices import Client
from primvoices.models import ClientConfig

# Initialize the client
client = Client(ClientConfig(
    api_key='your-api-key',
    # Optional: override the base URL
    # base_url='https://custom-api-url.com'
))

# Using context manager (recommended)
with Client(ClientConfig(api_key='your-api-key')) as primvoices:
    # Your code here
    pass

# Working with Voices
async def voice_examples():
    # List all voices
    voices = client.voices.list()
    print('Your voices:', voices.data)

    # List public voices
    public_voices = client.voices.list_public()
    print('Public voices:', public_voices.data)

    # Create a new voice
    new_voice = client.voices.create({
        'name': 'My Custom Voice',
        'sample_url': 'https://example.com/sample.wav',
        'verified': True  # Required: User must explicitly verify they have permission to use this voice
    })
    print('Created voice:', new_voice.data)

    # Get a specific voice
    voice = client.voices.retrieve('voice_id')
    print('Voice details:', voice.data)

    # Get a public voice
    public_voice = client.voices.retrieve_public('public_voice_id')
    print('Public voice details:', public_voice.data)

# Working with Generations
async def generation_examples():
    # List all generations
    generations = client.generations.list()
    print('All generations:', generations.data)

    # Create a new text-to-speech generation
    new_generation = client.generations.create({
        'voice_id': 'voice_id',
        'text': 'Hello, this is a test generation.',
        'quality': 'high',
        'notes': 'Read in a friendly tone'
    })
    print('Created generation:', new_generation.data)

    # Create a voice cloning generation
    voice_clone = client.generations.create({
        'voice_id': 'voice_id',
        'source_url': 'https://example.com/source-audio.wav',
        'quality': 'voice'
    })
    print('Created voice clone:', voice_clone.data)

    # Get a specific generation
    generation = client.generations.retrieve('generation_id')
    print('Generation details:', generation.data)

API Resources

Voices

  • client.voices.list() - List all voices for the authenticated user
  • client.voices.list_public() - List all public voices
  • client.voices.create(params) - Create a new voice
  • client.voices.retrieve(voice_id) - Get a specific voice
  • client.voices.retrieve_public(voice_id) - Get a specific public voice
  • client.voices.delete(voice_id) - Delete a voice

Generations

  • client.generations.list() - List all generations
  • client.generations.create(params) - Create a new generation
  • client.generations.retrieve(generation_id) - Get a specific generation
  • client.generations.delete(generation_id) - Delete a generation

Development

  1. Clone the repository
  2. Install dependencies:
    pip install -e ".[dev]"
    
  3. Run tests:
    pytest
    

License

MIT

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

primvoices-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

primvoices-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file primvoices-0.1.0.tar.gz.

File metadata

  • Download URL: primvoices-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for primvoices-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1822c58437f2f89b1782bd23ae965e67d81e74552fc552ea71660d4bca366ff2
MD5 3e9c3073ea7babfb4337844d4f495763
BLAKE2b-256 c330ee5cc6fa1883851e578b5b52627875dff27d9eab336de65c86bbc6f572d9

See more details on using hashes here.

File details

Details for the file primvoices-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: primvoices-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for primvoices-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78b821d7d3c5232b600e1a0f60ebc4bfb1ef6d8208e71befaa1bbecaace72315
MD5 1c271f36f6f33622015081c9a6bdd5a2
BLAKE2b-256 066aa19c24aaaa1d79904f4445ba75738a27cf4c83b6e8f89045b87941a78228

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