Skip to content

Commit

Permalink
新增 音频播放板块,暂时只提供音频播放的开关。
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed Aug 19, 2023
1 parent a87eeb2 commit 1f738e9
Show file tree
Hide file tree
Showing 7 changed files with 1,143 additions and 1,057 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,9 @@ cmd运行`npm i docsify-cli -g`
- 修复部分GUI显示bug
- 恢复Claude2的兼容

- 2023-08-19
- 新增 音频播放板块,暂时只提供音频播放的开关。

</details>


Expand Down
901 changes: 455 additions & 446 deletions UI_main.py

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"before_prompt": "请简要回复:",
"after_prompt": "",
"comment_log_type": "回答",
"play_audio": {
"enable": true
},
"show_box": {
"read_user_name": true,
"filter": true,
Expand All @@ -19,7 +22,8 @@
"sd": true,
"log": true,
"schedule": true,
"database": true
"database": true,
"play_audio": true
},
"read_user_name": {
"enable": true,
Expand Down
6 changes: 5 additions & 1 deletion config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"before_prompt": "请简要回复:",
"after_prompt": "",
"comment_log_type": "回答",
"play_audio": {
"enable": false
},
"show_box": {
"read_user_name": true,
"filter": true,
Expand All @@ -19,7 +22,8 @@
"sd": true,
"log": true,
"schedule": true,
"database": true
"database": true,
"play_audio": true
},
"read_user_name": {
"enable": true,
Expand Down
50 changes: 48 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,8 @@ def init_config(self):

# 自定义显隐各板块
def get_box_name_by_key(key):
# 定义键和值的映射关系
# 定义键和值的映射关系,请和配置文件中的键保持一致
# 添加时需要同步给配置文件中的show_box配置项追加你添加的键名
key_value_map = {
"read_user_name": "念用户名",
"filter": "过滤",
Expand All @@ -1167,7 +1168,8 @@ def get_box_name_by_key(key):
"sd": "Stable Diffusion",
"log": "日志",
"schedule": "定时任务",
"database": "数据库"
"database": "数据库",
"play_audio": "播放音频"
# 可以继续添加其他键和值
}

Expand Down Expand Up @@ -1463,6 +1465,34 @@ def database_gui_create():

database_gui_create()

# 播放音频
def play_audio_gui_create():
data_json = []

play_audio_config = config.get("play_audio")
tmp_json = {
"label_text": "启用",
"label_tip": "是否开启音频播放,如果不启用,则会只合成音频文件,不会进行播放操作",
"data": play_audio_config["enable"],
"widget_text": "",
"click_func": "",
"main_obj_name": "play_audio",
"index": 0
}
data_json.append(tmp_json)

widgets = self.create_widgets_from_json(data_json)

# 动态添加widget到对应的gridLayout
row = 0
# 分2列,左边就是label说明,右边就是输入框等
for i in range(0, len(widgets), 2):
self.ui.gridLayout_play_audio.addWidget(widgets[i], row, 0)
self.ui.gridLayout_play_audio.addWidget(widgets[i + 1], row, 1)
row += 1

play_audio_gui_create()

# 显隐各板块
self.oncomboBox_chat_type_IndexChanged(chat_type_index)
self.oncomboBox_audio_synthesis_type_IndexChanged(audio_synthesis_type_index)
Expand Down Expand Up @@ -2094,6 +2124,22 @@ def reorganize_database_data(database_data):
# 写回json
config_data["database"] = reorganize_database_data(database_data)

# 音频播放
def reorganize_play_audio_data(play_audio_data):
keys = list(play_audio_data.keys())

tmp_json = {
"enable": play_audio_data[keys[0]]
}

logging.debug(f"tmp_json={tmp_json}")

return tmp_json

play_audio_data = self.update_data_from_gridLayout(self.ui.gridLayout_play_audio)
# 写回json
config_data["play_audio"] = reorganize_play_audio_data(play_audio_data)

# 获取自定义板块显隐的数据
show_box_data = self.update_data_from_gridLayout(self.ui.gridLayout_show_box, "show_box")
show_box_json = {}
Expand Down
Loading

0 comments on commit 1f738e9

Please sign in to comment.