Skip to content

feat(stt): populate segments for OpenAI-compatible and Mistral STT (and check OpenRouter) #324

Open

Description

@lfnovo

Context

content-core wants timestamped segments from transcriptions on a best-effort basis (lfnovo/content-core#119). It will read TranscriptionResponse.segments and fall back to plain text when it is None. That works today for OpenAI/Groq Whisper, Azure Whisper and Deepgram. Several other STT providers drop timing data that their endpoint can return, so callers using them get plain text even when the backend has segments.

Checked on main (2.28.0), src/esperanto/providers/stt/.

Gaps

OpenAI-compatible (openai_compatible.py)

Builds TranscriptionResponse(text=response_data["text"], ...) (lines ~282 and ~340) and sends no response_format. Whisper-based servers behind this provider (Speaches/faster-whisper-server, LocalAI, whisper.cpp server, vLLM Whisper) support verbose_json with the same segment shape as OpenAI.

Proposal: reuse _resolve_transcription_response_format(model, config.get("response_format")) and _build_transcription_response(...) from base.py, as openai.py/azure.py already do. Keep the allowlist behavior (only Whisper-named models get verbose_json, config["response_format"] overrides) so non-Whisper servers keep working.

Mistral Voxtral (mistral.py)

Already maps through _build_transcription_response, so it would fill segments if the payload had them. But _build_request_data never sends timestamp_granularities, so the API returns no segments. Proposal: request timestamp_granularities=["segment"] (verify against the current Mistral transcription API and whether it conflicts with language).

OpenRouter (openrouter.py)

Only text, language, duration and usage are mapped. Check whether the OpenRouter transcription endpoint returns segments for any model. If it does, map them. If not, document it as unsupported per "Unsupported Response Fields Stay None".

Out of scope (already decided)

Acceptance

  • OpenAI-compatible with a Whisper model returns segments and duration. A non-Whisper model still gets json and segments=None.
  • Mistral returns segments when the API provides them.
  • OpenRouter is either mapped or documented as unsupported in its AGENTS.md.
  • Unit tests with mocked payloads for each case.

Activity

  1. lfnovo commented on Nov 18, 2026

    @lfnovo
    OwnerAuthor

    Checked the current provider docs (2026-11-18):

    • Mistral: timestamp_granularities=segment returns segments with text/start/end; word level returns 400 ("Word-level segments are not enabled for this model"). diarize=true adds speaker_id per segment but requires segment timestamps. The response language is null when pinned; return_language=true returns the detected one. https://docs.mistral.ai/studio/audio/speech-to-text/transcribe-files
    • OpenRouter: /audio/transcriptions accepts response_format=verbose_json and timestamp_granularities[] (segment, word). With verbose_json it returns segments (id/start/end/text, plus optional speaker) and words, but the docs say verbose_json only works with OpenAI-compatible upstream providers. So OpenRouter is in scope: same allowlist logic as openai.py, keyed on the routed model. https://openrouter.ai/docs/api/api-reference/stt/create-transcription.md

    Generated by Claude Code

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions