Skip to content

feat(stt): add Soniox as an opt-in streaming provider - #12295

Merged
mdmohsin7 merged 7 commits into
mainfrom
rex/soniox-stt-option
Aug 27, 2026
Merged

mdmohsin7 merged 7 commits into
mainfrom
rex/soniox-stt-option

Conversation

@mdmohsin7

@mdmohsin7 mdmohsin7 commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

Why

Modulate's multilingual streaming endpoint is failing for our account (~90% of
streams), and both Deepgram accounts we can reach are normal-tier with concurrency
ceilings around 5 pods' worth each. There is currently no provider that can carry our
auto-detect traffic reliably.

Soniox is the only vendor I could find that does speaker diarization and automatic
language identification together in real time
:

  • AssemblyAI Universal-Streaming: diarization yes, but 18 languages — missing ko, cs,
    uk, pl, zh-TW, all of which appear in our traffic.
  • Speechmatics: richest diarization config and 55+ languages, but language
    identification is documented as batch-only, and 82% of our sessions arrive as
    multi with no declared language.
  • Soniox: diarization and language ID both in streaming, 60+ languages, auto-detect
    needs no language specified.

What changed

Adds Soniox as a selectable streaming provider. Nothing changes unless a deployment
opts in
— it is absent from DEFAULT_MODELS_BY_SURFACE, so it is only reachable by
naming soniox in STT_SERVICE_MODELS.

  • config/stt_provider_policy.py — new SONIOX_PROVIDER, streaming surface only
    (the batch path has no Soniox client, and PTT dispatches Parakeet/Modulate alone).
  • utils/stt/streaming.py — SafeSonioxSocket + process_audio_soniox, a new
    STTService.soniox, and its own circuit breaker.
  • routers/listen/receiver.py — a Soniox primary falls back through Modulate then
    Deepgram, the same chain a Modulate primary uses.
  • charts — SONIOX_API_KEY passed to backend-listen, optional: true so the
    deployment is unaffected until the secret exists.

Protocol notes

Soniox streams token deltas, not utterances. Tokens flip is_final once committed
and non-final ones are revised in place, so forwarding them would emit text the model
later retracts. The socket forwards only finals, and coalesces consecutive finals from
one speaker into a segment shaped like the other providers'.

enable_speaker_diarization and enable_language_identification are both on, so each
token carries its own speaker and language. Auto-detect sessions send no
language_hints; a declared language is passed as a hint rather than a constraint.

Testing

  • test_soniox_streaming.py — 9 cases: final-only forwarding, speaker coalescing,
    speaker changes, missing speaker field, error propagation, preseconds trimming,
    hint behaviour for multi vs declared language, and that Soniox stays out of the
    defaults.
  • Existing STT suites pass per-file: policy (21), Modulate fallback (11), live STT
    failure (13), death monitor (4), runtime env validator (85).
  • The full tests/unit run segfaults in a native extension on my machine; that
    reproduces on unmodified main, so files were run individually.

Not verified

No end-to-end transcription test. The provided key authenticates and the protocol
handshake works, but the account returns:

error_code 402  organization_balance_exhausted
"Organization balance exhausted. Please either add funds manually or enable autopay."

So token assembly, diarization quality and language identification are all exercised
against a fake server only. Before enabling this in production, the account needs
funding and a real two-speaker sample should be run through it.

Soniox's own docs also warn that real-time diarization has higher attribution error
than async, and that endpoint detection reduces diarization accuracy — relevant since
our VAD gate finalizes aggressively.

Review in cubic

Line-count ratchet

Line-Count-Exception: backend/utils/stt/streaming.py | 1692 -> 1707 | The Soniox client (230 lines) lives in its own module, utils/stt/soniox.py; the 15 lines remaining here are the irreducible wiring a provider needs in the shared module — the STTService member, its get_model_name mapping, its circuit breaker and the _circuit_for_primary branch, the selection branch, and the re-export import.

