Skip to main content

Python SDK for Verbum AI speech services (sync and async)

Project description

verbum-sdk (Python)

CI PyPI Python License: MIT

Python SDK for Verbum AI speech services — real-time speech-to-text and speech-to-speech streaming, translation, text analysis, text-to-speech, and batch transcription. Sync and async clients ship from a single package.

Install

pip install verbum-sdk

Quickstart — sync

from verbum import VerbumClient, VerbumClientOptions, SttConnectOptions, create_api_token

client = VerbumClient(VerbumClientOptions(
    api_token=create_api_token("sk-..."),
    base_url="wss://sdk.verbum.ai",
))

# Context manager — session.stop() is called automatically on exit
with client.stt.connect(SttConnectOptions(language=["en-US"], encoding="PCM")) as session:
    session.on_recognized(lambda result: print(result.text))
    session.stream(pcm_bytes)   # call repeatedly with PCM audio chunks
# session is stopped here

Or without the context manager:

session = client.stt.connect(SttConnectOptions(language=["en-US"], encoding="PCM"))
session.on_recognized(lambda result: print(result.text))
session.stream(pcm_bytes)
session.stop()

Quickstart — async

import asyncio
from verbum import AsyncVerbumClient, VerbumClientOptions, SttConnectOptions, create_api_token

async def main() -> None:
    client = AsyncVerbumClient(VerbumClientOptions(
        api_token=create_api_token("sk-..."),
        base_url="wss://sdk.verbum.ai",
    ))

    # Awaitable + async context manager — both patterns work
    async with client.stt.connect(SttConnectOptions(language=["en-US"], encoding="PCM")) as session:
        session.on_recognized(lambda result: print(result.text))
        await session.stream(pcm_bytes)

asyncio.run(main())

From a non-async context (e.g. an ML pipeline):

session = client.stt.connect_sync(SttConnectOptions(language=["en-US"], encoding="PCM"))
session.stream_sync(pcm_bytes)   # thread-safe, no event loop required
session.stop_sync()

Quickstart — REST resources

from verbum.rest.types import TranslateRequest, SingleText

# Translation
result = client.rest.translator.translate(
    TranslateRequest(texts=[SingleText("Hello, world!")], to=["es", "fr"])
)
print(result.translations)

# Batch transcription (shortcut via client.batch)
from verbum.rest.types import BatchTranscribeRequest
job = client.batch.create_batch_job(BatchTranscribeRequest(urls=["https://..."], language="en-US"))
status = client.batch.get_batch_job_status(job.transcription_id)
result = client.batch.get_batch_job_result(job.transcription_id)

# Usage / consumption (shortcut via client.usage)
from verbum.rest.types import ConsumptionQuery
records = client.usage.get_consumption(ConsumptionQuery(start_date="2026-01-01", end_date="2026-12-31"))

Jupyter notebook

A live microphone transcription demo is available at notebooks/realtime_transcription.ipynb.

pip install "verbum-sdk[notebooks]"
jupyter lab notebooks/realtime_transcription.ipynb

API docs

Full API reference generated by Sphinx:

pip install "verbum-sdk[docs]"
cd docs && make html
# open docs/_build/html/index.html

Project layout

src/verbum/
  client.py       VerbumClient / AsyncVerbumClient
  auth/           API token auth provider
  stt/            SttModule / SttSession (+ Async variants) — full implementation
  ws/             Socket.IO transport (VerbumWebSocket / AsyncVerbumWebSocket)
  rest/           REST resource clients — translator, text-analysis, speech/TTS,
                  scribe, usage; circuit-breaker + retry on the base client

This mirrors the reference TypeScript SDK (src/*.ts) module-for-module so the two implementations stay easy to diff against each other during development.

Protocol & conformance

This SDK speaks the wire protocol documented in specs/PROTOCOL.md (Engine.IO v4 over WebSocket, Socket.IO /listen and /repeat namespaces) and passes the shared conformance suite (TC-001–TC-006) as a mandatory CI gate.

specs/ is a git submodule of verbum-sdk-specs; after cloning, run:

git submodule update --init --recursive

Development

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

ruff check .                        # lint
ruff format --check .               # format check
mypy                                # type check
pytest                              # unit tests (≥90 % coverage enforced)
pytest tests/integration/ -v        # integration tests (requires VERBUM_SDK_TEST_API_KEY)

Run the conformance suite locally (requires Node ≥ 22 + pnpm ≥ 11):

cd specs/conformance/runner && pnpm install && pnpm build && cd ../../..
VERBUM_SDK_API_KEY=<key> node specs/conformance/runner/dist/index.js run \
  --adapter "python tests/conformance/adapter.py" \
  --suite specs/conformance/suite \
  --specs-root specs

Project status

Area Status
Packaging / tooling Done
verbum.auth Done
verbum.stt session state machine Done
verbum.ws Socket.IO transport Done
verbum.rest.* (translator, text-analysis, speech, scribe, usage) Done
verbum.rest.* (users, projects, invitations, metrics — manager-api) Not planned
Unit tests (≥90 % coverage) Done
Integration tests Done
Conformance suite (TC-001–TC-006) Done
Sphinx API docs Done
Jupyter quickstart notebook Done
PyPI publish (CI/CD) Done

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

verbum_sdk-1.0.0.tar.gz (315.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

verbum_sdk-1.0.0-py3-none-any.whl (35.8 kB view details)

Uploaded Python 3

File details

Details for the file verbum_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: verbum_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 315.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for verbum_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 693f0d4b79f4d01c75a37469b1cbd635822ef8f78775fdc1bd21ef882c279569
MD5 257aeb303dfd7ef829a552ed6be7cfad
BLAKE2b-256 ece4e99a90647997a532c869cbac37ab6a39690b22e84f60fe0b417eb41bfd4f

See more details on using hashes here.

File details

Details for the file verbum_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: verbum_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 35.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for verbum_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3fbeea603b060f1cbbe59d4475d59f71d07dd4f2e7ee90871ce8f47570cb4f5
MD5 df9c17870dc9d3429cba8e70c98c34e5
BLAKE2b-256 5cdbfec49b995da39b0ebb119203d89fad39559cc5b80d418cf527539ab97651

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