🔭 修复 gtts lang 格式问题

This commit is contained in:
Xtao_dada 2020-06-07 01:21:33 +08:00 committed by GitHub
parent fa44e8a23e
commit 9ee311810e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,7 +73,7 @@ async def tts(context):
try: try:
await context.edit("生成语音中 . . .") await context.edit("生成语音中 . . .")
gTTS(message, lang) gTTS(message, lang=lang)
except AssertionError: except AssertionError:
await context.edit("出错了呜呜呜 ~ 无效的参数。") await context.edit("出错了呜呜呜 ~ 无效的参数。")
return return
@ -83,13 +83,13 @@ async def tts(context):
except RuntimeError: except RuntimeError:
await context.edit('出错了呜呜呜 ~ 加载语言数组时出错。') await context.edit('出错了呜呜呜 ~ 加载语言数组时出错。')
return return
google_tts = gTTS(message, lang) google_tts = gTTS(message, lang=lang)
google_tts.save("vocals.mp3") google_tts.save("vocals.mp3")
with open("vocals.mp3", "rb") as audio: with open("vocals.mp3", "rb") as audio:
line_list = list(audio) line_list = list(audio)
line_count = len(line_list) line_count = len(line_list)
if line_count == 1: if line_count == 1:
google_tts = gTTS(message, lang) google_tts = gTTS(message, lang=lang)
google_tts.save("vocals.mp3") google_tts.save("vocals.mp3")
with open("vocals.mp3", "r"): with open("vocals.mp3", "r"):
await context.client.send_file(context.chat_id, "vocals.mp3", voice_note=True) await context.client.send_file(context.chat_id, "vocals.mp3", voice_note=True)