Skip to content

Remove dead Speechmatics/Soniox STT code from backend - #6118

Merged
beastoin merged 28 commits into
mainfrom
fix/remove-dead-stt-6116
Mar 28, 2026
Merged

beastoin merged 28 commits into
mainfrom
fix/remove-dead-stt-6116

Conversation

@beastoin

@beastoin beastoin commented Mar 28, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #6116

Remove all dead Speechmatics and Soniox STT provider code from the backend. Only Deepgram is used in production (controlled by STT_SERVICE_MODELS env var which defaults to dg-nova-3).

Changes:

  • Delete utils/stt/soniox_util.py (278 lines) and scripts/stt/i_soniox_profiles.py (93 lines)
  • Remove soniox and speechmatics from STTService enum, leaving only deepgram
  • Remove process_audio_soniox() (~170 lines) and process_audio_speechmatics() (~110 lines) from streaming.py
  • Remove all soniox/speechmatics socket variables, routing branches, and cleanup code from transcribe.py
  • Change stt_service WebSocket param from Optional[STTService] to Optional[str] for backward compat (old app clients send 'soniox' as default)
  • Remove Soniox speech profile Redis helpers from redis_db.py
  • Remove remove_user_soniox_speech_profile call from speech_profile.py
  • Remove dead connect_user_webhook_ws() function and unused websockets import from webhooks.py
  • Remove soniox and speechmatics-python from requirements.txt
  • Remove SONIOX_API_KEY from .env.template and all Helm values (backend-listen, pusher, backend-secrets)
  • Clean up soniox/speechmatics references from benchmark script, test mocks, docs, and comments
  • Preserve database/conversations.py historical data reads for backward compat with existing Firestore collections

Review cycles:

  • R1: Found test_dg_usage_batch.py accumulation count (4→2) — fixed
  • R2: Found test_fair_use_api.py accumulation assertion (4→2), .env.template SONIOX_API_KEY — fixed
  • R3: Found Helm SONIOX_API_KEY refs (6 files), stale comments — fixed
  • R4: Found stale doc references in backend_deepdive.mdx and transcription.mdx — fixed
  • R5: Clean — PR_APPROVED_LGTM
  • Tester: TESTS_APPROVED

Test evidence:

  • backend/test.sh — all pass (4 pre-existing desktop_updates failures unrelated)
  • pytest tests/unit/test_dg_usage_batch.py — 11/11 pass
  • pytest tests/integration/test_fair_use_api.py — 22/22 pass
  • Import chain verification: STTService enum deepgram-only, language routing confirmed
  • Backward compat: old app sending stt_service=soniox as string won't cause 422

Net: ~1,100 lines deleted across 21 files (2 deleted entirely)


by AI for @beastoin

beastoin and others added 12 commits March 28, 2026 10:19
Remove STTService enum values, language sets, and process_audio functions
for providers that are no longer used. Only Deepgram remains.

Fixes #6116

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Remove dead socket variables, routing branches, and cleanup code for
removed providers. Change stt_service param type to Optional[str] for
backward compatibility with old app clients sending 'soniox'.

Fixes #6116

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Remove remove_user_soniox_speech_profile mock. Add missing
get_paid_plan_definitions stub to fix pre-existing import error.

Fixes #6116

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@greptile-apps

greptile-apps Bot commented Mar 28, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR is a focused dead-code removal that strips all Speechmatics and Soniox STT provider code from the backend (~1,100 lines across 12 files), leaving Deepgram as the sole provider. The simplification is well-scoped: socket variables, routing branches, Redis helpers, requirements, and two entire files are cleanly deleted, and stt_service is kept as Optional[str] (rather than removed) for backward compatibility with old app clients that still send 'soniox' as a default value.

