Skip to content

Commit

Permalink
fix: UnboundLocalError on tts without prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiTheModder committed Jun 10, 2024
1 parent e9101f9 commit 05097f5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions modules/safone.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ async def tts(client: Client, message: Message):
audio=f"{prompt}.mp3",
caption=f"<b>Characters:</b> <code>{character}</code>\n<b>Prompt:</b> <code>{prompt}</code>",
)
if os.path.exists(f"{prompt}.mp3"):
os.remove(f"{prompt}.mp3")

except KeyError:
try:
Expand All @@ -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
Expand Down

0 comments on commit 05097f5

Please sign in to comment.