Skip to content

feat(telegram): voice-in via Whisper transcription #318

Closed

Description

@vybe

Problem

src/backend/adapters/telegram_adapter.py:681-682 detects Telegram voice messages and returns a static placeholder:

[User sent a voice message — voice transcription is not yet available]

Users who prefer voice — common on mobile, accessibility, non-English typists — are effectively blocked from using Telegram-shared agents. The bot silently drops the content of every voice note.

Proposed approach

Transcribe voice messages with OpenAI Whisper before they hit the agent, so from the agent's perspective a voice note is just another text message.

Flow:

  1. Adapter sees message.voice in a Telegram update
  2. telegram_media.py downloads the OGG/Opus file (reuse existing 20MB + SSRF guards)
  3. New services/transcription_service.py POSTs to Whisper API (/v1/audio/transcriptions, model=whisper-1)
  4. Adapter substitutes the transcript for the placeholder, optionally prefixed (e.g. 🎙️ "<transcript>") so the agent knows the original was spoken
  5. Failures (rate limit, oversize, API down) → fall back to the current placeholder with the error reason

What's actually new

  • services/transcription_service.py — thin Whisper client with retries
  • Extend services/telegram_media.py to handle voice and audio payloads
  • Replace the placeholder in telegram_adapter.py:681
  • Platform setting OPENAI_API_KEY (reuse settings_service.py) — per-platform, not per-agent, since voice is a platform capability

Open questions

  • Cost attribution: Whisper is ~$0.006/min. Count against the agent's cost or platform overhead? Leaning platform, logged per-agent.
  • Language detection: Whisper auto-detects. Should we expose a per-binding language_hint for noisy environments?
  • Video notes (video_note): same pipeline? Extract audio track, then transcribe.

Out of scope

  • ElevenLabs / TTS reply (tracked separately)
  • Proactive messaging (tracked separately)
  • Non-Telegram channels (Slack, web) — same approach will apply later but not in this issue

Activity

  1. added
    priority-p2
    type-feature
    on Apr 13, 2026
  2. m13v commented on Apr 13, 2026

    @m13v

    we built exactly this pipeline for voice input in a macOS agent. the Whisper API approach is fine for the happy path, but two things to watch for: Telegram voice messages are OGG/Opus with variable bitrates, and Whisper expects specific audio formats (16kHz mono WAV/FLAC). you need an ffmpeg or pydub conversion step before hitting the API, otherwise you get garbled transcriptions on longer messages. the other gotcha is cost attribution as you mentioned. we ended up capping voice transcription at 2 minutes per message and returning a truncation notice for anything longer. most voice notes are under 30 seconds anyway, so the cap rarely triggers. for the failure fallback, include the file duration in the error placeholder so users know their 5-minute voice novel was too long.

  3. m13v commented on Apr 13, 2026

    @m13v

    our voice transcription pipeline that handles audio format conversion, model loading, and the chunked processing flow: https://github.com/m13v/fazm/blob/main/Desktop/Sources/TranscriptionService.swift

  4. added
    status-in-progress
    on Apr 18, 2026
  5. added
    complexity-medium
    theme-channels
    on Jun 3, 2026
  6. removed
    status-in-progress
    on Aug 7, 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

    complexity-mediumpriority-p2theme-channelstype-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions