Add BytesIO seek to fix empty file error

"ValueError: embedded null byte" error on the discord attachment due to the data being read from the end.
pull/104/head
imnotverygood 5 years ago committed by GitHub
parent ebe59c9370
commit 783da9ac32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -24,10 +24,11 @@ class TTS(Cog):
@commands.command(aliases=["t2s", "text2"])
async def tts(self, ctx: commands.Context, *, text: str):
"""
"""
Send Text to speech messages as an mp3
"""
mp3_fp = io.BytesIO()
tts = gTTS(text, "en")
tts.write_to_fp(mp3_fp)
await ctx.send(file=discord.File(mp3_fp.getvalue(), "text.mp3"))
mp3_fp.seek(0)
await ctx.send(file=File(mp3_fp, "text.mp3"))

Loading…
Cancel
Save