Add method to print out all the languages supported by tts
This commit is contained in:
parent
a93b974b98
commit
e899211ee8
@ -344,6 +344,11 @@ async def on_message(message):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if message.content.startswith('!tts'):
|
if message.content.startswith('!tts'):
|
||||||
|
if message.content.split()[1] == 'langs':
|
||||||
|
return await client.send_message(
|
||||||
|
message.channel,
|
||||||
|
tts.get_all_langs()
|
||||||
|
)
|
||||||
await client.send_file(
|
await client.send_file(
|
||||||
message.channel,
|
message.channel,
|
||||||
tts.text_to_speech(message.content),
|
tts.text_to_speech(message.content),
|
||||||
|
@ -114,7 +114,8 @@ def get_help_message(method):
|
|||||||
],
|
],
|
||||||
'tts': [
|
'tts': [
|
||||||
'Uploads a file with the specified text as an MP3.\nThis is advanced shitposting',
|
'Uploads a file with the specified text as an MP3.\nThis is advanced shitposting',
|
||||||
'\nUsage: !tts who watches the watchmen?'
|
'\nUsage: !tts who watches the watchmen?',
|
||||||
|
'\nTo list all languages, you can type `!tts langs`'
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
app/tts.py
16
app/tts.py
@ -1,4 +1,5 @@
|
|||||||
from gtts import gTTS
|
from gtts import gTTS
|
||||||
|
from gtts import lang
|
||||||
|
|
||||||
def text_to_speech(input):
|
def text_to_speech(input):
|
||||||
"""
|
"""
|
||||||
@ -7,9 +8,6 @@ def text_to_speech(input):
|
|||||||
If you pass in a language after a semicolon, it will return it read in
|
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
|
that language. eg: what are you doing; ja, will return a file read by a japanese
|
||||||
robot
|
robot
|
||||||
|
|
||||||
List of supported languages here:
|
|
||||||
https://github.com/pndurette/gTTS/tree/050377d2424b137cfb084a37fc1ec9b0d07bfee1#supported-languages
|
|
||||||
"""
|
"""
|
||||||
file_path = '/tmp/memes.mp3'
|
file_path = '/tmp/memes.mp3'
|
||||||
message = ' '.join(input.split()[1:])
|
message = ' '.join(input.split()[1:])
|
||||||
@ -28,3 +26,15 @@ def text_to_speech(input):
|
|||||||
).save(file_path)
|
).save(file_path)
|
||||||
|
|
||||||
return file_path
|
return file_path
|
||||||
|
|
||||||
|
def get_all_langs():
|
||||||
|
"""
|
||||||
|
get_all_langs()
|
||||||
|
|
||||||
|
returns a dictionary with all supported languages
|
||||||
|
"""
|
||||||
|
blob = ""
|
||||||
|
for key, value in lang.tts_langs().items():
|
||||||
|
blob += "{}: {}\n".format(key, value)
|
||||||
|
|
||||||
|
return "```css\n{}```".format(blob)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user