Skip to main content

seda

PyPI Python License ONNX Hugging Face Ruff uv

Lightweight, low-latency Turkish speech models for real-time applications.

Seda aims to provide models that are small enough to run on a CPU, fast enough for live audio, accurate enough for production, and available for commercial use. sedalib is the Python package for running them. It currently ships streaming speech recognition (STT) on top of sherpa-onnx.

Models

Model Task Architecture Params FLEURS-TR test WER
seda-v0.2 Streaming STT Zipformer2 transducer + second pass 66.1M 6.38 (accurate), 7.26 (balanced)
seda-v0.2-tiny Streaming STT Zipformer2 transducer + second pass 4.5M 10.51 (accurate), 11.24 (balanced)
seda-v0.1 Streaming STT Zipformer2 transducer 66.1M 11.60

For comparison, Whisper small scores 11.87, Whisper medium 6.62 and Whisper large-v3 4.62 on the same set. See the seda-v0.2 card for noisy, telephone and broadcast audio. seda-v0.2-tiny is distilled from seda-v0.2 for slow CPUs, phones and the browser: its acoustic model is 7 MB, and it runs every mode with the same options (Recognizer.from_pretrained("atasoglu/seda-v0.2-tiny")).

Installation

pip install sedalib
pip install "sedalib[format]"  # adds digits, punctuation and casing to the output

Python 3.10 or newer is required. The core package depends only on sherpa-onnx and huggingface-hub.

Quick start

Transcribe a complete waveform. read_wav loads a 16-bit PCM WAV file as mono float samples in [-1, 1] together with its sample rate:

from sedalib import Recognizer, read_wav

samples, sample_rate = read_wav("audio.wav")

recognizer = Recognizer.from_pretrained()  # downloads the model once and caches it
text = recognizer.transcribe(samples, sample_rate)
print(text)

Audio at other sample rates is resampled automatically.

Streaming

For live audio, open a stream and feed it small pieces as they arrive. accept returns the current partial transcript, and is_endpoint turns true when the speaker pauses. end_utterance returns the final text and starts the next utterance.

stream = recognizer.stream()

for chunk in microphone_chunks():  # e.g. 100 ms of audio at a time
    partial = stream.accept(chunk, sample_rate=16000)
    print(partial)

    if stream.is_endpoint:
        print("final:", stream.end_utterance())

The end of speech is detected by Silero VAD after a 0.75 s pause (endpoint_silence). A shorter pause gives the final text sooner but splits slow speech; a Stream can change it while it runs, e.g. stream.endpoint_silence = 0.3. If your application already knows that the speaker stopped, for example with a push-to-talk button, call end_utterance() right away.

To keep accepting audio while the final text is computed, split the two steps: stream.cut() ends the utterance and returns it, and utterance.finalize() can run in another thread.

A single Recognizer can serve many streams at once, from different threads. Call stream.finish() at the end of the audio to flush the remaining frames and get the final text.

Keywords

KeywordSpotter finds words or phrases in a file or a live stream, with the time and a confidence for each:

from sedalib import KeywordSpotter

spotter = KeywordSpotter(recognizer, ["deneme", "bir", "iki", "üç"], min_confidence=0.5)

for d in spotter.find(samples, sample_rate):
    print(
        d.keyword, d.text, d.start, d.end, d.confidence
    )  # keyword, what was heard, seconds

stream = spotter.stream()
for chunk in microphone_chunks():
    for d in stream.accept(chunk, sample_rate=16000):  # at the end of each utterance
        print(d.keyword, d.start)
  • Matching: on the final spoken-form words, as the model writes them ("Ankara'da" is "ankarada", numbers are words). The last word may carry Turkish suffixes, so "kamp" also finds "kampa" and "kampın" but not "kampanya". Stem changes are not covered: list "kitabı" too if "kitap" should find it. Short keywords can match other words this way ("at" finds "ata"); suffixes=False matches whole words only.
  • Confidence: the probability that the words were recognized right, calibrated on held-out speech for seda-v0.2 and seda-v0.2-tiny: the fast, balanced and accurate modes, and chunk=8 or 16 with or without use_lm. On FLEURS-TR test, transcribed one sentence at a time, it is off by about 2 points on average. Other setups and models give None, and min_confidence then keeps every match.
  • Latency: a live detection arrives when the utterance ends, after the VAD's pause.

Every word of a transcript is available too: recognizer.transcribe_words(samples, sample_rate) and utterance.words return Word(text, start, end, score, confidence).

Modes

