Skip to content

Commit

Permalink
Merge pull request #716 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
修复tts_ai_lab_top
  • Loading branch information
Ikaros-521 committed Mar 22, 2024
2 parents 7157fd0 + eba8421 commit 37eaef6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,8 @@
"sdp_ratio": "0.2",
"noise": "0.5",
"noisew": "0.9",
"length": "1.0"
"length": "1.0",
"lang": "zh"
},
"bark_gui": {
"api_ip_port": "http://127.0.0.1:7860",
Expand Down
3 changes: 2 additions & 1 deletion config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,8 @@
"sdp_ratio": "0.2",
"noise": "0.5",
"noisew": "0.9",
"length": "1.0"
"length": "1.0",
"lang": "zh"
},
"bark_gui": {
"api_ip_port": "http://127.0.0.1:7860",
Expand Down
6 changes: 3 additions & 3 deletions utils/audio_handle/my_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ async def tts_ai_lab_top_api(self, text):
params = {
"token": tts_ai_lab_top['token'],
"appid": tts_ai_lab_top['appid'],
'lang': "zh",
'lang': tts_ai_lab_top['lang'],
'speaker': tts_ai_lab_top['speaker'],
'text': text,
'sdp_ratio': float(tts_ai_lab_top['sdp_ratio']),
Expand All @@ -358,7 +358,7 @@ async def tts_ai_lab_top_api(self, text):

try:
async with aiohttp.ClientSession() as session:
async with session.post(url, json=params, timeout=self.timeout, ssl=self.ssl_context) as response:
async with session.post(url, json=params, timeout=self.timeout) as response:
ret = await response.json()
logging.debug(ret)

Expand All @@ -368,7 +368,7 @@ async def tts_ai_lab_top_api(self, text):
logging.error(f'tts.ai-lab.top合成失败,错误信息: {ret["message"]}')
return None

async with session.get(file_url, timeout=self.timeout, ssl=self.ssl_context) as response:
async with session.get(file_url, timeout=self.timeout) as response:
if response.status == 200:
content = await response.read()

Expand Down
2 changes: 1 addition & 1 deletion utils/my_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ def choose_song_handle(self, data):
# 拼接音频文件路径
resp_content = f"{My_handle.config.get('choose_song', 'song_path')}/{resp_content[0]}"
resp_content = os.path.abspath(resp_content)
logging.info(f"匹配到的音频路径:{resp_content}")
logging.info(f"点歌成功!匹配到的音频路径:{resp_content}")

message = {
"type": "song",
Expand Down
9 changes: 8 additions & 1 deletion webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,7 @@ def common_textarea_handle(content):
config_data["tts_ai_lab_top"]["noisew"] = input_tts_ai_lab_top_noisew.value
config_data["tts_ai_lab_top"]["length"] = input_tts_ai_lab_top_length.value
config_data["tts_ai_lab_top"]["sdp_ratio"] = input_tts_ai_lab_top_sdp_ratio.value
config_data["tts_ai_lab_top"]["lang"] = select_tts_ai_lab_top_lang.value

if config.get("webui", "show_card", "tts", "bark_gui"):
config_data["bark_gui"]["api_ip_port"] = input_bark_gui_api_ip_port.value
Expand Down Expand Up @@ -3169,8 +3170,10 @@ async def tts_common_audio_synthesis():
file_path = await audio.audio_synthesis_use_local_config(content, audio_synthesis_type)

if file_path:
logging.info(f"音频合成成功,存储于:{file_path}")
ui.notify(position="top", type="positive", message=f"音频合成成功,存储于:{file_path}")
else:
logging.error(f"音频合成失败!请查看日志排查问题")
ui.notify(position="top", type="negative", message=f"音频合成失败!请查看日志排查问题")
return

Expand Down Expand Up @@ -3367,7 +3370,11 @@ def clear_tts_common_audio_card(file_path):
input_tts_ai_lab_top_noisew = ui.input(label='音素长度', placeholder='控制音节发音长度变化程度,默认为0.9', value=config.get("tts_ai_lab_top", "noisew"))
input_tts_ai_lab_top_length = ui.input(label='语速', placeholder='可用于控制整体语速。默认为1.2', value=config.get("tts_ai_lab_top", "length"))
input_tts_ai_lab_top_sdp_ratio = ui.input(label='SDP/DP混合比', placeholder='SDP/DP混合比:SDP在合成时的占比,理论上此比率越高,合成的语音语调方差越大。', value=config.get("tts_ai_lab_top", "sdp_ratio"))

select_tts_ai_lab_top_lang = ui.select(
label='语言',
options={"zh": "中文"},
value=config.get("tts_ai_lab_top", "lang")
)
if config.get("webui", "show_card", "tts", "bark_gui"):
with ui.card().style(card_css):
ui.label("bark_gui")
Expand Down

0 comments on commit 37eaef6

Please sign in to comment.