From 1037d4bd24296653d33dc85dfa59b052adc3ae9b Mon Sep 17 00:00:00 2001 From: ikaros <327209194@qq.com> Date: Tue, 26 Mar 2024 09:47:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A9=E6=92=AD=20=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2=E4=B8=BA=E4=B8=AD=E6=96=87?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B9=E4=BE=BF=E7=94=A8=E6=88=B7=E7=90=86?= =?UTF-8?q?=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/common.py | 5 +++++ webui.py | 35 +++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/utils/common.py b/utils/common.py index dcbf97d4..efef502f 100644 --- a/utils/common.py +++ b/utils/common.py @@ -133,6 +133,11 @@ def get_random_value(self, lower_limit, upper_limit): return random_float + def find_keys_by_value(self, dictionary, target_value): + # 返回一个包含所有具有指定值的键的列表 + return [key for key, value in dictionary.items() if value == target_value] + + """ .,]` ]]]` ,]]` .` .]` diff --git a/webui.py b/webui.py index 4fca783d..0b432b7d 100644 --- a/webui.py +++ b/webui.py @@ -1913,7 +1913,7 @@ def common_textarea_handle(content): tmp_arr = [] for index in range(len(assistant_anchor_type_var)): if assistant_anchor_type_var[str(index)].value: - tmp_arr.append(assistant_anchor_type_var[str(index)].text) + tmp_arr.append(common.find_keys_by_value(assistant_anchor_type_mapping, assistant_anchor_type_var[str(index)].text)[0]) # logging.info(tmp_arr) config_data["assistant_anchor"]["type"] = tmp_arr config_data["assistant_anchor"]["local_qa"]["text"]["enable"] = switch_assistant_anchor_local_qa_text_enable.value @@ -2228,10 +2228,10 @@ def common_textarea_handle(content): with ui.card().style(card_css): ui.label('开放平台') with ui.row(): - input_bilibili_open_live_ACCESS_KEY_ID = ui.input(label='ACCESS_KEY_ID', value=config.get("bilibili", "open_live", "ACCESS_KEY_ID"), placeholder='开放平台ACCESS_KEY_ID').style("width:300px;") - input_bilibili_open_live_ACCESS_KEY_SECRET = ui.input(label='ACCESS_KEY_SECRET', value=config.get("bilibili", "open_live", "ACCESS_KEY_SECRET"), placeholder='开放平台ACCESS_KEY_SECRET').style("width:300px;") - input_bilibili_open_live_APP_ID = ui.input(label='项目ID', value=config.get("bilibili", "open_live", "APP_ID"), placeholder='开放平台 创作者服务中心 项目ID').style("width:200px;") - input_bilibili_open_live_ROOM_OWNER_AUTH_CODE = ui.input(label='身份码', value=config.get("bilibili", "open_live", "ROOM_OWNER_AUTH_CODE"), placeholder='直播中心用户 身份码').style("width:200px;") + input_bilibili_open_live_ACCESS_KEY_ID = ui.input(label='ACCESS_KEY_ID', value=config.get("bilibili", "open_live", "ACCESS_KEY_ID"), placeholder='开放平台ACCESS_KEY_ID').style("width:160px;") + input_bilibili_open_live_ACCESS_KEY_SECRET = ui.input(label='ACCESS_KEY_SECRET', value=config.get("bilibili", "open_live", "ACCESS_KEY_SECRET"), placeholder='开放平台ACCESS_KEY_SECRET').style("width:200px;") + input_bilibili_open_live_APP_ID = ui.input(label='项目ID', value=config.get("bilibili", "open_live", "APP_ID"), placeholder='开放平台 创作者服务中心 项目ID').style("width:100px;") + input_bilibili_open_live_ROOM_OWNER_AUTH_CODE = ui.input(label='身份码', value=config.get("bilibili", "open_live", "ROOM_OWNER_AUTH_CODE"), placeholder='直播中心用户 身份码').style("width:100px;") with ui.card().style(card_css): ui.label('twitch') with ui.row(): @@ -4010,14 +4010,14 @@ def vits_get_speaker_id(): value=config.get("talk", "trigger_key"), with_input=True, clearable=True - ).style("width:100px;") + ).style("width:200px;") select_talk_stop_trigger_key = ui.select( label='停录按键', options=data_json, value=config.get("talk", "stop_trigger_key"), with_input=True, clearable=True - ).style("width:100px;") + ).style("width:200px;") input_talk_volume_threshold = ui.input(label='音量阈值', value=config.get("talk", "volume_threshold"), placeholder='音量阈值,指的是触发录音的起始音量值,请根据自己的麦克风进行微调到最佳').style("width:100px;") input_talk_silence_threshold = ui.input(label='沉默阈值', value=config.get("talk", "silence_threshold"), placeholder='沉默阈值,指的是触发停止路径的最低音量值,请根据自己的麦克风进行微调到最佳').style("width:100px;") @@ -4379,14 +4379,29 @@ async def image_recognition_cam_screenshot_and_send(sleep_time: float): with ui.row(): # 类型列表源自audio_synthesis_handle 音频合成的所支持的type值 assistant_anchor_type_list = ["comment", "local_qa_audio", "song", "reread", "direct_reply", "read_comment", "gift", - "entrance", "follow", "idle_time_task"] + "entrance", "follow", "idle_time_task", "reread_top_priority", "schedule", "image_recognition_schedule"] + assistant_anchor_type_mapping = { + "comment": "弹幕", + "local_qa_audio": "本地问答-音频", + "song": "点歌", + "reread": "复读", + "direct_reply": "直接合成回复", + "read_comment": "念弹幕", + "gift": "礼物", + "entrance": "入场", + "follow": "关注", + "idle_time_task": "闲时任务", + "reread_top_priority": "最高优先级-复读", + "schedule": "定时任务", + "image_recognition_schedule": "图像识别定时任务" + } assistant_anchor_type_var = {} for index, assistant_anchor_type in enumerate(assistant_anchor_type_list): if assistant_anchor_type in config.get("assistant_anchor", "type"): - assistant_anchor_type_var[str(index)] = ui.checkbox(text=assistant_anchor_type, value=True) + assistant_anchor_type_var[str(index)] = ui.checkbox(text=assistant_anchor_type_mapping[assistant_anchor_type], value=True) else: - assistant_anchor_type_var[str(index)] = ui.checkbox(text=assistant_anchor_type, value=False) + assistant_anchor_type_var[str(index)] = ui.checkbox(text=assistant_anchor_type_mapping[assistant_anchor_type], value=False) with ui.grid(columns=4): switch_assistant_anchor_local_qa_text_enable = ui.switch('启用文本匹配', value=config.get("assistant_anchor", "local_qa", "text", "enable")).style(switch_internal_css) select_assistant_anchor_local_qa_text_format = ui.select(