Skip to content

Commit 51e3d45

Browse files
Vesperclaude
andcommitted
feat: delegate voice transcription to Claude instead of built-in whisper
Remove direct whisper dependency. Pass voice file path to Claude with a generic instruction to transcribe using available tools. Claude discovers and uses whatever STT MCP server is configured. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e368bfc commit 51e3d45

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

src/commands/telegram.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ensureProjectClaudeMd, run, runUserMessage, isRateLimited, getRateLimitResetAt } from "../runner";
22
import { getSettings, loadSettings } from "../config";
33
import { resetSession } from "../sessions";
4-
import { transcribeAudioToText } from "../whisper";
54
import { mkdir } from "node:fs/promises";
65
import { existsSync } from "node:fs";
76
import { extname, join } from "node:path";
@@ -636,7 +635,6 @@ async function handleMessage(message: TelegramMessage): Promise<void> {
636635
await sendTyping(config.token, chatId, threadId);
637636
let imagePath: string | null = null;
638637
let voicePath: string | null = null;
639-
let voiceTranscript: string | null = null;
640638
if (hasImage) {
641639
try {
642640
imagePath = await downloadImageFromMessage(config.token, message);
@@ -647,21 +645,10 @@ async function handleMessage(message: TelegramMessage): Promise<void> {
647645
if (hasVoice) {
648646
try {
649647
voicePath = await downloadVoiceFromMessage(config.token, message);
648+
if (voicePath) debugLog(`Voice file saved: path=${voicePath}`);
650649
} catch (err) {
651650
console.error(`[Telegram] Failed to download voice for ${label}: ${err instanceof Error ? err.message : err}`);
652651
}
653-
654-
if (voicePath) {
655-
try {
656-
debugLog(`Voice file saved: path=${voicePath}`);
657-
voiceTranscript = await transcribeAudioToText(voicePath, {
658-
debug: telegramDebug,
659-
log: (message) => debugLog(message),
660-
});
661-
} catch (err) {
662-
console.error(`[Telegram] Failed to transcribe voice for ${label}: ${err instanceof Error ? err.message : err}`);
663-
}
664-
}
665652
}
666653

667654
let documentInfo: { path: string; fileName: string; fileSize: number } | null = null;
@@ -682,12 +669,12 @@ async function handleMessage(message: TelegramMessage): Promise<void> {
682669
} else if (hasImage) {
683670
promptParts.push("The user attached an image, but downloading it failed. Respond and ask them to resend.");
684671
}
685-
if (voiceTranscript) {
686-
promptParts.push(`Voice transcript: ${voiceTranscript}`);
687-
promptParts.push("The user attached voice audio. Use the transcript as their spoken message.");
672+
if (voicePath) {
673+
promptParts.push(`Voice file path: ${voicePath}`);
674+
promptParts.push("The user sent a voice message. Transcribe it using an available transcription tool, then respond to the transcribed text as their spoken message.");
688675
} else if (hasVoice) {
689676
promptParts.push(
690-
"The user attached voice audio, but it could not be transcribed. Respond and ask them to resend a clearer clip."
677+
"The user attached voice audio, but downloading it failed. Respond and ask them to resend."
691678
);
692679
}
693680
if (documentInfo) {

0 commit comments

Comments
 (0)