fix speech gen

This commit is contained in:
Nexus 2023-03-16 22:49:11 +00:00
parent b22ee7c36f
commit 8fd8022115

View file

@ -832,12 +832,15 @@ class OtherCog(commands.Cog):
async def callback(self, interaction: discord.Interaction): async def callback(self, interaction: discord.Interaction):
def _convert(text: str) -> BytesIO(): def _convert(text: str) -> BytesIO():
engine = pyttsx3.init() with tempfile.makestemp(suffix=".mp3") as temp:
_io = BytesIO() engine = pyttsx3.init()
engine.save_to_file(text, _io) _io = BytesIO()
engine.runAndWait() engine.save_to_file(text, temp)
_io.seek(0) engine.runAndWait()
return _io with open(temp, "rb") as f:
_io.write(f.read())
_io.seek(0)
return _io
await interaction.response.defer() await interaction.response.defer()
_msg = await interaction.followup.send("Converting text to MP3...") _msg = await interaction.followup.send("Converting text to MP3...")