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.6.tar.gz (12.4 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.6-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: voicepilot_sdk-0.1.6.tar.gz
  • Upload date:
  • Size: 12.4 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.6.tar.gz
Algorithm Hash digest
SHA256 e2712b139dfb660deba6fadb0edc8106b7cd83a77ba31c9956daaf2e4d3b2b98
MD5 d7d6c7c4178e3b42d58b4154792ce267
BLAKE2b-256 3dd6a3b721171900203582316209fb012e80a24a21ed9ed7127f8382c724b8ed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: voicepilot_sdk-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 12.3 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 146dfb475bb76774d6292e3970941cb1db5bae9254c3d1404fee8fb3b8cc9fbe
MD5 b141871f9e2f4a6f290ace5f331d70aa
BLAKE2b-256 d2af2451552dc830f06b36daafa54ec4f5800fd49f60d758205973698e015a8c

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