Skip to main content

Python SDK for dTelecom real-time speech-to-text with x402 micropayments

Project description

dtelecom-stt

Python SDK for dTelecom real-time speech-to-text with x402 micropayments.

Pay-per-minute STT powered by Whisper and Parakeet, with automatic blockchain payments via USDC on Base or Solana.

Install

pip install dtelecom-stt

Quick Start

import asyncio
from dtelecom_stt import STTClient

async def main():
    # EVM wallet (Base)
    client = STTClient(private_key="0x...")
    # Or Solana wallet — detected automatically
    # client = STTClient(private_key="base58...")

    async with client.session(minutes=5, language="en") as stream:
        async for t in stream.transcribe_file("meeting.wav"):
            print(f"[{t.start:.1f}s] {t.text}")

asyncio.run(main())

Real-Time Streaming

import asyncio
from dtelecom_stt import STTClient

async def main():
    client = STTClient(private_key="0x...")  # or Solana base58 key

    async with client.session(minutes=5, language="en") as stream:
        # Callback-based
        stream.on_transcription(lambda t: print(t.text))

        # Send audio chunks (PCM16, 16kHz, mono)
        await stream.send_audio(pcm_bytes)

        # Or iterate asynchronously
        async for t in stream.transcriptions():
            print(t.text)

asyncio.run(main())

Auto-Extend Sessions

Sessions automatically buy more time when running low (enabled by default):

# 30-minute session that auto-extends
async with client.session(minutes=30, language="en") as stream:
    # When <60s remaining, SDK buys 5 more minutes automatically
    async for t in stream.transcriptions():
        print(t.text)

# Disable auto-extend
async with client.session(minutes=5, auto_extend=False) as stream:
    ...

Audio Format

The server expects PCM16, 16kHz, mono audio. Convert with ffmpeg:

ffmpeg -i input.mp3 -ar 16000 -ac 1 -acodec pcm_s16le output.wav

Pricing

info = await client.pricing()
print(f"${info.price_per_minute_usd}/min ({info.currency} on {info.network})")

Current pricing: $0.005/min (USDC on Base or Solana).

API Reference

STTClient(private_key, url=None)

Main client. Default URL: https://x402stt.dtelecom.org.

  • EVM key (hex, 0x-prefixed): pays with USDC on Base

  • Solana key (base58): pays with USDC on Solana

  • session(minutes=5, language="en", auto_extend=True) — Create a paid session (async context manager)

  • pricing() — Get pricing info

  • health() — Check server health

Stream

Returned by client.session(). Async context manager.

  • send_audio(data: bytes) — Send raw PCM16 audio
  • transcriptions() — Async iterator of Transcription objects
  • transcribe_file(path) — Stream a WAV file and yield transcriptions
  • on_transcription(callback) — Register callback for transcriptions
  • close() — Close the stream

Transcription

  • text: str — Transcribed text
  • start: float | None — Start time in seconds
  • end: float | None — End time in seconds
  • confidence: float | None — Confidence score
  • is_final: bool — Whether this is a final transcription

Supported Languages

25 languages via Parakeet-TDT (fast) with Whisper fallback:

English, Russian, German, French, Spanish, Italian, Portuguese, Dutch, Polish, Czech, Romanian, Hungarian, Greek, Turkish, Ukrainian, Swedish, Norwegian, Danish, Finnish, Catalan, Croatian, Lithuanian, Slovenian, Latvian, Estonian.

Error Handling

from dtelecom_stt import PaymentError, SessionExpiredError, ConnectionError

try:
    async with client.session(minutes=5) as stream:
        async for t in stream.transcriptions():
            print(t.text)
except PaymentError:
    print("Payment failed — check wallet balance")
except SessionExpiredError:
    print("Session time ran out")
except ConnectionError:
    print("Cannot connect to server")

License

MIT

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

dtelecom_stt-0.2.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

dtelecom_stt-0.2.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file dtelecom_stt-0.2.0.tar.gz.

File metadata

  • Download URL: dtelecom_stt-0.2.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for dtelecom_stt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2309f5e6efe57f4f2f9fb6ca916e4d8d9d15b10e16bd35b5c82192bce81688da
MD5 5fb7cd6012da1e0ab50d9dd0cb595831
BLAKE2b-256 84e0fe6f4b54b84537130aa3fbfecd8be0148d2755f0ce5f5f6a1bf43980cdd6

See more details on using hashes here.

File details

Details for the file dtelecom_stt-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dtelecom_stt-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for dtelecom_stt-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 49101b567a92a1370da615289d9ac9c84300d4d362d0f2f1dec586e6f3d6a63b
MD5 4324d2dc8354ab03d61a894bb500f24b
BLAKE2b-256 98480f5b655604f18864f7313bcc0716400d90f12241b1b0ddf275b7ca08245d

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