diff --git a/utils/audio_handle/my_tts.py b/utils/audio_handle/my_tts.py index 6bd9555e..5c60f79a 100644 --- a/utils/audio_handle/my_tts.py +++ b/utils/audio_handle/my_tts.py @@ -925,7 +925,7 @@ def replace_empty_strings_with_none(input_dict): try: async with aiohttp.ClientSession() as session: - async with session.post(API_URL, json=data["tts_config"]) as response: + async with session.post(API_URL, json=data["tts_config"], timeout=self.timeout) as response: if response.status == 200: content = await response.read() diff --git a/webui.py b/webui.py index 41fc9239..9075bdd7 100644 --- a/webui.py +++ b/webui.py @@ -4357,7 +4357,41 @@ def vits_get_speaker_id(): } ).style("width:200px;") input_fish_speech_model_name = ui.input(label='模型名', value=config.get("fish_speech", "model_name"), placeholder='需要加载的模型名').style("width:200px;") + + async def fish_speech_load_model(data): + import aiohttp + + ui.notify(position="top", type="info", message=f'fish_speech 准备加载模型:{data["model_name"]}') + + API_URL = urljoin(data["api_ip_port"], f'/v1/models/{data["model_name"]}') + + try: + async with aiohttp.ClientSession() as session: + async with session.put(API_URL, json=data["model_config"]) as response: + if response.status == 200: + ret = await response.json() + logging.debug(ret) + + if ret["name"] == data["model_name"]: + logging.info(f'fish_speech模型加载成功: {ret["name"]}') + ui.notify(position="top", type="positive", message=f'fish_speech模型加载成功: {ret["name"]}') + return ret + else: + logging.error(f'fish_speech模型加载失败') + ui.notify(position="top", type="negative", message=f'fish_speech模型加载失败') + return None + + except aiohttp.ClientError as e: + logging.error(f'fish_speech请求失败: {e}') + ui.notify(position="top", type="negative", message=f'fish_speech请求失败: {e}') + except Exception as e: + logging.error(f'fish_speech未知错误: {e}') + ui.notify(position="top", type="negative", message=f'fish_speech未知错误: {e}') + + return None + button_fish_speech_load_model = ui.button('加载模型', on_click=lambda: fish_speech_load_model(config.get("fish_speech")), color=button_internal_color).style(button_internal_css) + with ui.card().style(card_css): ui.label("模型配置") with ui.row():