Skip to content

Add Modulate (Velma-2) as second STT provider for streaming and pre-recorded #7140

Closed as not planned

Description

@beastoin

Summary

Revive Modulate (Velma-2) integration as the second STT provider alongside Deepgram, supporting both streaming WebSocket and batch/pre-recorded transcription.

Prior art: PR #5593 (closed 2026-03-17) implemented a working prototype with 32 unit tests. The code was architecturally sound but closed because "modulate is not ready for our high demand." The feature should now be implemented.

Since PR #5593: The backend was simplified on March 28, 2026 — Soniox and Speechmatics were removed, leaving Deepgram as the sole STT provider. The old PR's multi-provider wiring in transcribe.py no longer applies. A fresh implementation against the current single-provider architecture is needed.

Scope

Streaming (WebSocket)

  • Add STTService.modulate enum value
  • Implement process_audio_modulate() in streaming.py with WAV header support, speaker diarization, and preseconds filtering
  • Wire into _stream_handler() in transcribe.py (single-channel and multi-channel paths)
  • Feature-gated via STT_SERVICE_MODELS env var (e.g., modulate-velma-2)
  • EOS signal + delay before close for final transcript delivery
  • Socket interface: send(), finalize(), finish(), is_connection_dead

Pre-recorded (Batch REST)

  • Implement modulate_prerecorded_from_bytes() in pre_recorded.py
  • Output format: [{'timestamp': [start, end], 'speaker': 'SPEAKER_XX', 'text': 'word'}] (same as Deepgram)
  • Speaker ID mapping: Modulate 1-indexed → SPEAKER_XX 0-indexed
  • Timestamp conversion: ms → seconds
  • Retry with RuntimeError on exhaustion (not silent empty return)

Infrastructure

  • MODULATE_API_KEY env var + GCP Secret Manager
  • Helm chart updates: backend-listen, pusher, backend-secrets ExternalSecret
  • .env.template update
  • Language routing in get_stt_service_for_language() with Deepgram fallback for unsupported languages

Tests

  • Unit tests: enum, language routing, streaming message parsing, speaker ID mapping, timestamp conversion, preseconds skip, batch API, error handling, WAV header, retry exhaustion
  • Integration: verify batch API connectivity with real key (streaming if available)

Architecture Notes

  • Current architecture is Deepgram-only (Soniox/Speechmatics removed March 28, 2026)
  • Socket interface contract: send/finalize/finish/is_connection_dead (see SafeDeepgramSocket)
  • VAD gate compatibility: new socket should work with GatedDeepgramSocket wrapper
  • BYOK: not required for initial launch (Modulate doesn't have per-user key model)
  • Default behavior unchanged — Deepgram remains default unless STT_SERVICE_MODELS includes modulate-velma-2

Reference

Activity

  1. added
    p3
    on May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions