Async to Synck changes in voice handler
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
30c6af7f8e
commit
96cb030e19
@ -96,9 +96,10 @@ async def dispatch_private_commands(update, text):
|
|||||||
|
|
||||||
async def transcribe_with_whisper(update, bot):
|
async def transcribe_with_whisper(update, bot):
|
||||||
# 1. Descarga el archivo de voz desde Telegram
|
# 1. Descarga el archivo de voz desde Telegram
|
||||||
tg_file = await sync_to_async(bot.get_file)(update.message.voice.file_id)
|
tg_file = await bot.get_file(update.message.voice.file_id)
|
||||||
download_path = f"/tmp/{update.message.voice.file_id}.ogg"
|
download_path = f"/tmp/{update.message.voice.file_id}.ogg"
|
||||||
await sync_to_async(tg_file.download)(download_path)
|
# En python-telegram-bot v21: download_to_drive es coroutine
|
||||||
|
await tg_file.download_to_drive(download_path)
|
||||||
|
|
||||||
# 2. Envía el audio a la API Whisper de OpenAI
|
# 2. Envía el audio a la API Whisper de OpenAI
|
||||||
with open(download_path, "rb") as audio:
|
with open(download_path, "rb") as audio:
|
||||||
@ -120,7 +121,7 @@ async def telegram_webhook(request, bot_name):
|
|||||||
try:
|
try:
|
||||||
logger.info(f"Webhook called for bot: {bot_name}")
|
logger.info(f"Webhook called for bot: {bot_name}")
|
||||||
|
|
||||||
# Carga la configuración del bot
|
# Carga la configuración del bot (sync ORM)
|
||||||
try:
|
try:
|
||||||
bot_instance = await sync_to_async(TelegramBot.objects.get)(
|
bot_instance = await sync_to_async(TelegramBot.objects.get)(
|
||||||
name=bot_name, is_active=True
|
name=bot_name, is_active=True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user