lintonxue00
commited on
Commit
•
d64834a
1
Parent(s):
0b9bf74
Upload ext_voice.py
Browse files- ext_voice.py +2 -6
ext_voice.py
CHANGED
@@ -21,10 +21,6 @@ from aiohttp import request
|
|
21 |
from loguru import logger
|
22 |
from nonebot.exception import ActionFailed
|
23 |
import asyncio
|
24 |
-
import re
|
25 |
-
import requests
|
26 |
-
import base64
|
27 |
-
import uuid
|
28 |
|
29 |
try:
|
30 |
from ujson import loads as loadJsonS
|
@@ -143,7 +139,7 @@ class CustomExtension(Extension):
|
|
143 |
# ! moegoe.azurewebsites.net 是一个公开的语音合成api,非本人搭建,请勿滥用 (tip by KroMiose)
|
144 |
# 该api只支持日语,如果传入其它语言,会导致合成结果不可预知
|
145 |
# 如果你开启了翻译就没事了
|
146 |
-
url = f"https://
|
147 |
|
148 |
# todo: 如果需要使用本地的语音合成api,请取消注释下面的代码,并自行改为您的api地址,将填入合成文本的地方改为{text}
|
149 |
# url = f"http://127.0.0.1:23211/to_voice?text={text}"
|
@@ -152,7 +148,7 @@ class CustomExtension(Extension):
|
|
152 |
r = requests.get(url)
|
153 |
file_name = f"{voice_path}{uuid.uuid1()}.ogg"
|
154 |
if is_base64:
|
155 |
-
audio_data = base64.b64decode(r.content
|
156 |
else:
|
157 |
audio_data = r.content
|
158 |
|
|
|
21 |
from loguru import logger
|
22 |
from nonebot.exception import ActionFailed
|
23 |
import asyncio
|
|
|
|
|
|
|
|
|
24 |
|
25 |
try:
|
26 |
from ujson import loads as loadJsonS
|
|
|
139 |
# ! moegoe.azurewebsites.net 是一个公开的语音合成api,非本人搭建,请勿滥用 (tip by KroMiose)
|
140 |
# 该api只支持日语,如果传入其它语言,会导致合成结果不可预知
|
141 |
# 如果你开启了翻译就没事了
|
142 |
+
url = f"https://moegoe.azurewebsites.net/api/speak?text={text}&id=0"
|
143 |
|
144 |
# todo: 如果需要使用本地的语音合成api,请取消注释下面的代码,并自行改为您的api地址,将填入合成文本的地方改为{text}
|
145 |
# url = f"http://127.0.0.1:23211/to_voice?text={text}"
|
|
|
148 |
r = requests.get(url)
|
149 |
file_name = f"{voice_path}{uuid.uuid1()}.ogg"
|
150 |
if is_base64:
|
151 |
+
audio_data = base64.b64decode(r.content)
|
152 |
else:
|
153 |
audio_data = r.content
|
154 |
|