Skip to content

Commit

Permalink
Merge pull request #758 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
完善fish-speech功能
  • Loading branch information
Ikaros-521 committed Apr 14, 2024
2 parents df61d24 + 6be88e4 commit 60515f7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion utils/audio_handle/my_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
34 changes: 34 additions & 0 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 60515f7

Please sign in to comment.