From eba8421d08eee0b2d1fbe22a7ab48881ecceab05 Mon Sep 17 00:00:00 2001 From: ikaros <327209194@qq.com> Date: Fri, 22 Mar 2024 10:48:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtts=5Fai=5Flab=5Ftop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.json | 3 ++- config.json.bak | 3 ++- utils/audio_handle/my_tts.py | 6 +++--- utils/my_handle.py | 2 +- webui.py | 9 ++++++++- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/config.json b/config.json index c3210f64..456f6b42 100644 --- a/config.json +++ b/config.json @@ -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", diff --git a/config.json.bak b/config.json.bak index c3210f64..456f6b42 100644 --- a/config.json.bak +++ b/config.json.bak @@ -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", diff --git a/utils/audio_handle/my_tts.py b/utils/audio_handle/my_tts.py index 9c17c472..56ac5e05 100644 --- a/utils/audio_handle/my_tts.py +++ b/utils/audio_handle/my_tts.py @@ -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']), @@ -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) @@ -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() diff --git a/utils/my_handle.py b/utils/my_handle.py index b827af0a..56f23d25 100644 --- a/utils/my_handle.py +++ b/utils/my_handle.py @@ -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", diff --git a/webui.py b/webui.py index 1a1bc8aa..1a1d204c 100644 --- a/webui.py +++ b/webui.py @@ -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 @@ -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 @@ -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")