You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds transcribe_voice, a dual-engine transcription tool: Groq-hosted
whisper-large-v3-turbo (default, leaves the server but preserves the full
recording) and native Telegram Premium transcription (free, audio never
leaves Telegram, but empirically drops the last speech segment in roughly
2 of 3 recordings, so it's kept as an explicit opt-in fallback rather than
the default). Native results are polled while pending instead of returned
as truncated text.
Results are cached by (chat_id, message_id) in a dedicated SQLite file
(0600/0700 permissions, mounted as its own Docker volume so it survives a
rebuild) since Groq transcription is a real per-call cost, not free like
native. get_history/get_messages/list_messages now surface cached
transcripts inline instead of showing empty text for voice messages;
TELEGRAM_TRANSCRIBE controls whether listings only show what's already
cached (default) or also prefetch missing ones, bounded by a per-call
budget so one large listing can't trigger dozens of downloads+uploads.
Engine selection is configurable both ways: an explicit engine= argument
on transcribe_voice, and a TELEGRAM_TRANSCRIBE_ENGINE default for callers
that don't pass one. Every transcript is returned/rendered with an explicit
note that it's a machine transcript, not a verbatim quote. transcribe_voice
is read-only-annotated so it stays exposed under TELEGRAM_EXPOSED_TOOLS=
read-only.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+45-1Lines changed: 45 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,24 @@ The server currently includes 80+ MCP tools grouped into these areas:
57
57
When a reference is unknown, resembles one contact, matches several, or points at a contact that no longer resolves, tools send nothing and return a structured instruction telling the agent exactly what to ask you, to save the answer with `set_contact_alias`, and to retry once. `list_contact_aliases` shows one row per person with all their aliases (use it to spot a wrong memory), `delete_contact_alias` forgets one, and repointing an alias at someone else requires `replace=True`. The save path itself refuses a target it would have to guess at: contacts are saved by @username, phone, numeric ID, or an alias already confirmed for them.
58
58
59
59
Aliases live in `${XDG_STATE_HOME:-~/.local/state}/telegram-mcp/aliases.json` (owner-only, written atomically); `TELEGRAM_ALIASES_FILE` overrides the path, and a pre-existing `aliases.json` next to the code is still read as a fallback.
`transcribe_voice(chat_id, message_id, engine=None)` turns a voice message or video note into text. Two engines are available:
65
+
66
+
-`groq` (default): uploads the recording to Groq's hosted `whisper-large-v3-turbo`. Leaves the server and costs a download+upload per call, but doesn't drop the recording's last few words the way native transcription does. Requires `GROQ_API_KEY`.
67
+
-`telegram`: native Telegram Premium transcription (`messages.TranscribeAudioRequest`). Free and never leaves Telegram, but empirically drops the last speech segment in roughly 2 of 3 recordings and requires Telegram Premium on the account. Long recordings come back `pending` and are polled automatically.
68
+
69
+
The engine is chosen per call via the `engine` argument, or otherwise defaults to `TELEGRAM_TRANSCRIBE_ENGINE` (`groq` or `telegram`). Results are cached by `(chat_id, message_id)` in a local SQLite file so repeat reads and repeat listings never re-transcribe the same message. Every transcript is returned with a `note` marking it as a machine transcript, not a verbatim quote — treat it as a paraphrase, not exact wording.
70
+
71
+
`get_history`, `get_messages`, and `list_messages` fill in already-cached transcripts for voice messages instead of leaving the text empty, controlled by `TELEGRAM_TRANSCRIBE`:
72
+
73
+
-`off`: `transcribe_voice` is disabled and listings never show transcripts.
74
+
-`on-demand` (default): listings show cached transcripts but never spend an API call fetching a new one.
75
+
-`auto`: listings also prefetch missing transcripts, bounded per call by `TELEGRAM_TRANSCRIBE_MAX_VOICES`/`TELEGRAM_TRANSCRIBE_MAX_SECONDS` (Groq isn't free, so this prefetch is budgeted rather than unbounded).
76
+
77
+
The cache lives in `TELEGRAM_TRANSCRIPT_CACHE_DIR` (default `data/transcripts`), written as a 700 directory / 600 file since it holds personal-chat text in plaintext — see [Docker](#docker) for why this needs its own volume mount in a container.
61
78
-**Profile and privacy:** get your own account info, update profile fields, set or delete profile photos, inspect privacy settings, get user info/photos/status, and manage bot commands.
62
79
-**Folders and drafts:** list, create, update, reorder, and delete Telegram folders; save, list, and clear drafts.
63
80
-**Events:** wait for incoming messages with debounce (`wait_for_new_message`, `wait_for_settled_message`), optionally for one chat only via `chat_id` — without it any unrelated conversation wakes the wait — or enable the opt-in incoming event feed for callback-style delivery (see below).
@@ -161,6 +178,23 @@ normal authority inside the server process; read-only mode only prevents
161
178
non-read-only tools from being registered and exposed through MCP. Accepted
162
179
values are `all` (the default), `read-only`, and `read-only+<tool>,<tool>`.
163
180
181
+
Voice transcription (see [Voice transcription](#voice-transcription) above) is
182
+
off by default in the sense that no transcript is ever fetched unless you ask
183
+
for one — `transcribe_voice` is always available, and listings only pick up
184
+
already-cached transcripts. Enable prefetching or pick an engine explicitly:
185
+
186
+
```env
187
+
TELEGRAM_TRANSCRIBE=on-demand # off / on-demand (default) / auto
188
+
TELEGRAM_TRANSCRIBE_ENGINE=groq # groq (default) or telegram
189
+
GROQ_API_KEY=your_groq_api_key_here # required whenever engine=groq is used
0 commit comments