Skip to content

Commit

Permalink
Merge pull request #608 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
Live2D移到虚拟身体,新增模型名配置,可以自动检索模型名,进行模型加载
  • Loading branch information
Ikaros-521 authored Jan 31, 2024
2 parents d132be2 + 838c016 commit 806ac33
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@
},
"live2d": {
"enable": false,
"port": 12345
"port": 12345,
"name": "Hiyori"
},
"openai": {
"api": "https://api.openai.com/v1",
Expand Down
3 changes: 2 additions & 1 deletion config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@
},
"live2d": {
"enable": false,
"port": 12345
"port": 12345,
"name": "Hiyori"
},
"openai": {
"api": "https://api.openai.com/v1",
Expand Down
26 changes: 18 additions & 8 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,11 @@ def common_textarea_handle(content):
if config.get("webui", "show_card", "visual_body", "live2d"):
config_data["live2d"]["enable"] = switch_live2d_enable.value
config_data["live2d"]["port"] = int(input_live2d_port.value)
# config_data["live2d"]["name"] = input_live2d_name.value
config_data["live2d"]["name"] = select_live2d_name.value
tmp_str = f"var model_name = \"{select_live2d_name.value}\";"
# 路径写死了,注意
common.write_content_to_file("Live2D/js/model_name.js", tmp_str)


if config.get("webui", "show_card", "visual_body", "xuniren"):
config_data["xuniren"]["api_ip_port"] = input_xuniren_api_ip_port.value
Expand Down Expand Up @@ -1813,12 +1817,6 @@ def common_textarea_handle(content):
switch_audio_random_speed_copywriting_enable = ui.switch('文案音频变速', value=config.get("audio_random_speed", "copywriting", "enable")).style(switch_internal_css)
input_audio_random_speed_copywriting_speed_min = ui.input(label='速度下限', value=config.get("audio_random_speed", "copywriting", "speed_min")).style("width:200px;")
input_audio_random_speed_copywriting_speed_max = ui.input(label='速度上限', value=config.get("audio_random_speed", "copywriting", "speed_max")).style("width:200px;")
if config.get("webui", "show_card", "common_config", "live2d"):
with ui.card().style(card_css):
ui.label('Live2D')
with ui.grid(columns=2):
switch_live2d_enable = ui.switch('启用', value=config.get("live2d", "enable")).style(switch_internal_css)
input_live2d_port = ui.input(label='端口', value=config.get("live2d", "port")).style("width:200px;")

if config.get("webui", "show_card", "common_config", "choose_song"):
with ui.card().style(card_css):
Expand Down Expand Up @@ -2861,7 +2859,19 @@ def common_textarea_handle(content):
switch_live2d_enable = ui.switch('启用', value=config.get("live2d", "enable")).style(switch_internal_css)
input_live2d_port = ui.input(label='端口', value=config.get("live2d", "port"), placeholder='web服务运行的端口号,默认:12345,范围:0-65535,没事不要乱改就好')
# input_live2d_name = ui.input(label='模型名', value=config.get("live2d", "name"), placeholder='模型名称,模型存放于Live2D\live2d-model路径下,请注意路径和模型内容是否匹配')


live2d_names = common.get_folder_names("Live2D/live2d-model") # 路径写死
logging.info(f"本地Live2D模型名列表:{live2d_names}")

data_json = {}
for line in live2d_names:
data_json[line] = line
# live2d_model_name = common.get_live2d_model_name("Live2D/js/model_name.js") # 路径写死
select_live2d_name = ui.select(
label='模型名',
options=data_json,
value=config.get("live2d", "name")
).style("width:150px")
if config.get("webui", "show_card", "visual_body", "xuniren"):
with ui.card().style(card_css):
ui.label("xuniren")
Expand Down

0 comments on commit 806ac33

Please sign in to comment.