vip 支持 azure 文本转语音

This commit is contained in:
xtaodada 2021-12-13 23:22:17 +08:00
parent 5c04749c37
commit 3fc248e351
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
2 changed files with 27 additions and 3 deletions

View File

@ -322,13 +322,13 @@
}, },
{ {
"name": "vip", "name": "vip",
"version": "0.62", "version": "0.7",
"section": "chat", "section": "chat",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "9.8 kb", "size": "11.6 kb",
"supported": true, "supported": true,
"des-short": "vip 捐赠用户功能", "des-short": "vip 捐赠用户功能",
"des": "命令天气weather weather_pic weather_he\nPixivpixiv \n百度baidu Duckduckgoduckduckgo\n相似动漫whatanime。与 weather 插件冲突" "des": "命令天气weather weather_pic weather_he\nPixivpixiv \n百度baidu Duckduckgoduckduckgo\n相似动漫whatanime\n文本转语音tts_。与 weather 插件冲突"
}, },
{ {
"name": "calculator", "name": "calculator",

24
vip.py
View File

@ -267,3 +267,27 @@ async def whatanime(context):
caption=text, caption=text,
reply_to=msg.id) reply_to=msg.id)
await context.delete() await context.delete()
@listener(is_plugin=True, outgoing=True, command=alias_command("tts_"),
description="通过 Azure 文本到语音 基于字符串生成语音消息。\n\n"
"字符串末尾为 en 时,使用英文发音\n字符串末尾为 tw 时,使用台湾发音\n"
"字符串末尾为 ne 时,使用中文新闻发音\n字符串末尾为 nv 时,使用中文女音",
parameters="<字符串>")
async def az_tts(context):
await context.edit("获取中 . . .")
reply = await context.get_reply_message()
try:
message = await obtain_message(context)
except ValueError:
await context.edit("出错了呜呜呜 ~ 无效的参数。")
return
async with bot.conversation('PagerMaid_Modify_bot') as conversation:
await conversation.send_message('/tts ' + message)
chat_response = await conversation.get_response()
await bot.send_read_acknowledge(conversation.chat_id)
if reply:
await context.respond(chat_response, reply_to=reply)
else:
await context.respond(chat_response)
await context.delete()