diff --git a/README.md b/README.md
index eae5e91b..9cc281b1 100644
--- a/README.md
+++ b/README.md
@@ -1144,6 +1144,10 @@ cmd输入命令即可:`doctoc /path/to/file`
- 文案模式增加了一组文案配置,也就是说有2块文案,会进行左右切换的播放,都播放完毕后会进行新的一轮播放。
- 新增LLM后的第二重过滤(违禁词、链接、拼音)
- 违禁拼音配置内容需要是中文,需要注意,已更正
+- 新增 念用户名的功能,例:回复xxx。你好
+- 新增用户名过滤(违禁词、链接、拼音)
+- 修复本地问答音频匹配,传入音频后缀导致的匹配错误bug
+- 新增本地问答库匹配 最低相似度配置,用于微调需要的关键词匹配度,已自定义触发灵敏度。
diff --git a/UI_main.py b/UI_main.py
index 2893f398..bd804ae3 100644
--- a/UI_main.py
+++ b/UI_main.py
@@ -86,7 +86,7 @@ def setupUi(self, MainWindow):
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
- self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 980, 6386))
+ self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -501, 980, 6470))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
self.verticalLayout.setContentsMargins(35, 20, 35, 20)
@@ -97,6 +97,78 @@ def setupUi(self, MainWindow):
self.gridLayout = QtWidgets.QGridLayout(self.formWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
+ self.comboBox_platform = QtWidgets.QComboBox(self.formWidget)
+ self.comboBox_platform.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
+ self.comboBox_platform.setObjectName("comboBox_platform")
+ self.comboBox_platform.addItem("")
+ self.comboBox_platform.addItem("")
+ self.comboBox_platform.addItem("")
+ self.comboBox_platform.addItem("")
+ self.gridLayout.addWidget(self.comboBox_platform, 0, 1, 1, 1)
+ self.groupBox = QtWidgets.QGroupBox(self.formWidget)
+ self.groupBox.setStyleSheet("")
+ self.groupBox.setObjectName("groupBox")
+ self.gridLayout_26 = QtWidgets.QGridLayout(self.groupBox)
+ self.gridLayout_26.setObjectName("gridLayout_26")
+ self.gridLayout_25 = QtWidgets.QGridLayout()
+ self.gridLayout_25.setObjectName("gridLayout_25")
+ self.textEdit_filter_before_must_str = QtWidgets.QTextEdit(self.groupBox)
+ self.textEdit_filter_before_must_str.setObjectName("textEdit_filter_before_must_str")
+ self.gridLayout_25.addWidget(self.textEdit_filter_before_must_str, 0, 1, 1, 1)
+ self.label_filter_badwords_path = QtWidgets.QLabel(self.groupBox)
+ self.label_filter_badwords_path.setObjectName("label_filter_badwords_path")
+ self.gridLayout_25.addWidget(self.label_filter_badwords_path, 2, 0, 1, 1)
+ self.lineEdit_filter_bad_pinyin_path = QtWidgets.QLineEdit(self.groupBox)
+ self.lineEdit_filter_bad_pinyin_path.setObjectName("lineEdit_filter_bad_pinyin_path")
+ self.gridLayout_25.addWidget(self.lineEdit_filter_bad_pinyin_path, 3, 1, 1, 1)
+ self.lineEdit_filter_max_len = QtWidgets.QLineEdit(self.groupBox)
+ self.lineEdit_filter_max_len.setObjectName("lineEdit_filter_max_len")
+ self.gridLayout_25.addWidget(self.lineEdit_filter_max_len, 4, 1, 1, 1)
+ self.label_filter_max_char_len = QtWidgets.QLabel(self.groupBox)
+ self.label_filter_max_char_len.setObjectName("label_filter_max_char_len")
+ self.gridLayout_25.addWidget(self.label_filter_max_char_len, 5, 0, 1, 1)
+ self.label_filter_after_must_str = QtWidgets.QLabel(self.groupBox)
+ self.label_filter_after_must_str.setObjectName("label_filter_after_must_str")
+ self.gridLayout_25.addWidget(self.label_filter_after_must_str, 1, 0, 1, 1)
+ self.textEdit_filter_after_must_str = QtWidgets.QTextEdit(self.groupBox)
+ self.textEdit_filter_after_must_str.setObjectName("textEdit_filter_after_must_str")
+ self.gridLayout_25.addWidget(self.textEdit_filter_after_must_str, 1, 1, 1, 1)
+ self.label_filter_max_len = QtWidgets.QLabel(self.groupBox)
+ self.label_filter_max_len.setObjectName("label_filter_max_len")
+ self.gridLayout_25.addWidget(self.label_filter_max_len, 4, 0, 1, 1)
+ self.label_filter_before_must_str = QtWidgets.QLabel(self.groupBox)
+ self.label_filter_before_must_str.setObjectName("label_filter_before_must_str")
+ self.gridLayout_25.addWidget(self.label_filter_before_must_str, 0, 0, 1, 1)
+ self.lineEdit_filter_max_char_len = QtWidgets.QLineEdit(self.groupBox)
+ self.lineEdit_filter_max_char_len.setObjectName("lineEdit_filter_max_char_len")
+ self.gridLayout_25.addWidget(self.lineEdit_filter_max_char_len, 5, 1, 1, 1)
+ self.lineEdit_filter_badwords_path = QtWidgets.QLineEdit(self.groupBox)
+ self.lineEdit_filter_badwords_path.setObjectName("lineEdit_filter_badwords_path")
+ self.gridLayout_25.addWidget(self.lineEdit_filter_badwords_path, 2, 1, 1, 1)
+ self.label_filter_bad_pinyin_path = QtWidgets.QLabel(self.groupBox)
+ self.label_filter_bad_pinyin_path.setObjectName("label_filter_bad_pinyin_path")
+ self.gridLayout_25.addWidget(self.label_filter_bad_pinyin_path, 3, 0, 1, 1)
+ self.gridLayout_26.addLayout(self.gridLayout_25, 0, 0, 1, 1)
+ self.gridLayout.addWidget(self.groupBox, 14, 0, 1, 3)
+ self.comboBox_chat_type = QtWidgets.QComboBox(self.formWidget)
+ self.comboBox_chat_type.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
+ self.comboBox_chat_type.setObjectName("comboBox_chat_type")
+ self.comboBox_chat_type.addItem("")
+ self.comboBox_chat_type.addItem("")
+ self.comboBox_chat_type.addItem("")
+ self.comboBox_chat_type.addItem("")
+ self.comboBox_chat_type.addItem("")
+ self.comboBox_chat_type.addItem("")
+ self.comboBox_chat_type.addItem("")
+ self.gridLayout.addWidget(self.comboBox_chat_type, 2, 1, 1, 1)
+ self.comboBox_need_lang = QtWidgets.QComboBox(self.formWidget)
+ self.comboBox_need_lang.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
+ self.comboBox_need_lang.setObjectName("comboBox_need_lang")
+ self.comboBox_need_lang.addItem("")
+ self.comboBox_need_lang.addItem("")
+ self.comboBox_need_lang.addItem("")
+ self.comboBox_need_lang.addItem("")
+ self.gridLayout.addWidget(self.comboBox_need_lang, 3, 1, 1, 1)
self.groupBox_thanks = QtWidgets.QGroupBox(self.formWidget)
self.groupBox_thanks.setObjectName("groupBox_thanks")
self.gridLayout_42 = QtWidgets.QGridLayout(self.groupBox_thanks)
@@ -131,91 +203,7 @@ def setupUi(self, MainWindow):
self.checkBox_thanks_gift_enable = QtWidgets.QCheckBox(self.groupBox_thanks)
self.checkBox_thanks_gift_enable.setObjectName("checkBox_thanks_gift_enable")
self.gridLayout_42.addWidget(self.checkBox_thanks_gift_enable, 1, 1, 1, 1)
- self.gridLayout.addWidget(self.groupBox_thanks, 15, 0, 1, 3)
- self.comboBox_need_lang = QtWidgets.QComboBox(self.formWidget)
- self.comboBox_need_lang.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
- self.comboBox_need_lang.setObjectName("comboBox_need_lang")
- self.comboBox_need_lang.addItem("")
- self.comboBox_need_lang.addItem("")
- self.comboBox_need_lang.addItem("")
- self.comboBox_need_lang.addItem("")
- self.gridLayout.addWidget(self.comboBox_need_lang, 3, 1, 1, 1)
- self.label_chat_type = QtWidgets.QLabel(self.formWidget)
- self.label_chat_type.setObjectName("label_chat_type")
- self.gridLayout.addWidget(self.label_chat_type, 2, 0, 1, 1)
- self.comboBox_platform = QtWidgets.QComboBox(self.formWidget)
- self.comboBox_platform.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
- self.comboBox_platform.setObjectName("comboBox_platform")
- self.comboBox_platform.addItem("")
- self.comboBox_platform.addItem("")
- self.comboBox_platform.addItem("")
- self.comboBox_platform.addItem("")
- self.gridLayout.addWidget(self.comboBox_platform, 0, 1, 1, 1)
- self.label_room_display_id = QtWidgets.QLabel(self.formWidget)
- self.label_room_display_id.setObjectName("label_room_display_id")
- self.gridLayout.addWidget(self.label_room_display_id, 1, 0, 1, 1)
- self.lineEdit_before_prompt = QtWidgets.QLineEdit(self.formWidget)
- self.lineEdit_before_prompt.setObjectName("lineEdit_before_prompt")
- self.gridLayout.addWidget(self.lineEdit_before_prompt, 4, 1, 1, 1)
- self.label_before_prompt = QtWidgets.QLabel(self.formWidget)
- self.label_before_prompt.setObjectName("label_before_prompt")
- self.gridLayout.addWidget(self.label_before_prompt, 4, 0, 1, 1)
- self.groupBox_log = QtWidgets.QGroupBox(self.formWidget)
- self.groupBox_log.setObjectName("groupBox_log")
- self.gridLayout_47 = QtWidgets.QGridLayout(self.groupBox_log)
- self.gridLayout_47.setObjectName("gridLayout_47")
- self.gridLayout_46 = QtWidgets.QGridLayout()
- self.gridLayout_46.setObjectName("gridLayout_46")
- self.comboBox_commit_log_type = QtWidgets.QComboBox(self.groupBox_log)
- self.comboBox_commit_log_type.setObjectName("comboBox_commit_log_type")
- self.comboBox_commit_log_type.addItem("")
- self.comboBox_commit_log_type.addItem("")
- self.comboBox_commit_log_type.addItem("")
- self.comboBox_commit_log_type.addItem("")
- self.gridLayout_46.addWidget(self.comboBox_commit_log_type, 1, 1, 1, 1)
- self.label_commit_log_type = QtWidgets.QLabel(self.groupBox_log)
- self.label_commit_log_type.setObjectName("label_commit_log_type")
- self.gridLayout_46.addWidget(self.label_commit_log_type, 1, 0, 1, 1)
- self.label_captions_file_path = QtWidgets.QLabel(self.groupBox_log)
- self.label_captions_file_path.setObjectName("label_captions_file_path")
- self.gridLayout_46.addWidget(self.label_captions_file_path, 3, 0, 1, 1)
- self.lineEdit_captions_file_path = QtWidgets.QLineEdit(self.groupBox_log)
- self.lineEdit_captions_file_path.setObjectName("lineEdit_captions_file_path")
- self.gridLayout_46.addWidget(self.lineEdit_captions_file_path, 3, 1, 1, 1)
- self.label_captions_enable = QtWidgets.QLabel(self.groupBox_log)
- self.label_captions_enable.setObjectName("label_captions_enable")
- self.gridLayout_46.addWidget(self.label_captions_enable, 2, 0, 1, 1)
- self.checkBox_captions_enable = QtWidgets.QCheckBox(self.groupBox_log)
- self.checkBox_captions_enable.setObjectName("checkBox_captions_enable")
- self.gridLayout_46.addWidget(self.checkBox_captions_enable, 2, 1, 1, 1)
- self.gridLayout_46.setColumnStretch(0, 1)
- self.gridLayout_46.setColumnStretch(1, 5)
- self.gridLayout_47.addLayout(self.gridLayout_46, 0, 0, 1, 1)
- self.gridLayout.addWidget(self.groupBox_log, 11, 0, 1, 3)
- self.groupBox_openai = QtWidgets.QGroupBox(self.formWidget)
- self.groupBox_openai.setObjectName("groupBox_openai")
- self.gridLayout_4 = QtWidgets.QGridLayout(self.groupBox_openai)
- self.gridLayout_4.setObjectName("gridLayout_4")
- self.gridLayout_2 = QtWidgets.QGridLayout()
- self.gridLayout_2.setSpacing(2)
- self.gridLayout_2.setObjectName("gridLayout_2")
- self.label_openai_api = QtWidgets.QLabel(self.groupBox_openai)
- self.label_openai_api.setObjectName("label_openai_api")
- self.gridLayout_2.addWidget(self.label_openai_api, 0, 0, 1, 1)
- self.lineEdit_openai_api = QtWidgets.QLineEdit(self.groupBox_openai)
- self.lineEdit_openai_api.setObjectName("lineEdit_openai_api")
- self.gridLayout_2.addWidget(self.lineEdit_openai_api, 0, 2, 1, 1)
- self.label_openai_api_key = QtWidgets.QLabel(self.groupBox_openai)
- self.label_openai_api_key.setObjectName("label_openai_api_key")
- self.gridLayout_2.addWidget(self.label_openai_api_key, 1, 0, 1, 1)
- self.textEdit_openai_api_key = QtWidgets.QTextEdit(self.groupBox_openai)
- self.textEdit_openai_api_key.setObjectName("textEdit_openai_api_key")
- self.gridLayout_2.addWidget(self.textEdit_openai_api_key, 1, 1, 1, 2)
- self.gridLayout_4.addLayout(self.gridLayout_2, 0, 0, 1, 1)
- self.gridLayout.addWidget(self.groupBox_openai, 18, 0, 1, 3)
- self.label_audio_synthesis_type = QtWidgets.QLabel(self.formWidget)
- self.label_audio_synthesis_type.setObjectName("label_audio_synthesis_type")
- self.gridLayout.addWidget(self.label_audio_synthesis_type, 10, 0, 1, 1)
+ self.gridLayout.addWidget(self.groupBox_thanks, 16, 0, 1, 3)
self.groupBox_live2d = QtWidgets.QGroupBox(self.formWidget)
self.groupBox_live2d.setObjectName("groupBox_live2d")
self.gridLayout_30 = QtWidgets.QGridLayout(self.groupBox_live2d)
@@ -243,52 +231,51 @@ def setupUi(self, MainWindow):
self.gridLayout_29.setColumnStretch(0, 1)
self.gridLayout_29.setColumnStretch(1, 8)
self.gridLayout_30.addLayout(self.gridLayout_29, 0, 0, 1, 1)
- self.gridLayout.addWidget(self.groupBox_live2d, 17, 0, 1, 3)
- self.groupBox = QtWidgets.QGroupBox(self.formWidget)
- self.groupBox.setStyleSheet("")
- self.groupBox.setObjectName("groupBox")
- self.gridLayout_26 = QtWidgets.QGridLayout(self.groupBox)
- self.gridLayout_26.setObjectName("gridLayout_26")
- self.gridLayout_25 = QtWidgets.QGridLayout()
- self.gridLayout_25.setObjectName("gridLayout_25")
- self.textEdit_filter_before_must_str = QtWidgets.QTextEdit(self.groupBox)
- self.textEdit_filter_before_must_str.setObjectName("textEdit_filter_before_must_str")
- self.gridLayout_25.addWidget(self.textEdit_filter_before_must_str, 0, 1, 1, 1)
- self.label_filter_badwords_path = QtWidgets.QLabel(self.groupBox)
- self.label_filter_badwords_path.setObjectName("label_filter_badwords_path")
- self.gridLayout_25.addWidget(self.label_filter_badwords_path, 2, 0, 1, 1)
- self.lineEdit_filter_bad_pinyin_path = QtWidgets.QLineEdit(self.groupBox)
- self.lineEdit_filter_bad_pinyin_path.setObjectName("lineEdit_filter_bad_pinyin_path")
- self.gridLayout_25.addWidget(self.lineEdit_filter_bad_pinyin_path, 3, 1, 1, 1)
- self.lineEdit_filter_max_len = QtWidgets.QLineEdit(self.groupBox)
- self.lineEdit_filter_max_len.setObjectName("lineEdit_filter_max_len")
- self.gridLayout_25.addWidget(self.lineEdit_filter_max_len, 4, 1, 1, 1)
- self.label_filter_max_char_len = QtWidgets.QLabel(self.groupBox)
- self.label_filter_max_char_len.setObjectName("label_filter_max_char_len")
- self.gridLayout_25.addWidget(self.label_filter_max_char_len, 5, 0, 1, 1)
- self.label_filter_after_must_str = QtWidgets.QLabel(self.groupBox)
- self.label_filter_after_must_str.setObjectName("label_filter_after_must_str")
- self.gridLayout_25.addWidget(self.label_filter_after_must_str, 1, 0, 1, 1)
- self.textEdit_filter_after_must_str = QtWidgets.QTextEdit(self.groupBox)
- self.textEdit_filter_after_must_str.setObjectName("textEdit_filter_after_must_str")
- self.gridLayout_25.addWidget(self.textEdit_filter_after_must_str, 1, 1, 1, 1)
- self.label_filter_max_len = QtWidgets.QLabel(self.groupBox)
- self.label_filter_max_len.setObjectName("label_filter_max_len")
- self.gridLayout_25.addWidget(self.label_filter_max_len, 4, 0, 1, 1)
- self.label_filter_before_must_str = QtWidgets.QLabel(self.groupBox)
- self.label_filter_before_must_str.setObjectName("label_filter_before_must_str")
- self.gridLayout_25.addWidget(self.label_filter_before_must_str, 0, 0, 1, 1)
- self.lineEdit_filter_max_char_len = QtWidgets.QLineEdit(self.groupBox)
- self.lineEdit_filter_max_char_len.setObjectName("lineEdit_filter_max_char_len")
- self.gridLayout_25.addWidget(self.lineEdit_filter_max_char_len, 5, 1, 1, 1)
- self.lineEdit_filter_badwords_path = QtWidgets.QLineEdit(self.groupBox)
- self.lineEdit_filter_badwords_path.setObjectName("lineEdit_filter_badwords_path")
- self.gridLayout_25.addWidget(self.lineEdit_filter_badwords_path, 2, 1, 1, 1)
- self.label_filter_bad_pinyin_path = QtWidgets.QLabel(self.groupBox)
- self.label_filter_bad_pinyin_path.setObjectName("label_filter_bad_pinyin_path")
- self.gridLayout_25.addWidget(self.label_filter_bad_pinyin_path, 3, 0, 1, 1)
- self.gridLayout_26.addLayout(self.gridLayout_25, 0, 0, 1, 1)
- self.gridLayout.addWidget(self.groupBox, 13, 0, 1, 3)
+ self.gridLayout.addWidget(self.groupBox_live2d, 18, 0, 1, 3)
+ self.groupBox_chatglm = QtWidgets.QGroupBox(self.formWidget)
+ self.groupBox_chatglm.setObjectName("groupBox_chatglm")
+ self.gridLayout_9 = QtWidgets.QGridLayout(self.groupBox_chatglm)
+ self.gridLayout_9.setObjectName("gridLayout_9")
+ self.gridLayout_8 = QtWidgets.QGridLayout()
+ self.gridLayout_8.setObjectName("gridLayout_8")
+ self.label_chatglm_api_ip_port = QtWidgets.QLabel(self.groupBox_chatglm)
+ self.label_chatglm_api_ip_port.setObjectName("label_chatglm_api_ip_port")
+ self.gridLayout_8.addWidget(self.label_chatglm_api_ip_port, 0, 0, 1, 1)
+ self.lineEdit_chatglm_max_length = QtWidgets.QLineEdit(self.groupBox_chatglm)
+ self.lineEdit_chatglm_max_length.setObjectName("lineEdit_chatglm_max_length")
+ self.gridLayout_8.addWidget(self.lineEdit_chatglm_max_length, 1, 1, 1, 1)
+ self.lineEdit_chatglm_top_p = QtWidgets.QLineEdit(self.groupBox_chatglm)
+ self.lineEdit_chatglm_top_p.setObjectName("lineEdit_chatglm_top_p")
+ self.gridLayout_8.addWidget(self.lineEdit_chatglm_top_p, 2, 1, 1, 1)
+ self.lineEdit_chatglm_api_ip_port = QtWidgets.QLineEdit(self.groupBox_chatglm)
+ self.lineEdit_chatglm_api_ip_port.setObjectName("lineEdit_chatglm_api_ip_port")
+ self.gridLayout_8.addWidget(self.lineEdit_chatglm_api_ip_port, 0, 1, 1, 1)
+ self.label_chatglm_top_p = QtWidgets.QLabel(self.groupBox_chatglm)
+ self.label_chatglm_top_p.setObjectName("label_chatglm_top_p")
+ self.gridLayout_8.addWidget(self.label_chatglm_top_p, 2, 0, 1, 1)
+ self.label_chatglm_max_length = QtWidgets.QLabel(self.groupBox_chatglm)
+ self.label_chatglm_max_length.setObjectName("label_chatglm_max_length")
+ self.gridLayout_8.addWidget(self.label_chatglm_max_length, 1, 0, 1, 1)
+ self.label_chatglm_temperature = QtWidgets.QLabel(self.groupBox_chatglm)
+ self.label_chatglm_temperature.setObjectName("label_chatglm_temperature")
+ self.gridLayout_8.addWidget(self.label_chatglm_temperature, 3, 0, 1, 1)
+ self.lineEdit_chatglm_temperature = QtWidgets.QLineEdit(self.groupBox_chatglm)
+ self.lineEdit_chatglm_temperature.setObjectName("lineEdit_chatglm_temperature")
+ self.gridLayout_8.addWidget(self.lineEdit_chatglm_temperature, 3, 1, 1, 1)
+ self.gridLayout_9.addLayout(self.gridLayout_8, 0, 0, 1, 1)
+ self.gridLayout.addWidget(self.groupBox_chatglm, 23, 0, 1, 3)
+ self.label_chat_type = QtWidgets.QLabel(self.formWidget)
+ self.label_chat_type.setObjectName("label_chat_type")
+ self.gridLayout.addWidget(self.label_chat_type, 2, 0, 1, 1)
+ self.label_need_lang = QtWidgets.QLabel(self.formWidget)
+ self.label_need_lang.setObjectName("label_need_lang")
+ self.gridLayout.addWidget(self.label_need_lang, 3, 0, 1, 1)
+ self.label_room_display_id = QtWidgets.QLabel(self.formWidget)
+ self.label_room_display_id.setObjectName("label_room_display_id")
+ self.gridLayout.addWidget(self.label_room_display_id, 1, 0, 1, 1)
+ self.lineEdit_after_prompt = QtWidgets.QLineEdit(self.formWidget)
+ self.lineEdit_after_prompt.setObjectName("lineEdit_after_prompt")
+ self.gridLayout.addWidget(self.lineEdit_after_prompt, 5, 1, 1, 1)
self.groupBox_claude = QtWidgets.QGroupBox(self.formWidget)
self.groupBox_claude.setObjectName("groupBox_claude")
self.gridLayout_7 = QtWidgets.QGridLayout(self.groupBox_claude)
@@ -308,11 +295,125 @@ def setupUi(self, MainWindow):
self.lineEdit_claude_bot_user_id = QtWidgets.QLineEdit(self.groupBox_claude)
self.lineEdit_claude_bot_user_id.setObjectName("lineEdit_claude_bot_user_id")
self.gridLayout_7.addWidget(self.lineEdit_claude_bot_user_id, 1, 1, 1, 1)
- self.gridLayout.addWidget(self.groupBox_claude, 21, 0, 1, 3)
+ self.gridLayout.addWidget(self.groupBox_claude, 22, 0, 1, 3)
+ self.label_before_prompt = QtWidgets.QLabel(self.formWidget)
+ self.label_before_prompt.setObjectName("label_before_prompt")
+ self.gridLayout.addWidget(self.label_before_prompt, 4, 0, 1, 1)
self.label_platform = QtWidgets.QLabel(self.formWidget)
self.label_platform.setAutoFillBackground(True)
self.label_platform.setObjectName("label_platform")
self.gridLayout.addWidget(self.label_platform, 0, 0, 1, 1)
+ self.groupBox_log = QtWidgets.QGroupBox(self.formWidget)
+ self.groupBox_log.setObjectName("groupBox_log")
+ self.gridLayout_47 = QtWidgets.QGridLayout(self.groupBox_log)
+ self.gridLayout_47.setObjectName("gridLayout_47")
+ self.gridLayout_46 = QtWidgets.QGridLayout()
+ self.gridLayout_46.setObjectName("gridLayout_46")
+ self.comboBox_commit_log_type = QtWidgets.QComboBox(self.groupBox_log)
+ self.comboBox_commit_log_type.setObjectName("comboBox_commit_log_type")
+ self.comboBox_commit_log_type.addItem("")
+ self.comboBox_commit_log_type.addItem("")
+ self.comboBox_commit_log_type.addItem("")
+ self.comboBox_commit_log_type.addItem("")
+ self.gridLayout_46.addWidget(self.comboBox_commit_log_type, 1, 1, 1, 1)
+ self.label_commit_log_type = QtWidgets.QLabel(self.groupBox_log)
+ self.label_commit_log_type.setObjectName("label_commit_log_type")
+ self.gridLayout_46.addWidget(self.label_commit_log_type, 1, 0, 1, 1)
+ self.label_captions_file_path = QtWidgets.QLabel(self.groupBox_log)
+ self.label_captions_file_path.setObjectName("label_captions_file_path")
+ self.gridLayout_46.addWidget(self.label_captions_file_path, 3, 0, 1, 1)
+ self.lineEdit_captions_file_path = QtWidgets.QLineEdit(self.groupBox_log)
+ self.lineEdit_captions_file_path.setObjectName("lineEdit_captions_file_path")
+ self.gridLayout_46.addWidget(self.lineEdit_captions_file_path, 3, 1, 1, 1)
+ self.label_captions_enable = QtWidgets.QLabel(self.groupBox_log)
+ self.label_captions_enable.setObjectName("label_captions_enable")
+ self.gridLayout_46.addWidget(self.label_captions_enable, 2, 0, 1, 1)
+ self.checkBox_captions_enable = QtWidgets.QCheckBox(self.groupBox_log)
+ self.checkBox_captions_enable.setObjectName("checkBox_captions_enable")
+ self.gridLayout_46.addWidget(self.checkBox_captions_enable, 2, 1, 1, 1)
+ self.gridLayout_46.setColumnStretch(0, 1)
+ self.gridLayout_46.setColumnStretch(1, 5)
+ self.gridLayout_47.addLayout(self.gridLayout_46, 0, 0, 1, 1)
+ self.gridLayout.addWidget(self.groupBox_log, 12, 0, 1, 3)
+ self.lineEdit_before_prompt = QtWidgets.QLineEdit(self.formWidget)
+ self.lineEdit_before_prompt.setObjectName("lineEdit_before_prompt")
+ self.gridLayout.addWidget(self.lineEdit_before_prompt, 4, 1, 1, 1)
+ self.label_audio_synthesis_type = QtWidgets.QLabel(self.formWidget)
+ self.label_audio_synthesis_type.setObjectName("label_audio_synthesis_type")
+ self.gridLayout.addWidget(self.label_audio_synthesis_type, 10, 0, 1, 1)
+ self.comboBox_audio_synthesis_type = QtWidgets.QComboBox(self.formWidget)
+ self.comboBox_audio_synthesis_type.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
+ self.comboBox_audio_synthesis_type.setObjectName("comboBox_audio_synthesis_type")
+ self.comboBox_audio_synthesis_type.addItem("")
+ self.comboBox_audio_synthesis_type.addItem("")
+ self.comboBox_audio_synthesis_type.addItem("")
+ self.comboBox_audio_synthesis_type.addItem("")
+ self.gridLayout.addWidget(self.comboBox_audio_synthesis_type, 10, 1, 1, 1)
+ self.lineEdit_room_display_id = QtWidgets.QLineEdit(self.formWidget)
+ self.lineEdit_room_display_id.setObjectName("lineEdit_room_display_id")
+ self.gridLayout.addWidget(self.lineEdit_room_display_id, 1, 1, 1, 1)
+ self.groupBox_local_qa = QtWidgets.QGroupBox(self.formWidget)
+ self.groupBox_local_qa.setObjectName("groupBox_local_qa")
+ self.gridLayout_51 = QtWidgets.QGridLayout(self.groupBox_local_qa)
+ self.gridLayout_51.setObjectName("gridLayout_51")
+ self.gridLayout_50 = QtWidgets.QGridLayout()
+ self.gridLayout_50.setObjectName("gridLayout_50")
+ self.label_local_qa_text_file_path = QtWidgets.QLabel(self.groupBox_local_qa)
+ self.label_local_qa_text_file_path.setObjectName("label_local_qa_text_file_path")
+ self.gridLayout_50.addWidget(self.label_local_qa_text_file_path, 1, 0, 1, 1)
+ self.lineEdit_local_qa_audio_file_path = QtWidgets.QLineEdit(self.groupBox_local_qa)
+ self.lineEdit_local_qa_audio_file_path.setObjectName("lineEdit_local_qa_audio_file_path")
+ self.gridLayout_50.addWidget(self.lineEdit_local_qa_audio_file_path, 3, 1, 1, 1)
+ self.lineEdit_local_qa_text_file_path = QtWidgets.QLineEdit(self.groupBox_local_qa)
+ self.lineEdit_local_qa_text_file_path.setObjectName("lineEdit_local_qa_text_file_path")
+ self.gridLayout_50.addWidget(self.lineEdit_local_qa_text_file_path, 1, 1, 1, 1)
+ self.label_local_qa_audio_enable = QtWidgets.QLabel(self.groupBox_local_qa)
+ self.label_local_qa_audio_enable.setObjectName("label_local_qa_audio_enable")
+ self.gridLayout_50.addWidget(self.label_local_qa_audio_enable, 2, 0, 1, 1)
+ self.label_local_qa_text_enable = QtWidgets.QLabel(self.groupBox_local_qa)
+ self.label_local_qa_text_enable.setObjectName("label_local_qa_text_enable")
+ self.gridLayout_50.addWidget(self.label_local_qa_text_enable, 0, 0, 1, 1)
+ self.label_local_qa_audio_file_path = QtWidgets.QLabel(self.groupBox_local_qa)
+ self.label_local_qa_audio_file_path.setObjectName("label_local_qa_audio_file_path")
+ self.gridLayout_50.addWidget(self.label_local_qa_audio_file_path, 3, 0, 1, 1)
+ self.checkBox_local_qa_text_enable = QtWidgets.QCheckBox(self.groupBox_local_qa)
+ self.checkBox_local_qa_text_enable.setObjectName("checkBox_local_qa_text_enable")
+ self.gridLayout_50.addWidget(self.checkBox_local_qa_text_enable, 0, 1, 1, 1)
+ self.checkBox_local_qa_audio_enable = QtWidgets.QCheckBox(self.groupBox_local_qa)
+ self.checkBox_local_qa_audio_enable.setObjectName("checkBox_local_qa_audio_enable")
+ self.gridLayout_50.addWidget(self.checkBox_local_qa_audio_enable, 2, 1, 1, 1)
+ self.label_local_qa_similarity = QtWidgets.QLabel(self.groupBox_local_qa)
+ self.label_local_qa_similarity.setObjectName("label_local_qa_similarity")
+ self.gridLayout_50.addWidget(self.label_local_qa_similarity, 4, 0, 1, 1)
+ self.lineEdit_local_qa_similarity = QtWidgets.QLineEdit(self.groupBox_local_qa)
+ self.lineEdit_local_qa_similarity.setObjectName("lineEdit_local_qa_similarity")
+ self.gridLayout_50.addWidget(self.lineEdit_local_qa_similarity, 4, 1, 1, 1)
+ self.gridLayout_51.addLayout(self.gridLayout_50, 0, 0, 1, 1)
+ self.gridLayout.addWidget(self.groupBox_local_qa, 13, 0, 1, 3)
+ self.label_after_prompt = QtWidgets.QLabel(self.formWidget)
+ self.label_after_prompt.setObjectName("label_after_prompt")
+ self.gridLayout.addWidget(self.label_after_prompt, 5, 0, 1, 1)
+ self.groupBox_openai = QtWidgets.QGroupBox(self.formWidget)
+ self.groupBox_openai.setObjectName("groupBox_openai")
+ self.gridLayout_4 = QtWidgets.QGridLayout(self.groupBox_openai)
+ self.gridLayout_4.setObjectName("gridLayout_4")
+ self.gridLayout_2 = QtWidgets.QGridLayout()
+ self.gridLayout_2.setSpacing(2)
+ self.gridLayout_2.setObjectName("gridLayout_2")
+ self.label_openai_api = QtWidgets.QLabel(self.groupBox_openai)
+ self.label_openai_api.setObjectName("label_openai_api")
+ self.gridLayout_2.addWidget(self.label_openai_api, 0, 0, 1, 1)
+ self.lineEdit_openai_api = QtWidgets.QLineEdit(self.groupBox_openai)
+ self.lineEdit_openai_api.setObjectName("lineEdit_openai_api")
+ self.gridLayout_2.addWidget(self.lineEdit_openai_api, 0, 2, 1, 1)
+ self.label_openai_api_key = QtWidgets.QLabel(self.groupBox_openai)
+ self.label_openai_api_key.setObjectName("label_openai_api_key")
+ self.gridLayout_2.addWidget(self.label_openai_api_key, 1, 0, 1, 1)
+ self.textEdit_openai_api_key = QtWidgets.QTextEdit(self.groupBox_openai)
+ self.textEdit_openai_api_key.setObjectName("textEdit_openai_api_key")
+ self.gridLayout_2.addWidget(self.textEdit_openai_api_key, 1, 1, 1, 2)
+ self.gridLayout_4.addLayout(self.gridLayout_2, 0, 0, 1, 1)
+ self.gridLayout.addWidget(self.groupBox_openai, 19, 0, 1, 3)
self.groupBox_chatgpt = QtWidgets.QGroupBox(self.formWidget)
self.groupBox_chatgpt.setObjectName("groupBox_chatgpt")
self.gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_chatgpt)
@@ -381,102 +482,13 @@ def setupUi(self, MainWindow):
self.comboBox_chatgpt_model.addItem("")
self.gridLayout_3.addWidget(self.comboBox_chatgpt_model, 0, 1, 1, 1)
self.gridLayout_5.addLayout(self.gridLayout_3, 0, 0, 1, 1)
- self.gridLayout.addWidget(self.groupBox_chatgpt, 19, 0, 2, 3)
- self.lineEdit_room_display_id = QtWidgets.QLineEdit(self.formWidget)
- self.lineEdit_room_display_id.setObjectName("lineEdit_room_display_id")
- self.gridLayout.addWidget(self.lineEdit_room_display_id, 1, 1, 1, 1)
- self.label_need_lang = QtWidgets.QLabel(self.formWidget)
- self.label_need_lang.setObjectName("label_need_lang")
- self.gridLayout.addWidget(self.label_need_lang, 3, 0, 1, 1)
- self.lineEdit_after_prompt = QtWidgets.QLineEdit(self.formWidget)
- self.lineEdit_after_prompt.setObjectName("lineEdit_after_prompt")
- self.gridLayout.addWidget(self.lineEdit_after_prompt, 5, 1, 1, 1)
- self.comboBox_chat_type = QtWidgets.QComboBox(self.formWidget)
- self.comboBox_chat_type.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
- self.comboBox_chat_type.setObjectName("comboBox_chat_type")
- self.comboBox_chat_type.addItem("")
- self.comboBox_chat_type.addItem("")
- self.comboBox_chat_type.addItem("")
- self.comboBox_chat_type.addItem("")
- self.comboBox_chat_type.addItem("")
- self.comboBox_chat_type.addItem("")
- self.comboBox_chat_type.addItem("")
- self.gridLayout.addWidget(self.comboBox_chat_type, 2, 1, 1, 1)
- self.label_after_prompt = QtWidgets.QLabel(self.formWidget)
- self.label_after_prompt.setObjectName("label_after_prompt")
- self.gridLayout.addWidget(self.label_after_prompt, 5, 0, 1, 1)
- self.comboBox_audio_synthesis_type = QtWidgets.QComboBox(self.formWidget)
- self.comboBox_audio_synthesis_type.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
- self.comboBox_audio_synthesis_type.setObjectName("comboBox_audio_synthesis_type")
- self.comboBox_audio_synthesis_type.addItem("")
- self.comboBox_audio_synthesis_type.addItem("")
- self.comboBox_audio_synthesis_type.addItem("")
- self.comboBox_audio_synthesis_type.addItem("")
- self.gridLayout.addWidget(self.comboBox_audio_synthesis_type, 10, 1, 1, 1)
- self.groupBox_chatglm = QtWidgets.QGroupBox(self.formWidget)
- self.groupBox_chatglm.setObjectName("groupBox_chatglm")
- self.gridLayout_9 = QtWidgets.QGridLayout(self.groupBox_chatglm)
- self.gridLayout_9.setObjectName("gridLayout_9")
- self.gridLayout_8 = QtWidgets.QGridLayout()
- self.gridLayout_8.setObjectName("gridLayout_8")
- self.label_chatglm_api_ip_port = QtWidgets.QLabel(self.groupBox_chatglm)
- self.label_chatglm_api_ip_port.setObjectName("label_chatglm_api_ip_port")
- self.gridLayout_8.addWidget(self.label_chatglm_api_ip_port, 0, 0, 1, 1)
- self.lineEdit_chatglm_max_length = QtWidgets.QLineEdit(self.groupBox_chatglm)
- self.lineEdit_chatglm_max_length.setObjectName("lineEdit_chatglm_max_length")
- self.gridLayout_8.addWidget(self.lineEdit_chatglm_max_length, 1, 1, 1, 1)
- self.lineEdit_chatglm_top_p = QtWidgets.QLineEdit(self.groupBox_chatglm)
- self.lineEdit_chatglm_top_p.setObjectName("lineEdit_chatglm_top_p")
- self.gridLayout_8.addWidget(self.lineEdit_chatglm_top_p, 2, 1, 1, 1)
- self.lineEdit_chatglm_api_ip_port = QtWidgets.QLineEdit(self.groupBox_chatglm)
- self.lineEdit_chatglm_api_ip_port.setObjectName("lineEdit_chatglm_api_ip_port")
- self.gridLayout_8.addWidget(self.lineEdit_chatglm_api_ip_port, 0, 1, 1, 1)
- self.label_chatglm_top_p = QtWidgets.QLabel(self.groupBox_chatglm)
- self.label_chatglm_top_p.setObjectName("label_chatglm_top_p")
- self.gridLayout_8.addWidget(self.label_chatglm_top_p, 2, 0, 1, 1)
- self.label_chatglm_max_length = QtWidgets.QLabel(self.groupBox_chatglm)
- self.label_chatglm_max_length.setObjectName("label_chatglm_max_length")
- self.gridLayout_8.addWidget(self.label_chatglm_max_length, 1, 0, 1, 1)
- self.label_chatglm_temperature = QtWidgets.QLabel(self.groupBox_chatglm)
- self.label_chatglm_temperature.setObjectName("label_chatglm_temperature")
- self.gridLayout_8.addWidget(self.label_chatglm_temperature, 3, 0, 1, 1)
- self.lineEdit_chatglm_temperature = QtWidgets.QLineEdit(self.groupBox_chatglm)
- self.lineEdit_chatglm_temperature.setObjectName("lineEdit_chatglm_temperature")
- self.gridLayout_8.addWidget(self.lineEdit_chatglm_temperature, 3, 1, 1, 1)
- self.gridLayout_9.addLayout(self.gridLayout_8, 0, 0, 1, 1)
- self.gridLayout.addWidget(self.groupBox_chatglm, 22, 0, 1, 3)
- self.groupBox_local_qa = QtWidgets.QGroupBox(self.formWidget)
- self.groupBox_local_qa.setObjectName("groupBox_local_qa")
- self.gridLayout_51 = QtWidgets.QGridLayout(self.groupBox_local_qa)
- self.gridLayout_51.setObjectName("gridLayout_51")
- self.gridLayout_50 = QtWidgets.QGridLayout()
- self.gridLayout_50.setObjectName("gridLayout_50")
- self.label_local_qa_text_file_path = QtWidgets.QLabel(self.groupBox_local_qa)
- self.label_local_qa_text_file_path.setObjectName("label_local_qa_text_file_path")
- self.gridLayout_50.addWidget(self.label_local_qa_text_file_path, 1, 0, 1, 1)
- self.label_local_qa_audio_enable = QtWidgets.QLabel(self.groupBox_local_qa)
- self.label_local_qa_audio_enable.setObjectName("label_local_qa_audio_enable")
- self.gridLayout_50.addWidget(self.label_local_qa_audio_enable, 2, 0, 1, 1)
- self.checkBox_local_qa_text_enable = QtWidgets.QCheckBox(self.groupBox_local_qa)
- self.checkBox_local_qa_text_enable.setObjectName("checkBox_local_qa_text_enable")
- self.gridLayout_50.addWidget(self.checkBox_local_qa_text_enable, 0, 1, 1, 1)
- self.label_local_qa_text_enable = QtWidgets.QLabel(self.groupBox_local_qa)
- self.label_local_qa_text_enable.setObjectName("label_local_qa_text_enable")
- self.gridLayout_50.addWidget(self.label_local_qa_text_enable, 0, 0, 1, 1)
- self.lineEdit_local_qa_text_file_path = QtWidgets.QLineEdit(self.groupBox_local_qa)
- self.lineEdit_local_qa_text_file_path.setObjectName("lineEdit_local_qa_text_file_path")
- self.gridLayout_50.addWidget(self.lineEdit_local_qa_text_file_path, 1, 1, 1, 1)
- self.label_local_qa_audio_file_path = QtWidgets.QLabel(self.groupBox_local_qa)
- self.label_local_qa_audio_file_path.setObjectName("label_local_qa_audio_file_path")
- self.gridLayout_50.addWidget(self.label_local_qa_audio_file_path, 3, 0, 1, 1)
- self.checkBox_local_qa_audio_enable = QtWidgets.QCheckBox(self.groupBox_local_qa)
- self.checkBox_local_qa_audio_enable.setObjectName("checkBox_local_qa_audio_enable")
- self.gridLayout_50.addWidget(self.checkBox_local_qa_audio_enable, 2, 1, 1, 1)
- self.lineEdit_local_qa_audio_file_path = QtWidgets.QLineEdit(self.groupBox_local_qa)
- self.lineEdit_local_qa_audio_file_path.setObjectName("lineEdit_local_qa_audio_file_path")
- self.gridLayout_50.addWidget(self.lineEdit_local_qa_audio_file_path, 3, 1, 1, 1)
- self.gridLayout_51.addLayout(self.gridLayout_50, 0, 0, 1, 1)
- self.gridLayout.addWidget(self.groupBox_local_qa, 12, 0, 1, 3)
+ self.gridLayout.addWidget(self.groupBox_chatgpt, 20, 0, 2, 3)
+ self.label_read_user_name = QtWidgets.QLabel(self.formWidget)
+ self.label_read_user_name.setObjectName("label_read_user_name")
+ self.gridLayout.addWidget(self.label_read_user_name, 11, 0, 1, 1)
+ self.checkBox_read_user_name = QtWidgets.QCheckBox(self.formWidget)
+ self.checkBox_read_user_name.setObjectName("checkBox_read_user_name")
+ self.gridLayout.addWidget(self.checkBox_read_user_name, 11, 1, 1, 1)
self.verticalLayout.addWidget(self.formWidget)
self.groupBox_chat_with_file = QtWidgets.QGroupBox(self.scrollAreaWidgetContents)
self.groupBox_chat_with_file.setObjectName("groupBox_chat_with_file")
@@ -1025,7 +1037,7 @@ def setupUi(self, MainWindow):
self.scrollArea_2.setWidgetResizable(True)
self.scrollArea_2.setObjectName("scrollArea_2")
self.scrollAreaWidgetContents_2 = QtWidgets.QWidget()
- self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, -206, 963, 1181))
+ self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 749, 1181))
self.scrollAreaWidgetContents_2.setObjectName("scrollAreaWidgetContents_2")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_2)
self.verticalLayout_2.setObjectName("verticalLayout_2")
@@ -1215,7 +1227,7 @@ def setupUi(self, MainWindow):
self.scrollArea_3.setWidgetResizable(True)
self.scrollArea_3.setObjectName("scrollArea_3")
self.scrollAreaWidgetContents_3 = QtWidgets.QWidget()
- self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 963, 919))
+ self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 328, 919))
self.scrollAreaWidgetContents_3.setObjectName("scrollAreaWidgetContents_3")
self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_3)
self.verticalLayout_3.setObjectName("verticalLayout_3")
@@ -1406,6 +1418,28 @@ def retranslateUi(self, MainWindow):
self.pushButton_run.setText(_translate("MainWindow", "运行"))
self.pushButton_config_page.setText(_translate("MainWindow", "①配置页"))
self.pushButton_save.setText(_translate("MainWindow", "保存配置"))
+ self.comboBox_platform.setItemText(0, _translate("MainWindow", "哔哩哔哩"))
+ self.comboBox_platform.setItemText(1, _translate("MainWindow", "抖音"))
+ self.comboBox_platform.setItemText(2, _translate("MainWindow", "快手"))
+ self.comboBox_platform.setItemText(3, _translate("MainWindow", "聊天模式-谷歌"))
+ self.groupBox.setTitle(_translate("MainWindow", "过滤"))
+ self.label_filter_badwords_path.setText(_translate("MainWindow", "违禁词路径"))
+ self.label_filter_max_char_len.setText(_translate("MainWindow", "最大字符数"))
+ self.label_filter_after_must_str.setText(_translate("MainWindow", "弹幕后缀"))
+ self.label_filter_max_len.setText(_translate("MainWindow", "最大单词数"))
+ self.label_filter_before_must_str.setText(_translate("MainWindow", "弹幕前缀"))
+ self.label_filter_bad_pinyin_path.setText(_translate("MainWindow", "违禁拼音路径"))
+ self.comboBox_chat_type.setItemText(0, _translate("MainWindow", "复读机"))
+ self.comboBox_chat_type.setItemText(1, _translate("MainWindow", "ChatGPT"))
+ self.comboBox_chat_type.setItemText(2, _translate("MainWindow", "Claude"))
+ self.comboBox_chat_type.setItemText(3, _translate("MainWindow", "ChatGLM"))
+ self.comboBox_chat_type.setItemText(4, _translate("MainWindow", "chat_with_file"))
+ self.comboBox_chat_type.setItemText(5, _translate("MainWindow", "Chatterbot"))
+ self.comboBox_chat_type.setItemText(6, _translate("MainWindow", "text-generation-webui"))
+ self.comboBox_need_lang.setItemText(0, _translate("MainWindow", "所有"))
+ self.comboBox_need_lang.setItemText(1, _translate("MainWindow", "中文"))
+ self.comboBox_need_lang.setItemText(2, _translate("MainWindow", "英文"))
+ self.comboBox_need_lang.setItemText(3, _translate("MainWindow", "日文"))
self.groupBox_thanks.setTitle(_translate("MainWindow", "答谢"))
self.label_thanks_entrance_copy.setText(_translate("MainWindow", "入场文案"))
self.label_thanks_gift_copy.setText(_translate("MainWindow", "礼物文案"))
@@ -1414,17 +1448,24 @@ def retranslateUi(self, MainWindow):
self.label_thanks_entrance_enable.setText(_translate("MainWindow", "入场欢迎"))
self.label_thanks_gift_enable.setText(_translate("MainWindow", "礼物答谢"))
self.checkBox_thanks_gift_enable.setText(_translate("MainWindow", "启用"))
- self.comboBox_need_lang.setItemText(0, _translate("MainWindow", "所有"))
- self.comboBox_need_lang.setItemText(1, _translate("MainWindow", "中文"))
- self.comboBox_need_lang.setItemText(2, _translate("MainWindow", "英文"))
- self.comboBox_need_lang.setItemText(3, _translate("MainWindow", "日文"))
+ self.groupBox_live2d.setTitle(_translate("MainWindow", "Live2D"))
+ self.checkBox_live2d_enable.setText(_translate("MainWindow", "是"))
+ self.label_live2d_port.setText(_translate("MainWindow", "端口"))
+ self.label_live2d_enable.setText(_translate("MainWindow", "启用"))
+ self.label_live2d_name.setText(_translate("MainWindow", "模型名"))
+ self.groupBox_chatglm.setTitle(_translate("MainWindow", "ChatGLM"))
+ self.label_chatglm_api_ip_port.setText(_translate("MainWindow", "api地址"))
+ self.label_chatglm_top_p.setText(_translate("MainWindow", "前p个选择"))
+ self.label_chatglm_max_length.setText(_translate("MainWindow", "最大长度限制"))
+ self.label_chatglm_temperature.setText(_translate("MainWindow", "温度"))
self.label_chat_type.setText(_translate("MainWindow", "聊天类型"))
- self.comboBox_platform.setItemText(0, _translate("MainWindow", "哔哩哔哩"))
- self.comboBox_platform.setItemText(1, _translate("MainWindow", "抖音"))
- self.comboBox_platform.setItemText(2, _translate("MainWindow", "快手"))
- self.comboBox_platform.setItemText(3, _translate("MainWindow", "聊天模式-谷歌"))
+ self.label_need_lang.setText(_translate("MainWindow", "回复语言"))
self.label_room_display_id.setText(_translate("MainWindow", "直播间号"))
+ self.groupBox_claude.setTitle(_translate("MainWindow", "Claude"))
+ self.label_claude_slack_user_token.setText(_translate("MainWindow", "slack_user_token"))
+ self.label_claude_bot_user_id.setText(_translate("MainWindow", "bot_user_id"))
self.label_before_prompt.setText(_translate("MainWindow", "提示词前缀"))
+ self.label_platform.setText(_translate("MainWindow", "平台"))
self.groupBox_log.setTitle(_translate("MainWindow", "日志"))
self.comboBox_commit_log_type.setItemText(0, _translate("MainWindow", "问答"))
self.comboBox_commit_log_type.setItemText(1, _translate("MainWindow", "问题"))
@@ -1434,26 +1475,23 @@ def retranslateUi(self, MainWindow):
self.label_captions_file_path.setText(_translate("MainWindow", "字幕日志路径"))
self.label_captions_enable.setText(_translate("MainWindow", "字幕日志"))
self.checkBox_captions_enable.setText(_translate("MainWindow", "启用"))
+ self.label_audio_synthesis_type.setText(_translate("MainWindow", "语音合成"))
+ self.comboBox_audio_synthesis_type.setItemText(0, _translate("MainWindow", "Edge-TTS"))
+ self.comboBox_audio_synthesis_type.setItemText(1, _translate("MainWindow", "VITS-Fast"))
+ self.comboBox_audio_synthesis_type.setItemText(2, _translate("MainWindow", "elevenlabs"))
+ self.comboBox_audio_synthesis_type.setItemText(3, _translate("MainWindow", "genshinvoice_top"))
+ self.groupBox_local_qa.setTitle(_translate("MainWindow", "本地问答"))
+ self.label_local_qa_text_file_path.setText(_translate("MainWindow", "文本问答数据路径"))
+ self.label_local_qa_audio_enable.setText(_translate("MainWindow", "音频匹配"))
+ self.label_local_qa_text_enable.setText(_translate("MainWindow", "文本匹配"))
+ self.label_local_qa_audio_file_path.setText(_translate("MainWindow", "音频存储路径"))
+ self.checkBox_local_qa_text_enable.setText(_translate("MainWindow", "启用"))
+ self.checkBox_local_qa_audio_enable.setText(_translate("MainWindow", "启用"))
+ self.label_local_qa_similarity.setText(_translate("MainWindow", "最低相似度"))
+ self.label_after_prompt.setText(_translate("MainWindow", "提示词后缀"))
self.groupBox_openai.setTitle(_translate("MainWindow", "openai"))
self.label_openai_api.setText(_translate("MainWindow", "API"))
self.label_openai_api_key.setText(_translate("MainWindow", "API KEY"))
- self.label_audio_synthesis_type.setText(_translate("MainWindow", "语音合成"))
- self.groupBox_live2d.setTitle(_translate("MainWindow", "Live2D"))
- self.checkBox_live2d_enable.setText(_translate("MainWindow", "是"))
- self.label_live2d_port.setText(_translate("MainWindow", "端口"))
- self.label_live2d_enable.setText(_translate("MainWindow", "启用"))
- self.label_live2d_name.setText(_translate("MainWindow", "模型名"))
- self.groupBox.setTitle(_translate("MainWindow", "过滤"))
- self.label_filter_badwords_path.setText(_translate("MainWindow", "违禁词路径"))
- self.label_filter_max_char_len.setText(_translate("MainWindow", "最大字符数"))
- self.label_filter_after_must_str.setText(_translate("MainWindow", "弹幕后缀"))
- self.label_filter_max_len.setText(_translate("MainWindow", "最大单词数"))
- self.label_filter_before_must_str.setText(_translate("MainWindow", "弹幕前缀"))
- self.label_filter_bad_pinyin_path.setText(_translate("MainWindow", "违禁拼音路径"))
- self.groupBox_claude.setTitle(_translate("MainWindow", "Claude"))
- self.label_claude_slack_user_token.setText(_translate("MainWindow", "slack_user_token"))
- self.label_claude_bot_user_id.setText(_translate("MainWindow", "bot_user_id"))
- self.label_platform.setText(_translate("MainWindow", "平台"))
self.groupBox_chatgpt.setTitle(_translate("MainWindow", "chatgpt"))
self.label_chatgpt_model.setText(_translate("MainWindow", "模型"))
self.label_chatgpt_max_tokens.setText(_translate("MainWindow", "最大令牌数"))
@@ -1481,31 +1519,8 @@ def retranslateUi(self, MainWindow):
self.comboBox_chatgpt_model.setItemText(16, _translate("MainWindow", "text-ada-001"))
self.comboBox_chatgpt_model.setItemText(17, _translate("MainWindow", "text-moderation-latest"))
self.comboBox_chatgpt_model.setItemText(18, _translate("MainWindow", "text-moderation-stable"))
- self.label_need_lang.setText(_translate("MainWindow", "回复语言"))
- self.comboBox_chat_type.setItemText(0, _translate("MainWindow", "复读机"))
- self.comboBox_chat_type.setItemText(1, _translate("MainWindow", "ChatGPT"))
- self.comboBox_chat_type.setItemText(2, _translate("MainWindow", "Claude"))
- self.comboBox_chat_type.setItemText(3, _translate("MainWindow", "ChatGLM"))
- self.comboBox_chat_type.setItemText(4, _translate("MainWindow", "chat_with_file"))
- self.comboBox_chat_type.setItemText(5, _translate("MainWindow", "Chatterbot"))
- self.comboBox_chat_type.setItemText(6, _translate("MainWindow", "text-generation-webui"))
- self.label_after_prompt.setText(_translate("MainWindow", "提示词后缀"))
- self.comboBox_audio_synthesis_type.setItemText(0, _translate("MainWindow", "Edge-TTS"))
- self.comboBox_audio_synthesis_type.setItemText(1, _translate("MainWindow", "VITS-Fast"))
- self.comboBox_audio_synthesis_type.setItemText(2, _translate("MainWindow", "elevenlabs"))
- self.comboBox_audio_synthesis_type.setItemText(3, _translate("MainWindow", "genshinvoice_top"))
- self.groupBox_chatglm.setTitle(_translate("MainWindow", "ChatGLM"))
- self.label_chatglm_api_ip_port.setText(_translate("MainWindow", "api地址"))
- self.label_chatglm_top_p.setText(_translate("MainWindow", "前p个选择"))
- self.label_chatglm_max_length.setText(_translate("MainWindow", "最大长度限制"))
- self.label_chatglm_temperature.setText(_translate("MainWindow", "温度"))
- self.groupBox_local_qa.setTitle(_translate("MainWindow", "本地问答"))
- self.label_local_qa_text_file_path.setText(_translate("MainWindow", "文本问答数据路径"))
- self.label_local_qa_audio_enable.setText(_translate("MainWindow", "音频匹配"))
- self.checkBox_local_qa_text_enable.setText(_translate("MainWindow", "启用"))
- self.label_local_qa_text_enable.setText(_translate("MainWindow", "文本匹配"))
- self.label_local_qa_audio_file_path.setText(_translate("MainWindow", "音频存储路径"))
- self.checkBox_local_qa_audio_enable.setText(_translate("MainWindow", "启用"))
+ self.label_read_user_name.setText(_translate("MainWindow", "念用户名"))
+ self.checkBox_read_user_name.setText(_translate("MainWindow", "启用"))
self.groupBox_chat_with_file.setTitle(_translate("MainWindow", "chat_with_file"))
self.label_chat_with_file_chain_type.setText(_translate("MainWindow", "链类型"))
self.label_chat_with_file_data_path.setText(_translate("MainWindow", "pdf文件路径"))
diff --git a/config.json b/config.json
index cafe63dc..e243122e 100644
--- a/config.json
+++ b/config.json
@@ -6,6 +6,7 @@
"before_prompt": "请简要回复:",
"after_prompt": "",
"commit_log_type": "回答",
+ "read_user_name": true,
"filter": {
"before_must_str": [],
"after_must_str": [],
@@ -137,7 +138,8 @@
"audio": {
"enable": true,
"file_path": "out/本地问答音频/"
- }
+ },
+ "similarity": 0.5
},
"choose_song": {
"enable": true,
diff --git a/config.json.bak b/config.json.bak
index cafe63dc..e243122e 100644
--- a/config.json.bak
+++ b/config.json.bak
@@ -6,6 +6,7 @@
"before_prompt": "请简要回复:",
"after_prompt": "",
"commit_log_type": "回答",
+ "read_user_name": true,
"filter": {
"before_must_str": [],
"after_must_str": [],
@@ -137,7 +138,8 @@
"audio": {
"enable": true,
"file_path": "out/本地问答音频/"
- }
+ },
+ "similarity": 0.5
},
"choose_song": {
"enable": true,
diff --git a/main.py b/main.py
index fe09637b..f17ecd7e 100644
--- a/main.py
+++ b/main.py
@@ -257,6 +257,7 @@ def init_config(self):
self.ui.label_before_prompt.setToolTip("提示词前缀,会自带追加在弹幕前,主要用于追加一些特殊的限制")
self.ui.label_after_prompt.setToolTip("提示词后缀,会自带追加在弹幕后,主要用于追加一些特殊的限制")
self.ui.label_commit_log_type.setToolTip("弹幕日志类型,用于记录弹幕触发时记录的内容,默认只记录回答,降低当用户使用弹幕日志显示在直播间时,因为用户的不良弹幕造成直播间被封禁问题")
+ self.ui.label_read_user_name.setToolTip("是否启用回复用户弹幕时,念用户的昵称,例:回复xxx。你好")
self.ui.label_captions_enable.setToolTip("是否启用字幕日志记录,字幕输出内容为当前合成播放的音频的文本")
self.ui.label_captions_file_path.setToolTip("字幕日志存储路径")
@@ -266,6 +267,7 @@ def init_config(self):
self.ui.label_local_qa_text_file_path.setToolTip("本地问答文本数据存储路径")
self.ui.label_local_qa_audio_enable.setToolTip("是否启用本地问答音频匹配,部分命中音频文件名后,直接播放对应的音频文件")
self.ui.label_local_qa_audio_file_path.setToolTip("本地问答音频文件存储路径")
+ self.ui.label_local_qa_similarity.setToolTip("最低文本匹配相似度,就是说用户发送的内容和本地问答库中设定的内容的最低相似度。\n低了就会被当做一般弹幕处理")
self.ui.label_filter_before_must_str.setToolTip("弹幕过滤,必须携带的触发前缀字符串(任一)\n例如:配置#,那么就需要发送:#你好")
self.ui.label_filter_after_must_str.setToolTip("弹幕过滤,必须携带的触发后缀字符串(任一)\n例如:配置。那么就需要发送:你好。")
@@ -482,12 +484,16 @@ def init_config(self):
self.ui.lineEdit_before_prompt.setText(self.before_prompt)
self.ui.lineEdit_after_prompt.setText(self.after_prompt)
+ if config.get("read_user_name"):
+ self.ui.checkBox_read_user_name.setChecked(True)
+
self.ui.comboBox_commit_log_type.clear()
commit_log_types = ["问答", "问题", "回答", "不记录"]
self.ui.comboBox_commit_log_type.addItems(commit_log_types)
commit_log_type_index = commit_log_types.index(self.commit_log_type)
self.ui.comboBox_commit_log_type.setCurrentIndex(commit_log_type_index)
+
# 日志
if self.captions_config['enable']:
self.ui.checkBox_captions_enable.setChecked(True)
@@ -500,6 +506,7 @@ def init_config(self):
if self.local_qa_config['audio']['enable']:
self.ui.checkBox_local_qa_audio_enable.setChecked(True)
self.ui.lineEdit_local_qa_audio_file_path.setText(self.local_qa_config['audio']['file_path'])
+ self.ui.lineEdit_local_qa_similarity.setText(str(self.local_qa_config['similarity']))
tmp_str = ""
for tmp in self.filter_config['before_must_str']:
@@ -964,6 +971,8 @@ def save(self):
config_data["before_prompt"] = self.ui.lineEdit_before_prompt.text()
config_data["after_prompt"] = self.ui.lineEdit_after_prompt.text()
+ config_data["read_user_name"] = self.ui.checkBox_read_user_name.isChecked()
+
need_lang = self.ui.comboBox_need_lang.currentText()
if need_lang == "所有":
config_data["need_lang"] = "none"
@@ -985,6 +994,7 @@ def save(self):
config_data["local_qa"]["text"]["file_path"] = self.ui.lineEdit_local_qa_text_file_path.text()
config_data["local_qa"]["audio"]["enable"] = self.ui.checkBox_local_qa_audio_enable.isChecked()
config_data["local_qa"]["audio"]["file_path"] = self.ui.lineEdit_local_qa_audio_file_path.text()
+ config_data["local_qa"]["similarity"] = round(float(self.ui.lineEdit_local_qa_similarity.text()), 2)
# 通用多行分隔符
separators = [" ", "\n"]
diff --git a/ui/main.ui b/ui/main.ui
index dc014af6..a1eb515e 100644
--- a/ui/main.ui
+++ b/ui/main.ui
@@ -134,9 +134,9 @@ font: 75 12pt "微软雅黑";
0
- 0
+ -501
980
- 6386
+ 6470
@@ -170,7 +170,179 @@ font: 75 12pt "微软雅黑";
0
- -
+
-
+
+
+ PointingHandCursor
+
+
-
+
+ 哔哩哔哩
+
+
+ -
+
+ 抖音
+
+
+ -
+
+ 快手
+
+
+ -
+
+ 聊天模式-谷歌
+
+
+
+
+ -
+
+
+
+
+
+ 过滤
+
+
+
-
+
+
-
+
+
+ -
+
+
+ 违禁词路径
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ 最大字符数
+
+
+
+ -
+
+
+ 弹幕后缀
+
+
+
+ -
+
+
+ -
+
+
+ 最大单词数
+
+
+
+ -
+
+
+ 弹幕前缀
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ 违禁拼音路径
+
+
+
+
+
+
+
+
+ -
+
+
+ PointingHandCursor
+
+
-
+
+ 复读机
+
+
+ -
+
+ ChatGPT
+
+
+ -
+
+ Claude
+
+
+ -
+
+ ChatGLM
+
+
+ -
+
+ chat_with_file
+
+
+ -
+
+ Chatterbot
+
+
+ -
+
+ text-generation-webui
+
+
+
+
+ -
+
+
+ PointingHandCursor
+
+
-
+
+ 所有
+
+
+ -
+
+ 中文
+
+
+ -
+
+ 英文
+
+
+ -
+
+ 日文
+
+
+
+
+ -
答谢
@@ -237,31 +409,104 @@ font: 75 12pt "微软雅黑";
- -
-
-
- PointingHandCursor
+
-
+
+
+ Live2D
-
-
-
- 所有
-
-
- -
-
- 中文
-
-
- -
-
- 英文
-
-
- -
-
- 日文
-
-
+
+ -
+
+
-
+
+
+ 是
+
+
+
+ -
+
+
+ -
+
+
+ 端口
+
+
+
+ -
+
+
+ 启用
+
+
+
+ -
+
+
+ 模型名
+
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+ ChatGLM
+
+
+
-
+
+
-
+
+
+ api地址
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ 前p个选择
+
+
+
+ -
+
+
+ 最大长度限制
+
+
+
+ -
+
+
+ 温度
+
+
+
+ -
+
+
+
+
+
-
@@ -271,31 +516,11 @@ font: 75 12pt "微软雅黑";
- -
-
-
- PointingHandCursor
+
-
+
+
+ 回复语言
-
-
-
- 哔哩哔哩
-
-
- -
-
- 抖音
-
-
- -
-
- 快手
-
-
- -
-
- 聊天模式-谷歌
-
-
-
@@ -305,8 +530,41 @@ font: 75 12pt "微软雅黑";
- -
-
+
-
+
+
+ -
+
+
+ Claude
+
+
+
-
+
+
+ -
+
+
-
+
+
+ slack_user_token
+
+
+
+
+
+ -
+
+
+ bot_user_id
+
+
+
+ -
+
+
+
+
-
@@ -315,7 +573,17 @@ font: 75 12pt "微软雅黑";
- -
+
-
+
+
+ true
+
+
+ 平台
+
+
+
+ -
日志
@@ -383,41 +651,8 @@ font: 75 12pt "微软雅黑";
- -
-
-
- openai
-
-
-
-
-
-
- 2
-
-
-
-
-
- API
-
-
-
- -
-
-
- -
-
-
- API KEY
-
-
-
- -
-
-
-
-
-
-
+ -
+
-
@@ -426,173 +661,151 @@ font: 75 12pt "微软雅黑";
- -
-
+
-
+
+
+ PointingHandCursor
+
+
-
+
+ Edge-TTS
+
+
+ -
+
+ VITS-Fast
+
+
+ -
+
+ elevenlabs
+
+
+ -
+
+ genshinvoice_top
+
+
+
+
+ -
+
+
+ -
+
- Live2D
+ 本地问答
-
+
-
-
-
-
-
+
+
-
+
- 是
+ 文本问答数据路径
+ -
+
+
-
-
+
- -
-
+
-
+
- 端口
+ 音频匹配
-
-
+
- 启用
+ 文本匹配
- -
-
+
-
+
- 模型名
+ 音频存储路径
- -
-
-
-
-
-
-
-
- -
-
-
-
-
-
- 过滤
-
-
-
-
-
-
-
-
- -
-
-
- 违禁词路径
-
-
-
- -
-
-
- -
-
-
- -
-
+
- 最大字符数
+ 启用
- -
-
+
-
+
- 弹幕后缀
+ 启用
- -
-
-
-
-
-
- 最大单词数
-
-
-
- -
-
+
- 弹幕前缀
+ 最低相似度
- -
-
-
- -
-
-
- -
-
-
- 违禁拼音路径
-
-
+
-
+
- -
-
+
-
+
+
+ 提示词后缀
+
+
+
+ -
+
- Claude
+ openai
-
-
-
-
-
+
-
-
+
+
+ 2
+
-
-
+
- slack_user_token
+ API
+
+
+
+ -
+
+
+ -
+
+
+ API KEY
+ -
+
+
- -
-
-
- bot_user_id
-
-
-
- -
-
-
- -
-
-
- true
-
-
- 平台
-
-
-
- -
+
-
chatgpt
@@ -771,207 +984,18 @@ font: 75 12pt "微软雅黑";
- -
-
-
- -
-
+
-
+
- 回复语言
-
-
-
- -
-
-
- -
-
-
- PointingHandCursor
+ 念用户名
-
-
-
- 复读机
-
-
- -
-
- ChatGPT
-
-
- -
-
- Claude
-
-
- -
-
- ChatGLM
-
-
- -
-
- chat_with_file
-
-
- -
-
- Chatterbot
-
-
- -
-
- text-generation-webui
-
-
- -
-
+
-
+
- 提示词后缀
-
-
-
- -
-
-
- PointingHandCursor
-
-
-
-
- Edge-TTS
-
-
- -
-
- VITS-Fast
-
-
- -
-
- elevenlabs
-
-
- -
-
- genshinvoice_top
-
-
-
-
- -
-
-
- ChatGLM
-
-
-
-
-
-
-
-
-
- api地址
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- 前p个选择
-
-
-
- -
-
-
- 最大长度限制
-
-
-
- -
-
-
- 温度
-
-
-
- -
-
-
-
-
-
-
-
- -
-
-
- 本地问答
+ 启用
-
-
-
-
-
-
-
-
- 文本问答数据路径
-
-
-
- -
-
-
- 音频匹配
-
-
-
- -
-
-
- 启用
-
-
-
- -
-
-
- 文本匹配
-
-
-
- -
-
-
- -
-
-
- 音频存储路径
-
-
-
- -
-
-
- 启用
-
-
-
- -
-
-
-
-
-
@@ -1941,8 +1965,8 @@ p, li { white-space: pre-wrap; }
0
- -206
- 963
+ 0
+ 749
1181
@@ -2341,7 +2365,7 @@ p, li { white-space: pre-wrap; }
0
0
- 963
+ 328
919
diff --git a/utils/audio.py b/utils/audio.py
index 23d4096f..dd64faf7 100644
--- a/utils/audio.py
+++ b/utils/audio.py
@@ -79,7 +79,16 @@ def search_files(self, root_dir, target_file):
# 获取本地音频文件夹内所有的音频文件名
- def get_dir_audios_filename(self, audio_path):
+ def get_dir_audios_filename(self, audio_path, type=0):
+ """获取本地音频文件夹内所有的音频文件名
+
+ Args:
+ audio_path (str): 音频文件路径
+ type (int, 可选): 区分返回内容,0返回完整文件名,1返回文件名不含拓展名. 默认是0
+
+ Returns:
+ list: 文件名列表
+ """
try:
# 使用 os.walk 遍历文件夹及其子文件夹
audio_files = []
@@ -88,10 +97,15 @@ def get_dir_audios_filename(self, audio_path):
if file.endswith(('.mp3', '.wav', '.flac', '.aac', '.ogg', '.m4a')):
audio_files.append(os.path.join(root, file))
- # 提取文件名
- file_names = [os.path.basename(file) for file in audio_files]
- # 保留子文件夹路径
- # file_names = [os.path.relpath(file, audio_path) for file in audio_files]
+ # 提取文件名或保留完整文件名
+ if type == 1:
+ # 只返回文件名不含拓展名
+ file_names = [os.path.splitext(os.path.basename(file))[0] for file in audio_files]
+ else:
+ # 返回完整文件名
+ file_names = [os.path.basename(file) for file in audio_files]
+ # 保留子文件夹路径
+ # file_names = [os.path.relpath(file, audio_path) for file in audio_files]
logging.info("获取到本地音频文件名列表如下:")
logging.info(file_names)
@@ -274,6 +288,7 @@ def audio_synthesis(self, message):
self.voice_tmp_path_queue.put(data_json)
return
+ # 是否为本地问答音频
elif message['type'] == "local_qa_audio":
# 拼接json数据,存入队列
data_json = {
@@ -281,9 +296,19 @@ def audio_synthesis(self, message):
"content": message["content"]
}
+ # 由于线程是独立的,所以回复音频的合成会慢于本地音频直接播放,所以以倒述的形式回复
+ message['content'] = f"以上内容回复{message['user_name']}。"
+ message['type'] = "commit"
+ self.message_queue.put(message)
self.voice_tmp_path_queue.put(data_json)
return
+ # 只有信息类型是 弹幕,才会进行念用户名
+ if message['type'] == "commit":
+ # 回复时是否念用户名字
+ if self.config.get("read_user_name"):
+ message['content'] = f"回复{message['user_name']}。{message['content']}"
+
# 中文语句切分
sentences = self.common.split_sentences(message['content'])
for s in sentences:
@@ -332,7 +357,7 @@ async def voice_change_and_put_to_queue(voice_tmp_path):
self.voice_tmp_path_queue.put(data_json)
# 区分TTS类型
- if message["type"] == "vits":
+ if message["tts_type"] == "vits":
try:
# 语言检测
language = self.common.lang_check(message["content"])
@@ -366,7 +391,7 @@ async def voice_change_and_put_to_queue(voice_tmp_path):
except Exception as e:
logging.error(e)
return
- elif message["type"] == "edge-tts":
+ elif message["tts_type"] == "edge-tts":
try:
voice_tmp_path = './out/' + self.common.get_bj_time(4) + '.mp3'
# 过滤" '字符
@@ -380,7 +405,7 @@ async def voice_change_and_put_to_queue(voice_tmp_path):
await voice_change_and_put_to_queue(voice_tmp_path)
except Exception as e:
logging.error(e)
- elif message["type"] == "elevenlabs":
+ elif message["tts_type"] == "elevenlabs":
try:
# 如果配置了密钥就设置上0.0
if message["data"]["elevenlabs_api_key"] != "":
@@ -396,7 +421,7 @@ async def voice_change_and_put_to_queue(voice_tmp_path):
except Exception as e:
logging.error(e)
return
- elif message["type"] == "genshinvoice_top":
+ elif message["tts_type"] == "genshinvoice_top":
try:
voice_tmp_path = await self.genshinvoice_top_api(message["content"])
print(f"genshinvoice.top合成成功,输出到={voice_tmp_path}")
diff --git a/utils/common.py b/utils/common.py
index bce51fc7..2df72f5a 100644
--- a/utils/common.py
+++ b/utils/common.py
@@ -242,12 +242,13 @@ def split_sentences(self, text):
# 字符串匹配算法来计算字符串之间的相似度,并选择匹配度最高的字符串作为结果
- def find_best_match(self, substring, string_list):
+ def find_best_match(self, substring, string_list, similarity=0.5):
"""字符串匹配算法来计算字符串之间的相似度,并选择匹配度最高的字符串作为结果
Args:
- substring (_type_): 要搜索的子串
- string_list (_type_): 字符串列表
+ substring (str): 要搜索的子串
+ string_list (list): 字符串列表
+ similarity (float): 最低相似度
Returns:
_type_: 匹配到的字符串 或 None
@@ -257,10 +258,15 @@ def find_best_match(self, substring, string_list):
for string in string_list:
ratio = difflib.SequenceMatcher(None, substring, string).ratio()
+ # print(f"String: {string}, Ratio: {ratio}") # 添加调试语句,输出每个字符串的相似度
if ratio > best_ratio:
best_ratio = ratio
best_match = string
+ # 如果相似度不到similarity,则认为匹配不成功
+ if best_ratio < similarity:
+ return None
+
return best_match
@@ -405,4 +411,41 @@ def get_random_value(self, lower_limit, upper_limit):
lower_limit, upper_limit = upper_limit, lower_limit
random_float = round(random.uniform(lower_limit, upper_limit), 2)
- return random_float
\ No newline at end of file
+ return random_float
+
+
+ def merge_consecutive_asterisks(self, s):
+ """合并字符串末尾连续的*
+
+ Args:
+ s (str): 待处理的字符串
+
+ Returns:
+ str: 处理完后的字符串
+ """
+ # 从字符串末尾开始遍历,找到连续的*的起始索引
+ idx = len(s) - 1
+ while idx >= 0 and s[idx] == '*':
+ idx -= 1
+
+ # 如果找到了超过3个连续的*,则进行替换
+ if len(s) - 1 - idx > 3:
+ s = s[:idx + 1] + '*' + s[len(s) - 1:]
+
+ return s
+
+
+ def remove_extension_from_list(self, file_name_list):
+ """
+ 将包含多个带有拓展名的文件名的列表中的拓展名去掉,只返回文件名部分组成的新列表
+
+ Args:
+ file_name_list (list): 包含多个带有拓展名的文件名的列表
+
+ Returns:
+ list: 文件名组成的新列表
+ """
+ # 使用列表推导来处理整个列表,去掉每个文件名的拓展名
+ file_name_without_extension_list = [file_name.split('.')[0] for file_name in file_name_list]
+ return file_name_without_extension_list
+
diff --git a/utils/my_handle.py b/utils/my_handle.py
index 298bb160..e2ee68dc 100644
--- a/utils/my_handle.py
+++ b/utils/my_handle.py
@@ -201,6 +201,26 @@ def commit_handle(self, user_name, content):
Returns:
_type_: 寂寞
"""
+
+ # 合并字符串末尾连续的* 主要针对获取不到用户名的情况
+ user_name = self.common.merge_consecutive_asterisks(user_name)
+
+ """
+ 用户名也得过滤一下,防止炸弹人
+ """
+ # 含有违禁词/链接
+ if self.common.profanity_content(user_name) or self.common.check_sensitive_words2(
+ self.filter_config["badwords_path"], user_name) or \
+ self.common.is_url_check(user_name):
+ logging.warning(f"违禁词/链接:{user_name}")
+ return
+
+ # 同拼音违禁词过滤
+ if self.filter_config["bad_pinyin_path"] != "":
+ if self.common.check_sensitive_words3(self.filter_config["bad_pinyin_path"], user_name):
+ logging.warning(f"同音违禁词:{user_name}")
+ return
+
# 1、匹配本地问答库 触发后不执行后面的其他功能
if self.local_qa["text"]["enable"] == True:
# 输出当前用户发送的弹幕消息
@@ -230,7 +250,8 @@ def commit_handle(self, user_name, content):
f.write(f"[AI回复{user_name}]:{resp_content_joined}\n" + tmp_content)
message = {
- "type": self.audio_synthesis_type,
+ "type": "commit",
+ "tts_type": self.audio_synthesis_type,
"data": self.config.get(self.audio_synthesis_type),
"config": self.filter_config,
"user_name": user_name,
@@ -247,10 +268,19 @@ def commit_handle(self, user_name, content):
# 输出当前用户发送的弹幕消息
# logging.info(f"[{user_name}]: {content}")
# 获取本地问答音频库文件夹内所有的音频文件名
- self.local_qa_audio_list = self.audio.get_dir_audios_filename(self.local_qa["audio"]["file_path"])
- local_qv_audio_filename = self.common.find_best_match(content, self.local_qa_audio_list)
+ local_qa_audio_filename_list = self.audio.get_dir_audios_filename(self.local_qa["audio"]["file_path"], type=1)
+ self.local_qa_audio_list = self.audio.get_dir_audios_filename(self.local_qa["audio"]["file_path"], type=0)
+
+ # 不含拓展名做查找
+ local_qv_audio_filename = self.common.find_best_match(content, local_qa_audio_filename_list, self.local_qa["similarity"])
+
+ # print(f"local_qv_audio_filename={local_qv_audio_filename}")
+
# 找到了匹配的结果
if local_qv_audio_filename is not None:
+ # 把结果从原文件名列表中在查找一遍,补上拓展名
+ local_qv_audio_filename = self.common.find_best_match(local_qv_audio_filename, self.local_qa_audio_list, 0)
+
# 寻找对应的文件
resp_content = self.audio.search_files(self.local_qa["audio"]["file_path"], local_qv_audio_filename)
if resp_content != []:
@@ -261,6 +291,9 @@ def commit_handle(self, user_name, content):
logging.info(f"匹配到的音频路径:{resp_content}")
message = {
"type": "local_qa_audio",
+ "tts_type": self.audio_synthesis_type,
+ "data": self.config.get(self.audio_synthesis_type),
+ "config": self.filter_config,
"user_name": user_name,
"content": resp_content
}
@@ -288,7 +321,8 @@ def commit_handle(self, user_name, content):
logging.info(f"[AI回复{user_name}]:{resp_content}")
message = {
- "type": self.audio_synthesis_type,
+ "type": "commit",
+ "tts_type": self.audio_synthesis_type,
"data": self.config.get(self.audio_synthesis_type),
"config": self.filter_config,
"user_name": user_name,
@@ -311,6 +345,9 @@ def commit_handle(self, user_name, content):
logging.info(f"匹配到的音频路径:{resp_content}")
message = {
"type": "song",
+ "tts_type": self.audio_synthesis_type,
+ "data": self.config.get(self.audio_synthesis_type),
+ "config": self.filter_config,
"user_name": user_name,
"content": resp_content
}
@@ -552,7 +589,8 @@ def commit_handle(self, user_name, content):
f.write(f"[AI回复{user_name}]:\n{resp_content_joined}\n" + tmp_content)
message = {
- "type": self.audio_synthesis_type,
+ "type": "commit",
+ "tts_type": self.audio_synthesis_type,
"data": self.config.get(self.audio_synthesis_type),
"config": self.filter_config,
"user_name": user_name,
@@ -565,6 +603,9 @@ def commit_handle(self, user_name, content):
# 礼物处理
def gift_handle(self, data):
+ # 合并字符串末尾连续的* 主要针对获取不到用户名的情况
+ data['username'] = self.common.merge_consecutive_asterisks(data['username'])
+
# logging.debug(f"[{data['username']}]: {data}")
try:
@@ -578,7 +619,8 @@ def gift_handle(self, data):
resp_content = self.thanks_config["gift_copy"].format(username=data["username"], gift_name=data["gift_name"])
message = {
- "type": self.audio_synthesis_type,
+ "type": "gift",
+ "tts_type": self.audio_synthesis_type,
"data": self.config.get(self.audio_synthesis_type),
"config": self.filter_config,
"user_name": data["username"],
@@ -593,6 +635,9 @@ def gift_handle(self, data):
# 入场处理
def entrance_handle(self, data):
+ # 合并字符串末尾连续的* 主要针对获取不到用户名的情况
+ data['username'] = self.common.merge_consecutive_asterisks(data['username'])
+
# logging.debug(f"[{data['username']}]: {data['content']}")
try:
@@ -602,7 +647,8 @@ def entrance_handle(self, data):
resp_content = self.thanks_config["entrance_copy"].format(username=data["username"])
message = {
- "type": self.audio_synthesis_type,
+ "type": "entrance",
+ "tts_type": self.audio_synthesis_type,
"data": self.config.get(self.audio_synthesis_type),
"config": self.filter_config,
"user_name": data['username'],