diff --git a/app/bot.py b/app/bot.py index 3bb99be6..069c3d49 100755 --- a/app/bot.py +++ b/app/bot.py @@ -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): diff --git a/app/tts.py b/app/tts.py index dde77d13..ab5951ef 100755 --- a/app/tts.py +++ b/app/tts.py @@ -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'