Skip to main content

tomfun-speech-to-text-client

Minimal async Python client for the tomfun speech-to-text web API.

  • Token authentication (Authorization: Bearer <token>)
  • Language hint passed to Whisper
  • Upload local files (chunked) or submit a remote URL
  • Streams status via Server-Sent Events

Single runtime dependency: aiohttp.

Install

pip install tomfun-speech-to-text-client

Usage

import asyncio
from tomfun_speech_to_text_client import Client

async def main():
    async with Client("https://speech-to-text.tomfun.co", token="YOUR_TOKEN") as c:
        r = await c.transcribe_file("audio.mp3", language="en")
        print(r.text)

        r = await c.transcribe_url("https://example.com/clip.wav", language="uk")
        print(r.srt)

asyncio.run(main())

With progress callback:

async def on_status(ev):
    print(ev["status"], ev.get("progressLast"))

await c.transcribe_file("audio.mp3", language="en", on_status=on_status)

Cancel a job:

await c.cancel(job_id)

Speaker diarization (server-side pyannote):

r = await c.transcribe_file("meeting.mp3", language="ru", diarize=True)
print(r.diarized)            # SRT with a [SPEAKER_xx] prefix per cue, or None
print(r.speaker_embeddings)  # base64 .npy, shape (numSpeakers, embeddingDim), or None

Both diarization fields are None when diarize wasn't requested — and also when the server's diarization failed on an otherwise successful job, so always check them.

TranscriptionResult

field notes
text plain transcript. Empty on silence; when the server sends it empty while the whisper JSON still holds segments, the client rebuilds it from json.transcription
srt / vtt / csv subtitle/table renderings
json parsed WhisperFullJSON (whisper-cli --output-json-full): transcription[].text / .offsets / .tokens
diarized SRT annotated with [SPEAKER_xx], or None
speaker_embeddings base64-encoded .npy, one row per detected speaker, or None
accuracy accuracy of the model that actually ran (lower than preferred_accuracy when the job was routed to a degraded manager)
raw the final job payload as received

Development (uv)

cd python_client
uv sync --group dev
uv run pytest

Publishing to PyPI

  1. Create a PyPI API token at https://pypi.org/manage/account/token/.
  2. Bump version in pyproject.toml.
  3. Build:
    uv build
    
  4. Upload. uv publish does not read ~/.pypirc (only --token / UV_PUBLISH_TOKEN, --username/--password, keyring, trusted publishing), so with the token stored there the shortest path is twine, which picks it up on its own — name the new version explicitly, otherwise twine trips over the already-published files in dist/:
    uv tool run --with twine twine upload dist/tomfun_speech_to_text_client-0.0.5*
    
    Or pass the token to uv directly:
    uv publish --token "$PYPI_TOKEN"
    

Metadata

Release files for tomfun-speech-to-text-client 0.0.5

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

Source distribution (sdist)

Source distribution for tomfun-speech-to-text-client 0.0.5
File Size Uploaded
tomfun_speech_to_text_client-0.0.5.tar.gz 98.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tomfun-speech-to-text-client 0.0.5
File Interpreter ABI Platform
tomfun_speech_to_text_client-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 108.0 kB

Release files / tomfun_speech_to_text_client-0.0.5.tar.gz

Download URL tomfun_speech_to_text_client-0.0.5.tar.gz
Size 98.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ff2c323d53b0df347b133912ac0d23799add327e81b232e53f956a039f182f82
BLAKE2b-256 checksum
How to use checksums
6f9cd61b36b9b926949f7f99650e41aa9195bb2896496419324baa7d3ccac61a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release files / tomfun_speech_to_text_client-0.0.5-py3-none-any.whl

Download URL tomfun_speech_to_text_client-0.0.5-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e083a5422b24bdc965310e5b80926c7595a30df9e45920966b8c8e08ad893ab
BLAKE2b-256 checksum
How to use checksums
9fd37d6e1c26c3a9acb2a9e15a8314e0ac7d6d80e7acbddb0fe667d5811770d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release history Release notifications | RSS feed

0.0.6

2 release files

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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