fix syntax

This commit is contained in:
kandrusyak
2026-07-25 15:47:36 +03:00
parent 3f63d0305c
commit c04fb9480b
8 changed files with 56 additions and 32 deletions

View File

@@ -148,16 +148,18 @@ async def private_voice(update: Update, context: ContextTypes.DEFAULT_TYPE) -> N
)
status_message = await update.message.reply_text("Распознаю голосовое сообщение...")
temp_path: Path | None = None
transcript = ""
try:
telegram_file = await context.bot.get_file(voice.file_id)
file_descriptor, raw_path = tempfile.mkstemp(suffix=".ogg")
os.close(file_descriptor)
temp_path = Path(raw_path)
await telegram_file.download_to_drive(custom_path=temp_path)
voice_path = Path(raw_path)
temp_path = voice_path
await telegram_file.download_to_drive(custom_path=voice_path)
transcript = await asyncio.to_thread(
get_speech_recognizer(context).transcribe,
temp_path,
voice_path,
)
except (SpeechRecognitionError, TelegramError):
logger.exception("Failed to transcribe Telegram voice message")
@@ -364,7 +366,7 @@ async def remind_command(update: Update, context: ContextTypes.DEFAULT_TYPE) ->
reminder_id = get_storage(context).add_reminder(
user_id=user_id,
chat_id=int(update.effective_chat.id),
chat_id=int(update.message.chat_id),
text=parsed.text,
remind_at_utc=parsed.remind_at_utc,
)