done maybe?
This commit is contained in:
parent
0ac6b222bb
commit
750091730f
1 changed files with 12 additions and 1 deletions
|
@ -2,7 +2,11 @@ import disnake
|
||||||
from disnake.ext import commands
|
from disnake.ext import commands
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import os
|
import os
|
||||||
|
from os import path
|
||||||
|
from pydub import AudioSegment
|
||||||
|
import speech_recognition as sr
|
||||||
|
|
||||||
|
st = sr.Recognizer()
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
bot = commands.Bot(command_prefix='.')
|
bot = commands.Bot(command_prefix='.')
|
||||||
|
|
||||||
|
@ -10,6 +14,13 @@ bot = commands.Bot(command_prefix='.')
|
||||||
async def transcribe(inter: disnake.ApplicationCommandInteraction, message: disnake.Message):
|
async def transcribe(inter: disnake.ApplicationCommandInteraction, message: disnake.Message):
|
||||||
# Reversing the message and sending it back.
|
# Reversing the message and sending it back.
|
||||||
await message.attachments[0].save("audio.mp3")
|
await message.attachments[0].save("audio.mp3")
|
||||||
await inter.response.send_message("audio saved", file=disnake.File("audio.mp3"))
|
mp3file = AudioSegment.from_mp3("audio.mp3")
|
||||||
|
mp3file.export("audio.wav", format="wav")
|
||||||
|
convertemessage = sr.AudioFile("audio.wav")
|
||||||
|
with convertemessage as sounds:
|
||||||
|
transcribeaudo = st.record(sounds)
|
||||||
|
await inter.response.send_message(st.recognize_sphinx(transcribeaudo), file=disnake.File("audio.mp3"))
|
||||||
|
os.remove("audio.mp3")
|
||||||
|
os.remove("audio.wav")
|
||||||
|
|
||||||
bot.run(os.getenv("TOKEN"))
|
bot.run(os.getenv("TOKEN"))
|
Loading…
Reference in a new issue