Skip to main content

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

  1. Create an API key in the customer console (it starts with vbx_).

  2. Tell the SDK the key. It calls the production API, https://jp-speech-api.verbex.ai, unless VERBEX_BASE_URL names another address:

    export VERBEX_API_KEY=vbx_...
    # export VERBEX_BASE_URL=https://jp-speech-api.verbex.ai   # optional; this is the default
    
  3. 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)
    
  4. 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://jp-speech-api.verbex.ai   # optional; this is the default
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)

If the audio breaks off, synthesize sends the request once more with the same key by itself (unless max_retries=0), so a dropped connection costs nothing extra. If that fails too, or with synthesize_stream (which never sends again by itself), you get SpeakError with code audio_incomplete: the utterance may have been billed, and error.idempotency_key is the key to send it again with, without a second charge.

A speak waits up to 360 seconds for the first audio (the status and headers come with it). Once audio has started, each chunk must follow the last within 150 seconds; audio that stalls longer counts as broken off (audio_incomplete).

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; idempotency_key on audio_incomplete)
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.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for verbex-speech-sdk 0.1.3
File Size Uploaded Provenance Actions
verbex_speech_sdk-0.1.3.tar.gz 38.4 kB With provenance Details for verbex_speech_sdk-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for verbex-speech-sdk 0.1.3
File Interpreter ABI Platform Actions
verbex_speech_sdk-0.1.3-py3-none-any.whl Python 3 none any Details for verbex_speech_sdk-0.1.3-py3-none-any.whl

Total release size: 72.9 kB

Release files / verbex_speech_sdk-0.1.3.tar.gz

Download URL verbex_speech_sdk-0.1.3.tar.gz
Size 38.4 kB
Tags Source
SHA-256 checksum
How to use checksums
dbc18933890194fdb678745e9040b85461ac87fa0bbff9226f9a336f56ed35cc
BLAKE2b-256 checksum
How to use checksums
e69b798f7e40dc02d7eede6ee9f774e14c93d4af48c8c64c6b68bc4a33d41e21
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 Dec 1, 2026.

Transparency log

Release files / verbex_speech_sdk-0.1.3-py3-none-any.whl

Download URL verbex_speech_sdk-0.1.3-py3-none-any.whl
Size 34.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae698c209108e78884a31628a61cb892d644fd16f30c190d197da072809cd482
BLAKE2b-256 checksum
How to use checksums
98d11bb2ac9d338a13c83a202921a470027b3768fd1cf52651c831eec0f15b4e
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 Dec 1, 2026.

Transparency log

Security for verbex-speech-sdk 0.1.3

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.

Select from 2 files

Attestation for verbex_speech_sdk-0.1.3.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 Dec 1, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page