Mode Live text Final text WER Final text after a pause RTF
fast 0.64 s chunks, greedy the same 9.38 0.32 s 0.042
balanced (default) 1.28 s chunks, beam search + LM the same 7.26 0.37 s 0.064
accurate 0.64 s chunks, greedy second pass with full context, beam search + LM 6.38 0.77 s 0.137
  • WER: FLEURS-TR test.
  • Final text after a pause: median time from the end of speech, including the pause the VAD waits for: measured with endpoint_silence=0.25 (the default pause is 0.75 s).
  • Speed: RTF on one thread of an Intel Core 5 210H CPU, including the second pass.

The second pass of accurate runs in the background while the utterance is spoken, so most of its work is done when the speaker stops.

Options

Recognizer.from_pretrained(
    "atasoglu/seda-v0.2",  # Hugging Face repo id
    revision=None,  # pin a branch, tag or commit
    mode="balanced",  # "fast", "balanced" or "accurate"
    use_lm=None,  # override the mode: rescore with the language model
    two_pass=None,  # override the mode: decode each utterance again for the final text
    chunk=None,  # override the mode: 8, 16, 32 or 64 frames (0.16 to 1.28 s per streaming step)
    punctuate=False,  # digits, punctuation, casing and apostrophes in final texts (needs [format])
    num_threads=1,  # CPU threads per model
    vad=None,  # Silero VAD for the end of speech (default: if the model ships it)
    endpoint_silence=None,  # pause that ends an utterance, in s (default 0.75 with the VAD, 1.2 without)
)

from_pretrained downloads only the files the chosen options need. To load a model you have already downloaded, use Recognizer("path/to/model_dir").

  • Faster end of speech: a shorter pause gives the final text sooner, but splits sentences more often at short hesitations. With 0.15 s, the final text arrives after about 0.22 s (fast) and 0.27 s (balanced).
  • Threads: num_threads=2 makes fast and balanced about 15% faster. More threads do not help a single stream. To serve many users, give each stream one thread and run them in parallel: one recognizer scales to about 4× the throughput on 8 cores.
  • Formatter: punctuate=True writes "Bugün Ankara'da hava 24 derece" instead of "bugün ankarada hava yirmi dört derece". sedalib.itn converts only the numbers and needs no extra.
  • Short chunks: chunk=8 or 16 react sooner (0.16 or 0.32 s steps) but cost more CPU per second of audio and are a little less accurate. On slow devices, prefer chunk=16 with greedy search or the default 0.64 s.
  • seda-v0.1: works with the balanced mode, with or without use_lm, and ends utterances with the 1.2 s silence rule. It does not have the files for fast, accurate, the short chunks, the VAD or the formatter.

Demo

A Gradio demo with live microphone streaming, file transcription, a control panel for all options and latency stats is available as an extra:

pip install "sedalib[demo]"
python -m sedalib.demo.stt
python -m sedalib.demo.keywords  # keyword spotting: type keywords, speak, see matches with confidence

Development

uv sync --all-extras
uv run prek install  # ruff lint and format hooks
uv run pytest  # tests that need a model are skipped
SEDA_TEST_MODEL=atasoglu/seda-v0.2,atasoglu/seda-v0.2-tiny,atasoglu/seda-v0.1 uv run pytest  # with models

License

The code is released under Apache-2.0. The seda-v0.2 and seda-v0.2-tiny model files are CC BY-SA 4.0, because parts of their training data are share-alike: Khan Academy for the acoustic model, and Wikipedia for the language model and the formatter. The Silero VAD file shipped with the model is MIT. Commercial use is allowed under these terms; see the model cards for details.

Metadata

Release files for sedalib 1.3.0

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

Source distribution (sdist)

Source distribution for sedalib 1.3.0
File Size Uploaded Provenance Actions
sedalib-1.3.0.tar.gz 388.6 kB Without provenance Details for sedalib-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sedalib 1.3.0
File Interpreter ABI Platform Actions
sedalib-1.3.0-py3-none-any.whl Python 3 none any Details for sedalib-1.3.0-py3-none-any.whl

Total release size: 429.5 kB

Release files / sedalib-1.3.0.tar.gz

Download URL sedalib-1.3.0.tar.gz
Size 388.6 kB
Tags Source
SHA-256 checksum
How to use checksums
da77acbd367713c3e3a881cc04a85476f0e5ddd3afc6082413b4f07793e8f26f
BLAKE2b-256 checksum
How to use checksums
4cd4888bcc2aaeb71457dd205cf9b9f4eb20354cf468eec29c10c658f4025ffc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / sedalib-1.3.0-py3-none-any.whl

Download URL sedalib-1.3.0-py3-none-any.whl
Size 40.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ef212e00a5b79e156f94e04b82378f9f62fe162e00065291d95c2a2e45e3e28
BLAKE2b-256 checksum
How to use checksums
075d7862e08f1f0e67378900a5a9e56dc7cf1e2055b4c22ddb2873ca40eede77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for sedalib 1.3.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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