Skip to main content

Official Python SDK for high-fidelity voice and conversational AI.

Project description

🚀 VoicePilot Python SDK

The official Python client for the VoicePilot high-fidelity voice and conversational AI platform.

Installation

pip install voicepilot-sdk
# For real-time conversational features:
pip install voicepilot-sdk[ws]

Quick Start

Initialize Client

from voicepilot import VoicePilotClient

# Generate your key at https://openclaw.intelligens.app
client = VoicePilotClient(api_key="sk_platform_your_key_here")

Text-to-Speech (TTS)

# Standard TTS (returns base64 string)
response = client.tts.create("Hello, welcome to VoicePilot!", voice="anushka")

# Streaming TTS (yields raw WAV bytes directly)
with open("output.wav", "wb") as f:
    for chunk in client.tts.stream("Hello from the streaming API!", voice="anushka"):
        f.write(chunk)

Speech-to-Text (STT)

result = client.stt.transcribe("speech_sample.wav")
print(f"Transcription: {result.transcript}")

Agent Management & Text Chat

# Create and delete agents
agent = client.agents.create(name="Support", system_prompt="You are a helpful assistant.")
client.agents.delete(agent.id)

# Stateless text chat with an agent (no WebSockets needed)
response = client.agents.chat(
    agent_id=agent.id,
    text="Hello!",
    history=[{"role": "user", "content": "Hi there"}]
)
print(response.reply_text)

📞 Call Lifecycle (Create & End Calls)

The SDK provides dedicated methods to reserve call sessions and finalize them, which is essential for billing, analytics, and triggering webhooks.

1. Manual Create & End (Recommended for custom integrations):

# Create a conversation log *before* connecting your frontend WebSockets
conv = client.conversations.create(agent_id="my_agent_id")
print(f"Pass this ID to your frontend: {conv['conversation_id']}")

# ... User completes the call on the frontend ...

# Explicitly end the call to finalize logs and trigger your webhooks
client.conversations.end(conv['conversation_id'])

2. Automatic Lifecycle via Built-In WebSocket Client:

# The `connect` context manager automatically calls `conversations.create()` 
# when entering the block, and cleanly closes the socket upon exiting.
with client.agents.connect(agent_id="my_agent_id") as session:
    # Get the auto-generated conversation ID
    print(f"Active Session: {session.conversation_id}")
    
    session.send("Tell me a story.")
    for message in session.listen():
        if message.type == "agent.response":
            print(f"Agent: {message.text}")

Error Handling

The SDK provides a typed exception hierarchy for easy error management.

from voicepilot.exceptions import ValidationError, AuthenticationError

try:
    client.tts.create("")
except ValidationError as e:
    print(f"Oops: {e}")
except AuthenticationError:
    print("Check your API key!")

Development

  • Tests: pytest tests/
  • Build: python -m build

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

voicepilot_sdk-0.1.2.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

voicepilot_sdk-0.1.2-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file voicepilot_sdk-0.1.2.tar.gz.

File metadata

  • Download URL: voicepilot_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for voicepilot_sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 836a11d8ef8270c85c995d7c06dcb6d4c54f63a1b4c73a4fa0cf7fcb439c2f3a
MD5 b2837a8ebb9ca6c6917071cb222c62f0
BLAKE2b-256 32f641b414fe2b6fbce0571ffde60a9595a6f520159039044c73638fe1896aee

See more details on using hashes here.

File details

Details for the file voicepilot_sdk-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: voicepilot_sdk-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for voicepilot_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5726c8a387a100bce7157295f25c71131b5dda6800ad5f31797e3df401fe13f1
MD5 59018a9c363c27c99d711ab67bf3f138
BLAKE2b-256 96e4193a2d5618cf14cf2eab5fd9305fef167c5d3ad81d5cdbc0ce2689292948

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