From 748302b12d4b0645189906c78dd1fddde0ed9026 Mon Sep 17 00:00:00 2001 From: fireinsect <847954981@qq.com> Date: Thu, 14 Dec 2023 12:15:10 +0800 Subject: [PATCH 1/4] =?UTF-8?q?perf:=20=E5=AF=B9msg=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E8=BF=9B=E4=B8=80=E6=AD=A5=E6=AD=A3=E5=88=99=EF=BC=8C=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E5=87=BA=E7=B1=BB=20shell=E6=8C=87=E4=BB=A4=EF=BC=8C?= =?UTF-8?q?=E9=80=9A=E8=BF=87=20-p=20=E6=9D=A5=E5=86=B3=E5=AE=9A=E6=8F=90?= =?UTF-8?q?=E9=86=92=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_moegoe/__init__.py | 9 +++++++-- nonebot_plugin_moegoe/profile.toml | 5 +++-- nonebot_plugin_moegoe/utils.py | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/nonebot_plugin_moegoe/__init__.py b/nonebot_plugin_moegoe/__init__.py index f03b464..19173e8 100644 --- a/nonebot_plugin_moegoe/__init__.py +++ b/nonebot_plugin_moegoe/__init__.py @@ -154,6 +154,7 @@ def getApiConfigs(api_name): ("emotion", "emotion", -1), ("sdp_ratio", "sdp_ratio", 0.5), ("audio_component", "audio_component", ''), + ("text_prompt", "text_prompt", 'Happy'), ): config[k] = d for name in (api_name, "api"): @@ -224,7 +225,7 @@ async def cn_func( gradioParas = list() for k in _profileDict["gradio_paralist"]: gradioParas.append(paras[k]) - stat, wav_path = gradioClients.forward(_profileDict["url"], *gradioParas, msg, "Text prompt", fn_index=0) + stat, wav_path = gradioClients.forward(_profileDict["url"], *gradioParas, "Text prompt", fn_index=0) if stat == 'Success': message = MessageSegment.record(Path(wav_path)) else: @@ -294,6 +295,10 @@ async def _(matcher: Matcher, matched: Tuple[Any, ...] = RegexGroup()): assert len(matched) >= 6 nation, name, _, para, lang, msg = matched[0:6] para_dict = para_process(para) + match = re.search(r"(-p|--prompt) (.+)", msg) + if match: + para_dict['text_prompt'] = match.groups(1) + msg = msg.replace(match.group(), "") para_dict['nation'] = nationDict[nation] para_dict['lang'] = langDict[lang] for en, cn in profileDict["cnapi"]["replace"]: @@ -313,4 +318,4 @@ async def _(matcher: Matcher, matched: Tuple[Any, ...] = RegexGroup()): try: await matcher.finish(record) except ActionFailed as e: - await matcher.finish("moegoe语音发送失败:" + str(e)) + await matcher.finish("moegoe语音发送失败:" + str(e)) \ No newline at end of file diff --git a/nonebot_plugin_moegoe/profile.toml b/nonebot_plugin_moegoe/profile.toml index 4449a93..f8f55fb 100644 --- a/nonebot_plugin_moegoe/profile.toml +++ b/nonebot_plugin_moegoe/profile.toml @@ -50,7 +50,7 @@ regex = "^让(Sua|Mimiru|Arin|Yeonhwa|Yuhwa|Seonbae)(以(.+))?说(?:韩语|韩 [cnapi] priority = 6 is_gradio = true -gradio_paralist = ["msg", 'name', 'sdp_ratio', 'noise', 'noisew', 'length', 'lang', 'audio_component'] +gradio_paralist = ["msg", 'name', 'sdp_ratio', 'noise', 'noisew', 'length', 'lang', 'audio_component', 'text_prompt'] url = "https://v2.genshinvoice.top/" # url = "https://genshin.azurewebsites.net/api/speak?format=mp3&text=${text}&id=${id}&length=${length}&noise=${noise}&noisew=${noisew}" # 需要apikey voice_format = "mp3" @@ -60,9 +60,10 @@ length = 1 # 整体语速 float (0.1 - 2) noise = 0.4 # 感情:控制感情变化和稳定程度 float (0.1 - 2) noisew = 0.8 # 音素长度:控制音节发音长度变化程度 float (0.1 - 2) audio_component = "https://mirror.ghproxy.com/https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav" # 情感参考音频(WAV 格式) str +text_prompt = "Happy" order = ["派蒙"] regex = "^让(中配|英配|日配)?([^0-9.]+)(以(.+))?说(国语|汉语|汉文|中文|Chinese|英语|英文|English|日语|日文|日本语|Japanese)?(?:[:|:]*)(.+)$" replace = [[',', ','], ['.', '。'], ['!', '!'], ['?', '?'], ['0', '零'], ['1', '一'], ['2', '二'], ['3', '三'], ['4', '四'], ['5', '五'], ['6', '六'], ['7', '七'], ['8', '八'], ['9', '九'], ] nation = {'中配'='ZH','英配'='EN','日配'='JP'} lang = {'国语'='ZH','汉语'='ZH','汉文'='ZH','中文'='ZH','Chinese'='ZH','英语'='EN','英文'='EN','English'='EN','日语'='JP','日文'='JP','日本语'='JP','Japanese'='JP'} -character_list = '请到API界面查看:https://v2.genshinvoice.top/' +character_list = '请到API界面查看:https://v2.genshinvoice.top/' \ No newline at end of file diff --git a/nonebot_plugin_moegoe/utils.py b/nonebot_plugin_moegoe/utils.py index ea5c2cb..252836e 100644 --- a/nonebot_plugin_moegoe/utils.py +++ b/nonebot_plugin_moegoe/utils.py @@ -36,4 +36,4 @@ def write_file(path: Path, data, binary=True): if binary: path.write_bytes(data) else: - path.write_text(data, encoding='UTF-8') + path.write_text(data, encoding='UTF-8') \ No newline at end of file From 51bcd1afc2140e3e86ff2586462916d9bc51df2b Mon Sep 17 00:00:00 2001 From: fireinsect <847954981@qq.com> Date: Thu, 14 Dec 2023 12:19:09 +0800 Subject: [PATCH 2/4] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E4=B8=8D=E5=AD=98=E5=9C=A8=20-p=20=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=E5=88=99=E6=8A=8Amsg=E4=BD=9C=E4=B8=BA=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_moegoe/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nonebot_plugin_moegoe/__init__.py b/nonebot_plugin_moegoe/__init__.py index 19173e8..7aa40b9 100644 --- a/nonebot_plugin_moegoe/__init__.py +++ b/nonebot_plugin_moegoe/__init__.py @@ -295,10 +295,14 @@ async def _(matcher: Matcher, matched: Tuple[Any, ...] = RegexGroup()): assert len(matched) >= 6 nation, name, _, para, lang, msg = matched[0:6] para_dict = para_process(para) + # 通过正则把 -p 从msg中提取出来,并进行判断 match = re.search(r"(-p|--prompt) (.+)", msg) if match: para_dict['text_prompt'] = match.groups(1) msg = msg.replace(match.group(), "") + # 并没有 -p 则把msg当作提示词 + else: + para_dict['text_prompt'] = msg para_dict['nation'] = nationDict[nation] para_dict['lang'] = langDict[lang] for en, cn in profileDict["cnapi"]["replace"]: From bf18f52a212665223f4b35608f7c174478309d54 Mon Sep 17 00:00:00 2001 From: yiyuiii Date: Sat, 16 Dec 2023 16:00:39 +0800 Subject: [PATCH 3/4] 0.10.4 --- README.md | 3 ++- nonebot_plugin_moegoe/profile.toml | 2 +- pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2fb9c09..7fc3a38 100644 --- a/README.md +++ b/README.md @@ -136,8 +136,9 @@ https://github.com/fumiama/MoeGoe/tree/genshin ## :clipboard: 更新日志 -#### 2023.12.12 > v0.10.3 :fire: +#### 2023.12.12 > v0.10.4 :fire: +- 跟随genshinvoice.top更新cnapi以及相关处理流程。 - Fix: 优化了api优先级机制和gradio接口处理机制。 #### 2023.12.11 > v0.10.1 diff --git a/nonebot_plugin_moegoe/profile.toml b/nonebot_plugin_moegoe/profile.toml index f8f55fb..8e6be69 100644 --- a/nonebot_plugin_moegoe/profile.toml +++ b/nonebot_plugin_moegoe/profile.toml @@ -1,4 +1,4 @@ -version = "0.10.3" +version = "0.10.4" priority = 5 [plugin_meta] diff --git a/pyproject.toml b/pyproject.toml index 320ca3a..ecfe807 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nonebot-plugin-moegoe" -version = "0.10.3" +version = "0.10.4" description = "VITS AI合成原神角色语音" license = "MIT" authors = ["yiyuiii "] From 2b4c4e8881895342b2b205cbb197cce378e75ae6 Mon Sep 17 00:00:00 2001 From: yiyuiii Date: Sat, 16 Dec 2023 16:01:23 +0800 Subject: [PATCH 4/4] 0.10.4 --- nonebot_plugin_moegoe/__init__.py | 2 +- nonebot_plugin_moegoe/profile.toml | 2 +- nonebot_plugin_moegoe/utils.py | 2 +- pyproject.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nonebot_plugin_moegoe/__init__.py b/nonebot_plugin_moegoe/__init__.py index 7aa40b9..5a976c8 100644 --- a/nonebot_plugin_moegoe/__init__.py +++ b/nonebot_plugin_moegoe/__init__.py @@ -322,4 +322,4 @@ async def _(matcher: Matcher, matched: Tuple[Any, ...] = RegexGroup()): try: await matcher.finish(record) except ActionFailed as e: - await matcher.finish("moegoe语音发送失败:" + str(e)) \ No newline at end of file + await matcher.finish("moegoe语音发送失败:" + str(e)) diff --git a/nonebot_plugin_moegoe/profile.toml b/nonebot_plugin_moegoe/profile.toml index 8e6be69..64312fc 100644 --- a/nonebot_plugin_moegoe/profile.toml +++ b/nonebot_plugin_moegoe/profile.toml @@ -66,4 +66,4 @@ regex = "^让(中配|英配|日配)?([^0-9.]+)(以(.+))?说(国语|汉语|汉文 replace = [[',', ','], ['.', '。'], ['!', '!'], ['?', '?'], ['0', '零'], ['1', '一'], ['2', '二'], ['3', '三'], ['4', '四'], ['5', '五'], ['6', '六'], ['7', '七'], ['8', '八'], ['9', '九'], ] nation = {'中配'='ZH','英配'='EN','日配'='JP'} lang = {'国语'='ZH','汉语'='ZH','汉文'='ZH','中文'='ZH','Chinese'='ZH','英语'='EN','英文'='EN','English'='EN','日语'='JP','日文'='JP','日本语'='JP','Japanese'='JP'} -character_list = '请到API界面查看:https://v2.genshinvoice.top/' \ No newline at end of file +character_list = '请到API界面查看:https://v2.genshinvoice.top/' diff --git a/nonebot_plugin_moegoe/utils.py b/nonebot_plugin_moegoe/utils.py index 252836e..ea5c2cb 100644 --- a/nonebot_plugin_moegoe/utils.py +++ b/nonebot_plugin_moegoe/utils.py @@ -36,4 +36,4 @@ def write_file(path: Path, data, binary=True): if binary: path.write_bytes(data) else: - path.write_text(data, encoding='UTF-8') \ No newline at end of file + path.write_text(data, encoding='UTF-8') diff --git a/pyproject.toml b/pyproject.toml index ecfe807..675e55f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,4 +24,4 @@ gradio_client = "^0.7.0" [build-system] requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" \ No newline at end of file +build-backend = "poetry.core.masonry.api"