Streaming only: the batch path has no Soniox client and PTT dispatches Parakeet
and Modulate alone. Absent from DEFAULT_MODELS_BY_SURFACE, so a deployment must
name it in STT_SERVICE_MODELS to select it.
Soniox streams token deltas rather than utterances: tokens flip is_final once
committed and non-final ones are revised in place, so only finals are forwarded
and consecutive finals from one speaker coalesce into a segment.

Diarization and language identification are both requested, so auto-detect
sessions need no declared language -- the token carries its own speaker and
language. A declared language is passed as a hint instead.
Live tokens arrive with duration_ms null, so the previous arithmetic collapsed
every segment's end onto its start. Verified against the live service with a
26s speech sample: 98 final tokens, all with duration_ms null.
streaming.py was already over the product line-count ratchet before this branch;
adding a provider inline pushed it further. The Soniox protocol is self-contained,
so it lives in utils/stt/soniox.py and streaming.py re-exports it for existing
import sites. Imports flow one way, so there is no cycle.

Also drops a redundant isinstance on a typed dict that pyright rejected, and
annotates JSON-sourced tokens as Any so the remaining runtime guard is real.
@mdmohsin7
mdmohsin7 merged commit a700baa into main Aug 27, 2026
34 of 37 checks passed
@mdmohsin7
mdmohsin7 deleted the rex/soniox-stt-option branch August 27, 2026 14:27
mdmohsin7 added a commit that referenced this pull request Aug 27, 2026
## Why

`main` is currently undeployable. #12295 added the `SONIOX_API_KEY` helm
binding to
both backend-listen values files but did not register it in the
classification
ledger, so `deployment-secret-boundary` fails:

```
- backend/charts/backend-listen/prod_omi_backend_listen_values.yaml:
    helm_secret binding SONIOX_API_KEY is unclassified
- backend/charts/backend-listen/dev_omi_backend_listen_values.yaml:
    helm_secret binding SONIOX_API_KEY is unclassified
```

Release Eligibility failed on `a700baa559` as a result, which blocks
**all** backend
deploys, not only the Soniox feature.

## What changed

One line: `SONIOX_API_KEY` added to `kinds.secret` in
`config/deployment-setting-classification.json`, next to
`MODULATE_API_KEY` and
`DEEPGRAM_API_KEY`.

It is a provider credential, so `secret` is the correct classification —
it must not
be a `config` value or reach a public build.

## Testing

`python3 .github/scripts/check_deployment_secret_boundary.py --base
origin/main`
→ `deployment secret-boundary check passed`

## How this got missed

The check runs in the shared PR preflight. On #12295 that preflight
failed first on
the line-count ratchet, so the secret-boundary failure was never
surfaced; the PR was
merged before the corrected run completed.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/12296?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
pull Bot pushed a commit to Mu-L/omi that referenced this pull request Aug 27, 2026
PR BasedHardware#12295 added the SONIOX_API_KEY helm binding without registering it, so
deployment-secret-boundary rejects main's tip and Release Eligibility fails --
blocking every backend deploy, not just this feature.
mdmohsin7 added a commit that referenced this pull request Aug 30, 2026
## Why

`SONIOX_API_KEY` exists in Secret Manager (org-level key, created
2025-05-17) and
#12295 wired backend-listen to consume it, but the ExternalSecret
enumerates its keys
explicitly and Soniox was not among the 34 listed. The key therefore
never reaches the
cluster secret, so the binding resolves to nothing and Soniox can never
be selected.

## What changed

Adds the `SONIOX_API_KEY` → `SONIOX_API_KEY` mapping to the prod and dev
backend
secret charts, next to `MODULATE_API_KEY` and `DEEPGRAM_API_KEY`.

## Verification

The org-level key was tested against the live Soniox service before this
change:
authenticated, transcribed, and returned two distinct speakers on a
two-speaker
sample. It is current, not stale.

The backend-listen binding is `optional: true`, so pods start fine
whether or not the
key is present; this change is what makes the provider actually usable.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/12298?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant