from gtts import gTTS def text_to_speech(input): """ text_to_speech(input) receives the message from discord and returns an MP3 of it. If you pass in a language after a semicolon, it will return it read in that language. eg: what are you doing; ja, will return a file read by a japanese robot List of supported languages here: https://github.com/pndurette/gTTS/tree/050377d2424b137cfb084a37fc1ec9b0d07bfee1#supported-languages """ file_path = '/tmp/memes.mp3' message = ' '.join(input.split()[1:]) language = 'en' # check for another language denoted at the end of the message if ';' in message: print(message.split(';')) language = message.split(';')[1].strip() message = message.split(';')[0] gTTS( text=message, lang=language, slow=False ).save(file_path) return file_path