From 05097f550ef1ae2eb47b7315df14c6defc087347 Mon Sep 17 00:00:00 2001 From: allinoneallinone00 Date: Mon, 10 Jun 2024 13:07:39 +0000 Subject: [PATCH] fix: `UnboundLocalError` on tts without prompt --- modules/safone.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/safone.py b/modules/safone.py index 6630512f..06569a6e 100644 --- a/modules/safone.py +++ b/modules/safone.py @@ -316,6 +316,8 @@ async def tts(client: Client, message: Message): audio=f"{prompt}.mp3", caption=f"Characters: {character}\nPrompt: {prompt}", ) + if os.path.exists(f"{prompt}.mp3"): + os.remove(f"{prompt}.mp3") except KeyError: try: @@ -327,12 +329,11 @@ async def tts(client: Client, message: Message): ) except Exception as e: await message.edit_text(format_exc(e)) - finally: - if os.path.exists(f"{prompt}.mp3"): - os.remove(f"{prompt}.mp3") -@Client.on_message(filters.command(["carbonnowsh", "carboon", "carbon", "cboon"], prefix) & filters.me) +@Client.on_message( + filters.command(["carbonnowsh", "carboon", "carbon", "cboon"], prefix) & filters.me +) async def carbon(client: Client, message: Message): if message.reply_to_message.text: text = message.reply_to_message.text