rewrite transcription
This commit is contained in:
parent
3420904ade
commit
dbb0abd467
1 changed files with 14 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
||||||
import disnake
|
import nextcord
|
||||||
from disnake.ext import commands
|
from nextcord.ext import commands
|
||||||
import os
|
import os
|
||||||
from os import path
|
from os import path
|
||||||
import asyncio
|
import asyncio
|
||||||
|
@ -23,35 +23,35 @@ class transcription(commands.Cog):
|
||||||
self.st = sr.Recognizer()
|
self.st = sr.Recognizer()
|
||||||
|
|
||||||
|
|
||||||
@commands.message_command(name="Transcribe Using Sphinx")
|
@nextcord.message_command(name="Transcribe Using Sphinx")
|
||||||
async def transcribesphinx(self, inter: disnake.ApplicationCommandInteraction, message: disnake.Message):
|
async def transcribesphinx(self, interaction: nextcord.Interaction, message: nextcord.Message):
|
||||||
try:
|
try:
|
||||||
await inter.response.defer(ephemeral='true')
|
await interaction.response.defer(ephemeral='true')
|
||||||
await message.attachments[0].save("audio.ogg")
|
await message.attachments[0].save("audio.ogg")
|
||||||
embed=disnake.Embed(title="Audio Transcription",description=self.st.recognize_sphinx(prepaudio("audio.ogg")), color=0x3584e4)
|
embed=nextcord.Embed(title="Audio Transcription",description=self.st.recognize_sphinx(prepaudio("audio.ogg")), color=0x3584e4)
|
||||||
embed.set_author(name=message.author.display_name, url=message.jump_url, icon_url=message.author.display_avatar)
|
embed.set_author(name=message.author.display_name, url=message.jump_url, icon_url=message.author.display_avatar)
|
||||||
embed.set_footer(text="Accuracy not guaranteed")
|
embed.set_footer(text="Accuracy not guaranteed")
|
||||||
await inter.edit_original_message(embed=embed)
|
await interaction.edit_original_message(embed=embed)
|
||||||
os.remove("audio.ogg")
|
os.remove("audio.ogg")
|
||||||
os.remove("audio.wav")
|
os.remove("audio.wav")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await inter.edit_original_message(content=f'an error appears to have occoured please report it to the developer: {e}')
|
await interaction.edit_original_message(content=f'an error appears to have occoured please report it to the developer: {e}')
|
||||||
|
|
||||||
@commands.message_command(name="Transcribe Using Google")
|
@nextcord.message_command(name="Transcribe Using Google")
|
||||||
async def transcribegoogle(self, inter: disnake.ApplicationCommandInteraction, message: disnake.Message):
|
async def transcribegoogle(self, interaction: nextcord.Interaction, message: nextcord.Message):
|
||||||
try:
|
try:
|
||||||
await inter.response.defer(ephemeral='true')
|
await interaction.response.defer(ephemeral='true')
|
||||||
await message.attachments[0].save("audio.ogg")
|
await message.attachments[0].save("audio.ogg")
|
||||||
# WARNING Google is propritary, consider disabling however sphynix is currently not very good so this provides an option
|
# WARNING Google is propritary, consider disabling however sphynix is currently not very good so this provides an option
|
||||||
embed=disnake.Embed(title="Audio Transcription",description=self.st.recognize_google(prepaudio("audio.ogg")), color=0x3584e4)
|
embed=nextcord.Embed(title="Audio Transcription",description=self.st.recognize_google(prepaudio("audio.ogg")), color=0x3584e4)
|
||||||
embed.set_author(name=message.author.display_name, url=message.jump_url, icon_url=message.author.display_avatar)
|
embed.set_author(name=message.author.display_name, url=message.jump_url, icon_url=message.author.display_avatar)
|
||||||
embed.set_footer(text="Accuracy not guaranteed")
|
embed.set_footer(text="Accuracy not guaranteed")
|
||||||
await inter.edit_original_message(embed=embed)
|
await interaction.edit_original_message(embed=embed)
|
||||||
await asyncio.sleep(3)
|
await asyncio.sleep(3)
|
||||||
os.remove("audio.ogg")
|
os.remove("audio.ogg")
|
||||||
os.remove("audio.wav")
|
os.remove("audio.wav")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await inter.edit_original_message(content=f'an error appears to have occoured please report it to the developer: {e}')
|
await interaction.edit_original_message(content=f'an error appears to have occoured please report it to the developer: {e}')
|
||||||
|
|
||||||
def setup(bot: commands.Bot):
|
def setup(bot: commands.Bot):
|
||||||
bot.add_cog(transcription(bot))
|
bot.add_cog(transcription(bot))
|
Loading…
Reference in a new issue