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

[!TIP] Batteries Included: All real-time, WebSocket, and Voice Activity Detection (VAD) dependencies are now included in the base package for a seamless setup.

Quick Start

Initialize Client

from voicepilot import VoicePilotClient

# Generate your key at https://voice.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.7.tar.gz (12.5 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.7-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: voicepilot_sdk-0.1.7.tar.gz
  • Upload date:
  • Size: 12.5 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.7.tar.gz
Algorithm Hash digest
SHA256 c411297028ea325cc6a1c29ce776a1cf38dc23f4e97c95fcf540a07f9da3ffa7
MD5 cdc946e0fda30ef2c062bb5420793932
BLAKE2b-256 bd055a1436fcfb925d4318fd23601d2cf11128156e51690306abfc43c4a2e5ec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: voicepilot_sdk-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 12.4 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 336f0f1ed36a1ea73687093588e66eac72cd3adf2f70455e85e831353cdfb6a3
MD5 edd26a36d82a5b6a7461acf429f61d6e
BLAKE2b-256 dab2924585d9ee47274488dc95f513220727a4a509ad0f057e385a8794dd9a96

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