diff --git a/transcribebot.py b/transcribebot.py index 30f6ab0..f6f1416 100644 --- a/transcribebot.py +++ b/transcribebot.py @@ -12,15 +12,19 @@ bot = commands.Bot(command_prefix='.') @bot.message_command(name="Transcrible") async def transcribe(inter: disnake.ApplicationCommandInteraction, message: disnake.Message): - await inter.response.defer(ephemeral='true') - await message.attachments[0].save("audio.ogg") - mp3file = AudioSegment.from_ogg("audio.ogg") - mp3file.export("audio.wav", format="wav") - convertemessage = sr.AudioFile("audio.wav") - with convertemessage as sounds: - transcribeaudo = st.record(sounds) - await inter.edit_original_message(content=st.recognize_sphinx(transcribeaudo)) - os.remove("audio.ogg") - os.remove("audio.wav") + try: + await inter.response.defer(ephemeral='true') + await message.attachments[0].save("audio.ogg") + mp3file = AudioSegment.from_ogg("audio.ogg") + mp3file.export("audio.wav", format="wav") + convertemessage = sr.AudioFile("audio.wav") + with convertemessage as sounds: + transcribeaudo = st.record(sounds) + await inter.edit_original_message(content=st.recognize_sphinx(transcribeaudo)) + os.remove("audio.ogg") + os.remove("audio.wav") + except Exception as e: + await inter.edit_original_message(content=f'an error appears to have occoured please report it to the developer: {e}') + bot.run(os.getenv("TOKEN")) \ No newline at end of file