error checking
This commit is contained in:
parent
9cf7985f35
commit
035ef71814
1 changed files with 14 additions and 10 deletions
|
@ -12,15 +12,19 @@ bot = commands.Bot(command_prefix='.')
|
||||||
|
|
||||||
@bot.message_command(name="Transcrible")
|
@bot.message_command(name="Transcrible")
|
||||||
async def transcribe(inter: disnake.ApplicationCommandInteraction, message: disnake.Message):
|
async def transcribe(inter: disnake.ApplicationCommandInteraction, message: disnake.Message):
|
||||||
await inter.response.defer(ephemeral='true')
|
try:
|
||||||
await message.attachments[0].save("audio.ogg")
|
await inter.response.defer(ephemeral='true')
|
||||||
mp3file = AudioSegment.from_ogg("audio.ogg")
|
await message.attachments[0].save("audio.ogg")
|
||||||
mp3file.export("audio.wav", format="wav")
|
mp3file = AudioSegment.from_ogg("audio.ogg")
|
||||||
convertemessage = sr.AudioFile("audio.wav")
|
mp3file.export("audio.wav", format="wav")
|
||||||
with convertemessage as sounds:
|
convertemessage = sr.AudioFile("audio.wav")
|
||||||
transcribeaudo = st.record(sounds)
|
with convertemessage as sounds:
|
||||||
await inter.edit_original_message(content=st.recognize_sphinx(transcribeaudo))
|
transcribeaudo = st.record(sounds)
|
||||||
os.remove("audio.ogg")
|
await inter.edit_original_message(content=st.recognize_sphinx(transcribeaudo))
|
||||||
os.remove("audio.wav")
|
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"))
|
bot.run(os.getenv("TOKEN"))
|
Loading…
Reference in a new issue