Add Whisper voice transcription to Telegram bot
- handleVoice() downloads Telegram audio and transcribes via Whisper API - transcribeAudio() calls Whisper with Basic Auth, handles json response - TelegramWebhookController now routes message.voice and message.audio - Whisper URL, token and toggle configurable from admin config panel - Transcribed text echoed back to user then processed as normal text intent Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
ad9d1761d2
commit
f39f3d4045
@@ -29,6 +29,18 @@ class TelegramWebhookController extends Controller
|
||||
return response()->json(['ok' => true]);
|
||||
}
|
||||
|
||||
// Voice / audio messages
|
||||
if (isset($update['message']['voice']) || isset($update['message']['audio'])) {
|
||||
$chatId = (string) $update['message']['chat']['id'];
|
||||
$fileId = $update['message']['voice']['file_id'] ?? $update['message']['audio']['file_id'];
|
||||
$nombre = trim(
|
||||
($update['message']['from']['first_name'] ?? '') . ' ' .
|
||||
($update['message']['from']['last_name'] ?? '')
|
||||
);
|
||||
$bot->handleVoice($chatId, $fileId, $nombre);
|
||||
return response()->json(['ok' => true]);
|
||||
}
|
||||
|
||||
// Text messages
|
||||
if (isset($update['message']['text'])) {
|
||||
$chatId = (string) $update['message']['chat']['id'];
|
||||
|
||||
@@ -27,6 +27,11 @@ class ShowConfiguracionChat extends Component
|
||||
public string $validacion_accion_auto = 'solo_notificar';
|
||||
public string $validacion_monto_tolerancia = '0';
|
||||
|
||||
// ── Whisper STT ───────────────────────────────────────────
|
||||
public string $whisper_url = '';
|
||||
public string $whisper_token = '';
|
||||
public string $whisper_habilitado = '0';
|
||||
|
||||
// ── Bre-B ─────────────────────────────────────────────────
|
||||
public string $recarga_banco_nombre = '';
|
||||
public string $recarga_banco_llave = '';
|
||||
@@ -38,6 +43,7 @@ class ShowConfiguracionChat extends Component
|
||||
'telegram_token', 'mensaje_bienvenida', 'mensaje_transferencia',
|
||||
'gemini_api_key', 'gemini_habilitado', 'gemini_prompt_extra',
|
||||
'validacion_foto_habilitada', 'validacion_accion_auto', 'validacion_monto_tolerancia',
|
||||
'whisper_url', 'whisper_token', 'whisper_habilitado',
|
||||
'recarga_banco_nombre', 'recarga_banco_llave', 'recarga_banco_titular',
|
||||
];
|
||||
|
||||
@@ -68,6 +74,7 @@ class ShowConfiguracionChat extends Component
|
||||
'telegram_token', 'mensaje_bienvenida', 'mensaje_transferencia',
|
||||
'gemini_api_key', 'gemini_habilitado', 'gemini_prompt_extra',
|
||||
'validacion_foto_habilitada', 'validacion_accion_auto', 'validacion_monto_tolerancia',
|
||||
'whisper_url', 'whisper_token', 'whisper_habilitado',
|
||||
'recarga_banco_nombre', 'recarga_banco_llave', 'recarga_banco_titular',
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user