using tmpefiles for tts so now we dont step on eachothers memes

This commit is contained in:
Luke Robles 2021-12-16 15:53:21 -08:00
parent cb59d090b5
commit 6dfb5b2d8d
2 changed files with 5 additions and 4 deletions

View File

@ -447,15 +447,15 @@ async def tts(ctx):
"Ok {}, check your DMs".format(ctx.message.author.mention)
)
return await ctx.message.author.send(tts.get_all_langs())
file_path = tts.text_to_speech(ctx.message.content)
await ctx.send(
file=discord.File(
tts.text_to_speech(ctx.message.content),
file_path,
filename="A Message From {}.mp3".format(ctx.message.author.name)
)
)
await ctx.message.delete()
os.remove('/tmp/memes.mp3')
os.remove(file_path)
@bot.command(name='issue')
async def issue(ctx):

View File

@ -1,4 +1,5 @@
from gtts import gTTS, lang
import tempfile
def text_to_speech(input):
"""
@ -8,7 +9,7 @@ def text_to_speech(input):
that language. eg: what are you doing; ja, will return a file read by a japanese
robot
"""
file_path = '/tmp/memes.mp3'
file, file_path = tempfile.mkstemp()
message = ' '.join(input.split()[1:])
language = 'en'