Key changes:

  • utils/stt/streaming.py — STTService enum trimmed to deepgram only; process_audio_soniox and process_audio_speechmatics removed.
  • routers/transcribe.py — all Soniox/Speechmatics socket state, routing branches, and cleanup code removed; VAD gate condition simplified correctly.
  • routers/speech_profile.py & database/redis_db.py — Soniox speech-profile Redis helpers removed end-to-end.
  • utils/webhooks.py — stub connect_user_webhook_ws() (empty URI, never called) and unused websockets import removed.
  • Issue found: test_budget_accounting_across_providers in test_fair_use_api.py still asserts >= 4 dg_usage_ms_pending += accumulation points, but only 2 remain after removing the Soniox and Speechmatics paths — this test will fail. The companion assertion in test_budget_gate_used_in_conditionals was correctly updated (5 → 3), but this one was missed.

Confidence Score: 4/5

Safe to merge after fixing the failing test_budget_accounting_across_providers assertion — all production logic is correct.

The production-path changes are correct and well-reasoned. The only concrete defect is a test assertion that was not updated alongside the code: test_budget_accounting_across_providers expects >= 4 dg_usage_ms_pending += accumulation points but only 2 exist after this PR, guaranteeing a CI failure. Everything else is clean dead-code removal.

backend/tests/integration/test_fair_use_api.py — the test_budget_accounting_across_providers assertion threshold must be updated from >= 4 to >= 2.

Important Files Changed

Filename Overview
backend/tests/integration/test_fair_use_api.py Updated fair_use_dg_budget_exhausted guard threshold (5→3), but test_budget_accounting_across_providers still asserts ≥4 dg_usage_ms_pending += accumulation points — only 2 remain after removing Soniox/Speechmatics paths, causing a test failure.
backend/routers/transcribe.py Removes all Soniox/Speechmatics socket variables, routing branches, and cleanup; stt_service parameter changed to Optional[str] for backward compat with old clients that sent 'soniox'; VAD gate condition correctly simplified since Deepgram is now always used.
backend/utils/stt/streaming.py Removes process_audio_soniox, process_audio_speechmatics, the Soniox language lists, and trims STTService enum to deepgram only; get_stt_service_for_language correctly updated for the remaining provider.
backend/database/redis_db.py Cleanly removes three Soniox Redis helpers (set/get/remove_user_soniox_speech_profile); no remaining callers.
backend/utils/webhooks.py Removes the stub connect_user_webhook_ws() function (empty URI, copy-pasted Speechmatics log messages, never called) and the now-unused websockets import.
backend/routers/speech_profile.py Removes remove_user_soniox_speech_profile import and its single call after uploading a speech profile.
backend/requirements.txt Drops soniox==1.10.1 and speechmatics-python==2.0.1 from the dependency list.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Client WebSocket connect
stt_service: Optional str] --> B{custom STT?}
    B -- yes --> C[Use app-suggested transcripts]
    B -- no --> D{Multi-channel?}
    D -- yes --> E[process_audio_dg
per channel]
    D -- no --> F[get_stt_service_for_language]
    F --> G{STT_SERVICE_MODELS}
    G -- dg-nova-3 --> H[STTService.deepgram
model=nova-3]
    G -- dg-nova-2 --> I[STTService.deepgram
model=nova-2]
    H --> J[process_audio_dg
single-channel]
    I --> J
    J --> K{has_speech_profile?}
    K -- yes --> L[deepgram_profile_socket
preseconds window]
    K -- no --> M[deepgram_socket
direct stream]
    L --> M
Loading

Comments Outside Diff (1)

  1. backend/tests/integration/test_fair_use_api.py, line 408-420 (link)

    P1 Failing assertion: dg_usage_ms_pending count not updated after provider removal

    test_budget_accounting_across_providers asserts len(accum_calls) >= 4, but after removing Soniox and Speechmatics the only remaining dg_usage_ms_pending += lines in transcribe.py are:

    • Line ~2410 (single-channel DG send in flush_stt_buffer)
    • Line ~2496 (multi-channel DG send in receive_data)

    That is 2 accumulation points, not 4. The test will fail. The test_budget_gate_used_in_conditionals threshold was correctly updated from 5 → 3, but this assertion was missed.

    The docstring should also be updated to remove mentions of Soniox/Speechmatics.

