Skip to main content

baari: knows when an Urdu speaker has finished talking

by samadpls.com Code license: BSD-2-Clause Data: IndicVoices, CC BY 4.0 PyPI Downloads Python 3.10+

End-of-turn detection for Urdu voice agents.
At every pause, it decides whether the speaker has finished (reply now) or is only pausing mid-sentence (keep listening).


baari (باری) means "turn" in Urdu. The table below shows that today's turn detectors often cut Urdu speakers off mid-sentence, or wait after they have finished. baari is a small audio model trained to get this right. It follows the Smart Turn recipe and takes the same input and output, so it can stand in for Smart Turn.

Status: work in progress. Done so far: the Urdu test set, the scores of existing models, and labels for 61,251 training segments. The training code is in place. The first model hasn't been trained yet.

🎧 Do existing models understand Urdu?

1,588 clips of real Urdu phone conversations, cut from the official held-out split of IndicVoices: 1,470 where the speaker had finished and 118 where they were pausing mid-sentence. Because most clips are "finished", a model that always says "finished" gets 92.6% plain accuracy, so the fair score is the average of the two middle columns (balanced accuracy).

Model Balanced accuracy (95% CI) Waits when unfinished Replies when finished
Always says "finished" (reference) 50.0% 0.0% 100.0%
Smart Turn v3.2 (CPU, int8) 63.4% (58.8–68.1) 57.6% 69.2%
Smart Turn v3.2 (GPU, fp32) 58.8% (54.8–63.0) 76.3% 41.3%
Indic Smart Turn tiny (int8) 73.4% (69.0–77.8) 61.0% 85.9%
Indic Smart Turn tiny (fp32) 70.0% (65.8–74.4) 51.7% 88.4%
Indic Smart Turn base (fp32) 70.9% (66.5–75.4) 47.5% 94.4%
PuristanLabs1/urdu-turn-v2 (Urdu) 51.8% (48.4–55.4) 16.9% 86.7%

Scored on a MacBook Pro (M3 Pro), with the same audio preparation Pipecat uses. int8 models are sensitive: their scores shift by a few points between Arm and x86 CPUs, and even tiny changes in how the audio is prepared flip about 1 answer in 100. fp32 results stay the same.

How the test set was made
  • Source: the conversation recordings in the valid split of IndicVoices Urdu (CC BY 4.0): 1,654 segments, 81 calls, 80 speakers, 1.7 hours. Each segment ends at a pause.
  • Labels: two LLM agents each read every call's transcript in order and marked whether the speaker had finished at the end of each segment (prompt). They agreed on 96.0%. Agreed segments form the test set; the 66 others are kept apart as test_ambiguous.
  • Clips: the last 8 s of 16 kHz audio ending at the segment, with the speaker's preceding segments as context, the same recipe as Indic Smart Turn.
  • Checked by ear: a native speaker listened to 50 random clips. All 25 "finished" labels were right, and 19 of 25 "unfinished" labels were. In the wrong ones the words stop mid-sentence but the voice sounds finished, which a transcript cannot show. So roughly 1 in 4 "unfinished" clips may really be finished, and the "waits when unfinished" column is a rough measure.
  • Leakage: 70 of the 80 test speakers, and the other side of 57 of the 81 test calls, also appear in the IndicVoices train split. Any training data will leave out those speakers and calls.

Use it

pip install baari
from baari import TurnDetector

detector = TurnDetector(threads=4)  # downloads baari's 9 MB int8 model once
detector.is_finished(audio)  # 16 kHz mono audio (float or int16) that ends at the pause
detector.probability(audio)  # the same decision as a number from 0 to 1

It needs only numpy and onnxruntime. One call takes about 12 ms on 4 CPU threads and 37 ms on one (MacBook Pro, M3 Pro). Use threads=1 on a server that handles many calls at once.

The baari model is not released yet. Until it is, TurnDetector(path=...) runs any Smart Turn style ONNX file, such as Indic Smart Turn tiny, the best existing model in the table above.

🛠️ Run it

uv sync --extra pipeline
echo "HF_TOKEN=..." > .env          # accept the IndicVoices terms on Hugging Face first
uv run baari scan --split valid     # index the conversation segments (text only)
uv run baari batches                # label batches for the LLM agents
# the agents write data/labels/valid/results/{a,b}/batch-*.jsonl
uv run baari build                  # cut the 8 s clips
uv run baari evaluate               # score the existing models
Training

The same steps on the IndicVoices train split, with one labeler. Test speakers and both sides of test calls are left out, and about 5% of the remaining speakers form a dev split that picks the best epoch.

uv run baari scan --split train
uv run baari batches --split train
# the agents write data/labels/train/results/a/batch-*.jsonl
uv run baari build --split train --labelers a --delete-shards
uv run baari train                  # fine-tune Indic Smart Turn tiny, export fp32 and int8 ONNX

Training starts from Indic Smart Turn tiny. That model ships only as ONNX, so baari train first reads its weights back into PyTorch. The kaggle folder runs the clip build and the training on Kaggle.


Credits · Contributing · BSD-2-Clause license
Made by Abdul Samad (abdulsamadsid1@gmail.com)

Metadata

Release files for baari 0.1.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 baari 0.1.0
File Size Uploaded Provenance Actions
baari-0.1.0.tar.gz 25.5 kB Without provenance Details for baari-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 55.9 kB

Release files / baari-0.1.0.tar.gz

Download URL baari-0.1.0.tar.gz
Size 25.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9e4693c1ba236f246eb867d19ce17cc133f71e619890f804d75c00a1c9774201
BLAKE2b-256 checksum
How to use checksums
c5bb7354f35d143d8de40f77e5ea9f72a5dbc5fea9e5db8e2d7fa8db2e6fcdc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / baari-0.1.0-py3-none-any.whl

Download URL baari-0.1.0-py3-none-any.whl
Size 30.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15108ec39efaa935ddea86c3f8a672aca871c966fe4325fc80a414155f0a2db4
BLAKE2b-256 checksum
How to use checksums
5ce06e1d526025fce1aa38a627dc414fdc7f4b9f683b6b76248796eb6e28d5ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for baari 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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