Official Python SDK for the Vocence Developer API — TTS, STT, voice cloning, voice design, and real-time voice agents.
Project description
Vocence Python SDK
Official Python client for the Vocence Developer API.
pip install vocence # REST + WebSocket
pip install "vocence[audio]" # adds Turn.play() and the mic ↔ agent live-chat helper
Quickstart
from vocence import Vocence
client = Vocence(api_key="voc_live_...")
# 1. Browse the catalog of pre-defined speakers
for v in client.voices.builtin():
print(v.id, v.name, "—", v.description)
# 2. Synthesize text in one of them
audio = client.tts.speak(text="Hello from Vocence!", voice="design-aria")
print(audio.audio_url)
# 3. Transcribe an audio clip
text = client.stt.transcribe(audio_path="clip.wav", language="English").text
print(text)
Async usage mirrors the sync API exactly:
import asyncio
from vocence import AsyncVocence
async def main() -> None:
async with AsyncVocence(api_key="voc_live_...") as client:
audio = await client.tts.speak(text="Hello", voice="design-aria")
print(audio.audio_url)
asyncio.run(main())
Voice agents over WebSocket
import asyncio
from vocence import AsyncVocence
async def main() -> None:
async with AsyncVocence(api_key="voc_live_...") as client:
async with client.agents.session("agent-id") as session:
await session.send_text("What's the weather in Tokyo?")
async for event in session:
print(event)
if event.type == "turn_end":
break
asyncio.run(main())
The session yields typed events: ready, transcript, token,
tool_call_started, tool_call_completed, audio_meta, audio (binary PCM16),
audio_end, turn_end, error.
For one-shot turns (no streaming), use the higher-level conversation API:
async with client.agents.conversation("agent-id") as conv:
turn = await conv.say("What's the weather in Tokyo?")
print(turn.text) # "It's 19 degrees..."
open("reply.pcm", "wb").write(turn.audio)
print(turn.audio_meta) # {'sample_rate': 24000, 'frame_ms': 40, ...}
The sync Vocence client exposes client.agents.session(agent_id) as a
blocking context manager — events are iterated with a normal for loop:
with Vocence(api_key="voc_live_...").agents.session("agent-id") as sess:
sess.send_text("hi")
for event in sess:
if event.type == "turn_end":
break
CLI
$ vocence login # opens a browser → approve → key saved
$ vocence account # show plan, credits remaining, key count
$ vocence usage # last 20 API requests
$ vocence keys list / create / revoke
$ vocence agents list / show / create / delete
# voices
$ vocence voices # list built-in speakers
$ vocence speak "Hello" --voice design-aria -o out.wav
$ vocence clone path/to/clip.wav --name "My Voice"
$ vocence design "warm female narrator" # interactive design + save
# audio
$ vocence transcribe clip.wav --language English
$ vocence chat <agent-id> # text REPL, plays the reply
$ vocence voice <agent-id> # push-to-talk mic REPL (needs vocence[audio])
Config is written to ~/.vocence/config.json. Override the key with the
VOCENCE_API_KEY environment variable on any command.
Errors
from vocence import Vocence, errors
client = Vocence(api_key="voc_live_invalid")
try:
client.tts.speak(text="x", voice="design-aria")
except errors.AuthenticationError as e:
print("bad key:", e)
except errors.InsufficientCreditsError as e:
print("top up:", e)
except errors.RateLimitError as e:
print("slow down, retry after:", e.retry_after)
API parity
The SDK covers 100% of the public REST + WS surface documented at vocence.ai/docs/api. See CHANGELOG.md for what shipped in each release.
License
Apache 2.0 — see the repo-root LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vocence-0.4.1.tar.gz.
File metadata
- Download URL: vocence-0.4.1.tar.gz
- Upload date:
- Size: 52.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8af27ac93f3d8a67b2dac7012efddf159c05e374794eb183620f166d268a91fe
|
|
| MD5 |
15aab9f7e61860228e8b3f47f7669829
|
|
| BLAKE2b-256 |
ba6ef85c481970e2140f6eab17be10266f06cd463bd2eed286c4ef8be7da8c7e
|
File details
Details for the file vocence-0.4.1-py3-none-any.whl.
File metadata
- Download URL: vocence-0.4.1-py3-none-any.whl
- Upload date:
- Size: 60.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faa550f91e66303ae1b9ebab52dbf9d198ef0b1da9353ad62a8cc56af9ecee71
|
|
| MD5 |
5a1084acf7293b537f5f5663dbaccd1b
|
|
| BLAKE2b-256 |
da86b20c912ed5d6709e396133f6675b974d9336c71528d117b5170c6931e69e
|