Reviews (1): Last reviewed commit: "test(stt): update fair use guard point c..." | Re-trigger Greptile

Comment on lines 30 to 33
@staticmethod
def get_model_name(value):
if value == STTService.deepgram:
return 'deepgram_streaming'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 get_model_name implicitly returns None for unrecognised values

With Soniox/Speechmatics branches removed, the method only handles STTService.deepgram. Any other value (impossible today since the enum has a single member, but a defensive concern) falls through with an implicit None return, which is silent and hard to debug. Consider either adding an explicit else branch or removing the method entirely since it has only one meaningful path now.

Suggested change
@staticmethod
def get_model_name(value):
if value == STTService.deepgram:
return 'deepgram_streaming'
@staticmethod
def get_model_name(value):
if value == STTService.deepgram:
return 'deepgram_streaming'
return None # Unknown / unsupported provider

beastoin and others added 16 commits March 28, 2026 10:28
With Soniox and Speechmatics removed, only DG single-channel and
multi-channel accumulation paths remain.

Fixes #6116

Co-Authored-By: Claude Opus 4.6 <[email protected]>
With Soniox and Speechmatics removed, only DG single-channel and
multi-channel accumulation paths remain.

Fixes #6116

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Removes all references to Soniox and Speechmatics STT providers,
which have been removed from the backend. Backend now uses only Deepgram.

Fixes #6116

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Removes Soniox and Speechmatics from diagrams, provider tables,
and parameter descriptions. Backend now uses only Deepgram.

Fixes #6116

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Comment no longer refers to a removed provider.

Fixes #6116

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@beastoin beastoin left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@beastoin
beastoin merged commit a11aff4 into main Mar 28, 2026
2 checks passed
@beastoin
beastoin deleted the fix/remove-dead-stt-6116 branch March 28, 2026 11:01
mdmohsin7 added a commit that referenced this pull request Mar 28, 2026
## Summary
- Bump app build number from 1.0.528+794 to 1.0.528+795
- 287 commits since last Codemagic build (v1.0.528+792)

Key changes in this release:
- **PR #5995**: Phone mic WAL + AudioSource refactor (backend already
deployed)
- **PR #6118**: Remove dead Speechmatics/Soniox STT code
- **PR #6119**: Remove redundant desktop code from app/
- **PR #6103/#6061**: Transcribe fallback removal + pusher recovery
- **PR #6083**: Free-tier fair-use enforcement
- **Lock bypass fixes**: 19+ security fixes for locked conversations
- **BLE reliability**: Native-owned BLE connection pipeline
- **Phone call UI**: Minimizable phone call with home screen banner

## After merge
1. Tag for Codemagic: `git tag v1.0.528+795-mobile-cm && git push origin
v1.0.528+795-mobile-cm`
2. Monitor Codemagic build → TestFlight/Play Store internal test

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
## Summary
- Bump app build number from 1.0.528+794 to 1.0.528+795
- 287 commits since last Codemagic build (v1.0.528+792)

Key changes in this release:
- **PR BasedHardware#5995**: Phone mic WAL + AudioSource refactor (backend already
deployed)
- **PR BasedHardware#6118**: Remove dead Speechmatics/Soniox STT code
- **PR BasedHardware#6119**: Remove redundant desktop code from app/
- **PR BasedHardware#6103/BasedHardware#6061**: Transcribe fallback removal + pusher recovery
- **PR BasedHardware#6083**: Free-tier fair-use enforcement
- **Lock bypass fixes**: 19+ security fixes for locked conversations
- **BLE reliability**: Native-owned BLE connection pipeline
- **Phone call UI**: Minimizable phone call with home screen banner

## After merge
1. Tag for Codemagic: `git tag v1.0.528+795-mobile-cm && git push origin
v1.0.528+795-mobile-cm`
2. Monitor Codemagic build → TestFlight/Play Store internal test

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

Remove dead Speechmatics and Soniox STT code from backend

1 participant