verbex-speech-sdk (Python)
Python SDK for the Verbex Speech API: speech-to-text (files and live audio) and text-to-speech.
Python 3.9 or later. Synchronous (VerbexSpeech) and asynchronous (AsyncVerbexSpeech) clients
with the same calls.
Installation
pip install verbex-speech-sdk
# or
poetry add verbex-speech-sdk
# or
uv add verbex-speech-sdk
The package is installed as verbex-speech-sdk and imported as verbex_speech:
from verbex_speech import VerbexSpeech
From a checkout of this repository instead: pip install ./python (or pip install -e ./python to
edit the SDK as you use it).
Quick start
-
Create an API key in the customer console (it starts with
vbx_). -
Tell the SDK the key. It calls the production API,
https://jp-speech-api.verbex.ai, unlessVERBEX_BASE_URLnames another address:export VERBEX_API_KEY=vbx_... # export VERBEX_BASE_URL=https://speech-api-stage.verbex.ai # stage only -
Pick a model and a voice your workspace can use:
from verbex_speech import VerbexSpeech with VerbexSpeech() as client: for m in client.listen.models(): print("stt", m.model, m.language, [mode.mode for mode in m.modes]) for v in client.speak.voices(): print("tts", v.model, v.code, v.language)
-
Transcribe a file and speak a reply, in one script:
from verbex_speech import APIError, VerbexSpeech with VerbexSpeech() as client: try: job = client.listen.transcribe("call.wav", model="verbex_jp_stt_x1", language="ja") except APIError as error: raise SystemExit(f"{error.code}: {error.message} (request {error.request_id})") if not job.completed: raise SystemExit(f"job {job.job_id} {job.status}: {job.error}") print(job.text) # Voices are listed by language; take one that speaks the text's language. voice = next(v for v in client.speak.voices() if v.language == "ja") audio = client.speak.synthesize(model=voice.model, voice=voice.code, text="ありがとうございました。", format="wav") with open("reply.wav", "wb") as f: f.write(audio.data)
Ready-to-run scripts are in examples/: transcribe_file.py call.wav, live_from_wav.py call.wav
(16 kHz mono 16-bit WAV) and speak_to_wav.py out.wav. Each reads the key and address from the
environment. The sections below cover every call and option.
Set up
Create an API key in the customer console. The SDK reads the key and the API address from the environment, or from the constructor:
export VERBEX_API_KEY=vbx_...
# export VERBEX_BASE_URL=https://speech-api-stage.verbex.ai # optional; default https://jp-speech-api.verbex.ai
from verbex_speech import VerbexSpeech
client = VerbexSpeech() # or VerbexSpeech(api_key=..., base_url=...)
The base URL is base_url, else VERBEX_BASE_URL, else the production API
https://jp-speech-api.verbex.ai. A malformed one raises ConfigurationError.
Keep the key secret: it is never logged by the SDK and never sent anywhere but the API.
Transcribe a file
job = client.listen.transcribe("call.wav", model="verbex_jp_stt_x1", language="ja")
print(job.status, job.text)
for segment in job.segments:
print(segment.start_sec, segment.end_sec, segment.text)
WAV or MP3, up to 100 MiB. A file of up to 1 MiB is sent in the request; a larger one goes straight
to storage through the upload flow, without passing through the API. Either way the call returns
the finished job. It does not raise for a failed job: check job.completed or job.status, and
job.error.
Options: hotwords=[...], metadata={...}, webhook_url=..., tags=[...], filename=,
size= (for a stream). A bytes object, a path or an open binary file all work. To audio already
in your storage, pass url="https://..." instead of a file.
Without waiting:
receipt = client.listen.submit("call.wav", model="verbex_jp_stt_x1", language="ja",
webhook_url="https://example.com/stt/done")
job = client.listen.get(receipt.job_id) # or client.listen.wait(receipt.job_id)
A finished job is kept for 10 minutes.
Submitting safely more than once
Every submit carries an Idempotency-Key header, so a submit whose answer was lost (a timeout, a
dropped connection) is retried without making a second job: the API answers the retry with the
first request's receipt, and receipt.replayed is True. The SDK makes a new key for each
submit or transcribe call and reuses it for that call's retries.
If your process may submit the same work again after a restart, pass your own key, saved with the work, so the API recognises it for up to 24 hours:
receipt = client.listen.submit("call.wav", model="verbex_jp_stt_x1", language="ja",
idempotency_key=f"call-{call_id}")
A key is 1 to 255 visible ASCII characters. Reusing a key for a different request raises
BadRequestError with code idempotency_key_reused (422).
Verify a webhook
from verbex_speech import parse_webhook, WebhookVerificationError
def handle(raw_body: bytes, headers: dict):
try:
job = parse_webhook(API_KEY, raw_body, headers) # the key that submitted the job
except WebhookVerificationError:
return 401
...
Pass the body exactly as received. verify_webhook(api_key, raw_body, timestamp, signature) returns
a bool if you only want the check.
Live transcription
with client.listen.stream(model="verbex_jp_stt_x1", language="ja") as session:
# send raw PCM: 16 kHz, mono, signed 16-bit little-endian, at the pace it is produced
session.send(pcm_chunk)
...
session.finish()
for event in session:
if event.type == "segment":
print(event.text)
Send from one thread and read in another, as examples/live_from_wav.py does. Events are
segment, configured (after session.configure(hotwords)), done and error. Leaving the
with block without finish() sends the end of audio for you and waits briefly for the last
segments. A session the server ends raises StreamError; when error.retryable is true, reconnect
and resume sending audio.
Text-to-speech
voice = next(v for v in client.speak.voices() if v.language == "ja")
audio = client.speak.synthesize(model=voice.model, voice=voice.code, text="こんにちは", format="wav")
open("hello.wav", "wb").write(audio.data)
The default format is raw PCM (16 kHz, mono, 16-bit). To start playback before the utterance is complete:
with client.speak.synthesize_stream(model=voice.model, voice=voice.code, text="...") as stream:
for chunk in stream:
player.write(chunk)
Speaking safely more than once
Every synthesize carries an Idempotency-Key header, the same one for each of its automatic
retries. An utterance is billed once: if the audio breaks off and you send the same request again
with the same key, it is spoken again without charge (up to 3 times within 24 hours), and
audio.replayed (or stream.replayed) is True. To use this for your own retries, pass your key:
key = str(uuid.uuid4()) # import uuid; one per utterance, kept for its retries
audio = client.speak.synthesize(model=voice.model, voice=voice.code, text="...", idempotency_key=key)
Past the 3 free replays the API refuses the key: BadRequestError with code
idempotency_replays_exhausted (422). Reusing a key for different text raises BadRequestError
with code idempotency_key_reused (422).
Many utterances over one connection, one at a time:
with client.speak.stream() as session:
for line in lines:
utterance = session.say(model=voice.model, voice=voice.code, text=line)
for chunk in utterance:
player.write(chunk)
print(utterance.done.audio_seconds)
A failed utterance raises SpeakError; the session stays open for the next one.
Async
from verbex_speech import AsyncVerbexSpeech
async with AsyncVerbexSpeech() as client:
job = await client.listen.transcribe("call.wav", model="verbex_jp_stt_x1", language="ja")
async with client.listen.stream(model="verbex_jp_stt_x1", language="ja") as session:
await session.send(pcm_chunk)
await session.finish()
async for event in session:
...
Errors
Every error is a VerbexError.
| Error | When |
|---|---|
ConfigurationError |
No or malformed API key or base URL |
ValidationError (also a ValueError) |
Refused before sending: over 100 MiB, no size for a stream, a bad format |
BadRequestError |
400, 405, 406, 409, 413, 415, 422 |
AuthenticationError |
401 |
PaymentRequiredError |
402: no plan, not enough credit, an overdue invoice |
PermissionDeniedError |
403: the key lacks the permission |
NotFoundError |
404 |
RateLimitError |
429 (retry_after in seconds for the rate limits) |
ServerError |
5xx |
APIConnectionError, APITimeoutError |
No answer |
UploadError |
The storage upload failed |
StreamError |
A WebSocket session ended by an error (code, close_code, retryable) |
SpeakError |
One utterance failed (code, request_id, fields) |
WaitTimeoutError |
wait(..., timeout=) ran out; error.job is the last state |
API errors carry status, code (branch on this), message, request_id (quote it to support)
and fields for validation_failed.
Retries
Up to max_retries (default 2) automatic retries with exponential backoff, honouring
Retry-After up to 60 seconds:
- reads, upload starts, speech and submits: on connection errors, timeouts, 429 rate limits, 502,
503, 504 (speech only before any audio has arrived). Submits and speech are safe to retry because
they carry their idempotency key (above); both are also retried on
409 request_in_progress, while the first request with their key still runs; - the storage upload and WebSocket handshakes: never.
429 concurrency_limit is not retried: wait for some of your own running work to finish.
502 synthesis_failed is not retried: the engine refused this text (for example, text in a language
the voice does not speak) and would refuse it the same way again.
Modules
Every public name can be imported from verbex_speech directly. The package is split by
responsibility, the same way as the Java SDK:
verbex_speech/
client.py VerbexSpeech, AsyncVerbexSpeech: configuration, HTTP client, .listen and .speak
errors.py the errors every product shares (VerbexError, APIError and its subclasses,
ConfigurationError, ValidationError, APIConnectionError, APITimeoutError, StreamError)
listen/ Listen, AsyncListen (client.listen)
models.py ListenModel, ModelMode, Feature; listing models
jobs.py Job, SubmitReceipt, UploadStarted, Segment, JobError, UploadError, WaitTimeoutError;
submit, the upload flow, get, wait, transcribe
stream.py ListenEvent, LiveSession, AsyncLiveSession; transcribe_stream
webhook.py verify_webhook, parse_webhook, signing_key, WebhookVerificationError
speak/ Speak, AsyncSpeak (client.speak), SpeakError
voices.py Voice; listing voices
synthesis.py SpeechAudio, SpeechStream, AsyncSpeechStream; synthesize, synthesize_stream
stream.py SpeakSession, AsyncSpeakSession, Utterance, AsyncUtterance, SpeakDone
_transport/ private: the HTTP request and retry loop, retry rules, WebSocket opening,
configuration and request-shape helpers
Development
pip install -e '.[dev]'
pytest # the live tests run only with VERBEX_API_KEY and VERBEX_BASE_URL set
The tests load the shared fixtures in ../conformance/, which the Node.js and Java SDKs test
against too. The behaviour all three share is specified in ../SPEC.md.
Metadata
Release files for verbex-speech-sdk 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| verbex_speech_sdk-0.1.1.tar.gz | 34.6 kB | With provenance | Details for verbex_speech_sdk-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| verbex_speech_sdk-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for verbex_speech_sdk-0.1.1-py3-none-any.whl |
Total release size: 67.9 kB
Release files / verbex_speech_sdk-0.1.1.tar.gz
| Download URL | verbex_speech_sdk-0.1.1.tar.gz |
|---|---|
| Size | 34.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c6998873112579ba8beb2fc48cda174c81f7cce213e3a6c91eae45fb1528437
|
|
BLAKE2b-256 checksum How to use checksums |
2a2cfccaaad1019712acbe96e8202d0c09bb25dfa2ec071594705a80ec45065e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / verbex_speech_sdk-0.1.1-py3-none-any.whl
| Download URL | verbex_speech_sdk-0.1.1-py3-none-any.whl |
|---|---|
| Size | 33.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b40ff685bf3f3f6aad65a98bd366534115f63b1f8be57db8ddfee4f671168b53
|
|
BLAKE2b-256 checksum How to use checksums |
2488ecc4e6c92dff886fdf01565d9d6e5a4211732ab3fac52a3eba25d7ec3b1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for verbex-speech-sdk 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for verbex_speech_sdk-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.