diff --git a/Live2D/js/model_name.js b/Live2D/js/model_name.js index 511c6730..0769a86b 100644 --- a/Live2D/js/model_name.js +++ b/Live2D/js/model_name.js @@ -1 +1 @@ -var model_name = "Hiyori"; \ No newline at end of file +var model_name = "haru2"; \ No newline at end of file diff --git a/Live2D/live2d-model/sizuku/ReadMe.txt b/Live2D/live2d-model/shizuku/ReadMe.txt similarity index 100% rename from Live2D/live2d-model/sizuku/ReadMe.txt rename to Live2D/live2d-model/shizuku/ReadMe.txt diff --git a/Live2D/live2d-model/sizuku/motion/01.motion3.json b/Live2D/live2d-model/shizuku/motion/01.motion3.json similarity index 100% rename from Live2D/live2d-model/sizuku/motion/01.motion3.json rename to Live2D/live2d-model/shizuku/motion/01.motion3.json diff --git a/Live2D/live2d-model/sizuku/motion/02.motion3.json b/Live2D/live2d-model/shizuku/motion/02.motion3.json similarity index 100% rename from Live2D/live2d-model/sizuku/motion/02.motion3.json rename to Live2D/live2d-model/shizuku/motion/02.motion3.json diff --git a/Live2D/live2d-model/sizuku/motion/03.motion3.json b/Live2D/live2d-model/shizuku/motion/03.motion3.json similarity index 100% rename from Live2D/live2d-model/sizuku/motion/03.motion3.json rename to Live2D/live2d-model/shizuku/motion/03.motion3.json diff --git a/Live2D/live2d-model/sizuku/motion/04.motion3.json b/Live2D/live2d-model/shizuku/motion/04.motion3.json similarity index 100% rename from Live2D/live2d-model/sizuku/motion/04.motion3.json rename to Live2D/live2d-model/shizuku/motion/04.motion3.json diff --git a/Live2D/live2d-model/sizuku/shizuku.1024/texture_00.png b/Live2D/live2d-model/shizuku/shizuku.1024/texture_00.png similarity index 100% rename from Live2D/live2d-model/sizuku/shizuku.1024/texture_00.png rename to Live2D/live2d-model/shizuku/shizuku.1024/texture_00.png diff --git a/Live2D/live2d-model/sizuku/shizuku.1024/texture_01.png b/Live2D/live2d-model/shizuku/shizuku.1024/texture_01.png similarity index 100% rename from Live2D/live2d-model/sizuku/shizuku.1024/texture_01.png rename to Live2D/live2d-model/shizuku/shizuku.1024/texture_01.png diff --git a/Live2D/live2d-model/sizuku/shizuku.1024/texture_02.png b/Live2D/live2d-model/shizuku/shizuku.1024/texture_02.png similarity index 100% rename from Live2D/live2d-model/sizuku/shizuku.1024/texture_02.png rename to Live2D/live2d-model/shizuku/shizuku.1024/texture_02.png diff --git a/Live2D/live2d-model/sizuku/shizuku.1024/texture_03.png b/Live2D/live2d-model/shizuku/shizuku.1024/texture_03.png similarity index 100% rename from Live2D/live2d-model/sizuku/shizuku.1024/texture_03.png rename to Live2D/live2d-model/shizuku/shizuku.1024/texture_03.png diff --git a/Live2D/live2d-model/sizuku/shizuku.1024/texture_04.png b/Live2D/live2d-model/shizuku/shizuku.1024/texture_04.png similarity index 100% rename from Live2D/live2d-model/sizuku/shizuku.1024/texture_04.png rename to Live2D/live2d-model/shizuku/shizuku.1024/texture_04.png diff --git a/Live2D/live2d-model/sizuku/shizuku.cdi3.json b/Live2D/live2d-model/shizuku/shizuku.cdi3.json similarity index 100% rename from Live2D/live2d-model/sizuku/shizuku.cdi3.json rename to Live2D/live2d-model/shizuku/shizuku.cdi3.json diff --git a/Live2D/live2d-model/sizuku/shizuku.moc3 b/Live2D/live2d-model/shizuku/shizuku.moc3 similarity index 100% rename from Live2D/live2d-model/sizuku/shizuku.moc3 rename to Live2D/live2d-model/shizuku/shizuku.moc3 diff --git a/Live2D/live2d-model/sizuku/shizuku.model3.json b/Live2D/live2d-model/shizuku/shizuku.model3.json similarity index 100% rename from Live2D/live2d-model/sizuku/shizuku.model3.json rename to Live2D/live2d-model/shizuku/shizuku.model3.json diff --git a/Live2D/live2d-model/sizuku/shizuku.physics3.json b/Live2D/live2d-model/shizuku/shizuku.physics3.json similarity index 100% rename from Live2D/live2d-model/sizuku/shizuku.physics3.json rename to Live2D/live2d-model/shizuku/shizuku.physics3.json diff --git a/Live2D/live2d-model/sizuku/shizuku.pose3.json b/Live2D/live2d-model/shizuku/shizuku.pose3.json similarity index 100% rename from Live2D/live2d-model/sizuku/shizuku.pose3.json rename to Live2D/live2d-model/shizuku/shizuku.pose3.json diff --git a/Live2D/live2d-model/sizuku/shizuku_t01.can3 b/Live2D/live2d-model/shizuku/shizuku_t01.can3 similarity index 100% rename from Live2D/live2d-model/sizuku/shizuku_t01.can3 rename to Live2D/live2d-model/shizuku/shizuku_t01.can3 diff --git a/Live2D/live2d-model/sizuku/shizuku_t02.cmo3 b/Live2D/live2d-model/shizuku/shizuku_t02.cmo3 similarity index 100% rename from Live2D/live2d-model/sizuku/shizuku_t02.cmo3 rename to Live2D/live2d-model/shizuku/shizuku_t02.cmo3 diff --git a/README.md b/README.md index 7dfa0eac..33ce82df 100644 --- a/README.md +++ b/README.md @@ -743,17 +743,25 @@ if __name__ == '__main__': ## 待办事项 - [ ] 懒人包优化 +- [ ] 接入更多的LLM(科大讯飞、new bing等) +- [ ] 接入更多的TTS方案 +- [ ] RVC的接入 - [ ] 快手平台的重新兼容 -- [ ] 其他直播平台的适配 -- [ ] live2d的嘴型匹配 +- [ ] 其他直播平台的适配(tiktok、YouTube、拼多多等) +- [ ] live2d的嘴型、动作匹配 - [ ] 接入更多的2/3D模型软件 - [ ] 屏蔽词升级。如:可以根据屏蔽词库转拼音的二重屏蔽;接入第三方屏蔽词API等 -- [ ] 本机语音直接交流模式 +- [ ] 本机语音直接交流模式(本地版本whisper,其他方式) - [ ] 本地的用户拉黑机制 - [ ] 礼物互动机制(跳舞,唱歌) +- [ ] 用户入场、投食感谢(自定义 文案) - [ ] 弹幕跳过机制 - [ ] 点歌后的弹幕触发问题(如:只取最新的几个) -- [ ] 接入new bing +- [ ] 弹幕丢失bug修复(很可能是线程sleep造成的) +- [ ] wav2lip方案尝试(带货方面) +- [ ] 直播中可以由弹幕进行动态换装 +- [ ] TTS合成时,语句切分算法有待优化 +- [ ] 压力测试 ## 📝 更新日志 @@ -867,6 +875,7 @@ if __name__ == '__main__': ### 2023-07-10 - GUI可以检索Live2D路径下的模型进行动态修改配置。(需要注意,修改后浏览器缓存问题,请用无痕浏览器打开) - 追加 Live2D官网所有的免费模型 +- 新增 答谢功能(入场欢迎、礼物答谢),暂时只支持B站,GUI同步进行配置。 diff --git a/UI_main.py b/UI_main.py index d8533182..d56840ca 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, -604, 980, 5062)) + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -408, 980, 5327)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout.setContentsMargins(35, 20, 35, 20) @@ -97,6 +97,46 @@ def setupUi(self, MainWindow): self.gridLayout = QtWidgets.QGridLayout(self.formWidget) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setObjectName("gridLayout") + 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.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_live2d = QtWidgets.QGroupBox(self.formWidget) + self.groupBox_live2d.setObjectName("groupBox_live2d") + self.gridLayout_30 = QtWidgets.QGridLayout(self.groupBox_live2d) + self.gridLayout_30.setObjectName("gridLayout_30") + self.gridLayout_29 = QtWidgets.QGridLayout() + self.gridLayout_29.setObjectName("gridLayout_29") + self.checkBox_live2d_enable = QtWidgets.QCheckBox(self.groupBox_live2d) + self.checkBox_live2d_enable.setObjectName("checkBox_live2d_enable") + self.gridLayout_29.addWidget(self.checkBox_live2d_enable, 0, 1, 1, 1) + self.lineEdit_live2d_port = QtWidgets.QLineEdit(self.groupBox_live2d) + self.lineEdit_live2d_port.setObjectName("lineEdit_live2d_port") + self.gridLayout_29.addWidget(self.lineEdit_live2d_port, 1, 1, 1, 1) + self.label_live2d_port = QtWidgets.QLabel(self.groupBox_live2d) + self.label_live2d_port.setObjectName("label_live2d_port") + self.gridLayout_29.addWidget(self.label_live2d_port, 1, 0, 1, 1) + self.label_live2d_enable = QtWidgets.QLabel(self.groupBox_live2d) + self.label_live2d_enable.setObjectName("label_live2d_enable") + self.gridLayout_29.addWidget(self.label_live2d_enable, 0, 0, 1, 1) + self.label_live2d_name = QtWidgets.QLabel(self.groupBox_live2d) + self.label_live2d_name.setObjectName("label_live2d_name") + self.gridLayout_29.addWidget(self.label_live2d_name, 2, 0, 1, 1) + self.comboBox_live2d_name = QtWidgets.QComboBox(self.groupBox_live2d) + self.comboBox_live2d_name.setObjectName("comboBox_live2d_name") + self.gridLayout_29.addWidget(self.comboBox_live2d_name, 2, 1, 1, 1) + 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, 14, 0, 1, 3) + 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) @@ -116,88 +156,7 @@ 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, 16, 0, 1, 3) - 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_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, 13, 0, 1, 3) - 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_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_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.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.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.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, 17, 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_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.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.gridLayout.addWidget(self.groupBox_claude, 18, 0, 1, 3) self.groupBox = QtWidgets.QGroupBox(self.formWidget) self.groupBox.setStyleSheet("") self.groupBox.setObjectName("groupBox") @@ -236,7 +195,57 @@ def setupUi(self, MainWindow): 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.gridLayout_26.addLayout(self.gridLayout_25, 0, 0, 1, 1) - self.gridLayout.addWidget(self.groupBox, 11, 0, 1, 3) + self.gridLayout.addWidget(self.groupBox, 12, 0, 1, 3) + self.comboBox_commit_log_type = QtWidgets.QComboBox(self.formWidget) + 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.addWidget(self.comboBox_commit_log_type, 6, 1, 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_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.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, 19, 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") @@ -248,9 +257,37 @@ def setupUi(self, MainWindow): self.comboBox_chat_type.addItem("") self.comboBox_chat_type.addItem("") self.gridLayout.addWidget(self.comboBox_chat_type, 2, 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.gridLayout.addWidget(self.comboBox_audio_synthesis_type, 10, 1, 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, 15, 0, 1, 3) + self.label_commit_log_type = QtWidgets.QLabel(self.formWidget) + self.label_commit_log_type.setObjectName("label_commit_log_type") + self.gridLayout.addWidget(self.label_commit_log_type, 6, 0, 1, 1) self.groupBox_chatgpt = QtWidgets.QGroupBox(self.formWidget) self.groupBox_chatgpt.setObjectName("groupBox_chatgpt") self.gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_chatgpt) @@ -319,7 +356,10 @@ 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, 14, 0, 2, 3) + self.gridLayout.addWidget(self.groupBox_chatgpt, 16, 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.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") @@ -328,59 +368,54 @@ def setupUi(self, MainWindow): self.comboBox_need_lang.addItem("") self.comboBox_need_lang.addItem("") self.gridLayout.addWidget(self.comboBox_need_lang, 3, 1, 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.gridLayout.addWidget(self.comboBox_audio_synthesis_type, 10, 1, 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.groupBox_live2d = QtWidgets.QGroupBox(self.formWidget) - self.groupBox_live2d.setObjectName("groupBox_live2d") - self.gridLayout_30 = QtWidgets.QGridLayout(self.groupBox_live2d) - self.gridLayout_30.setObjectName("gridLayout_30") - self.gridLayout_29 = QtWidgets.QGridLayout() - self.gridLayout_29.setObjectName("gridLayout_29") - self.checkBox_live2d_enable = QtWidgets.QCheckBox(self.groupBox_live2d) - self.checkBox_live2d_enable.setObjectName("checkBox_live2d_enable") - self.gridLayout_29.addWidget(self.checkBox_live2d_enable, 0, 1, 1, 1) - self.lineEdit_live2d_port = QtWidgets.QLineEdit(self.groupBox_live2d) - self.lineEdit_live2d_port.setObjectName("lineEdit_live2d_port") - self.gridLayout_29.addWidget(self.lineEdit_live2d_port, 1, 1, 1, 1) - self.label_live2d_port = QtWidgets.QLabel(self.groupBox_live2d) - self.label_live2d_port.setObjectName("label_live2d_port") - self.gridLayout_29.addWidget(self.label_live2d_port, 1, 0, 1, 1) - self.label_live2d_enable = QtWidgets.QLabel(self.groupBox_live2d) - self.label_live2d_enable.setObjectName("label_live2d_enable") - self.gridLayout_29.addWidget(self.label_live2d_enable, 0, 0, 1, 1) - self.label_live2d_name = QtWidgets.QLabel(self.groupBox_live2d) - self.label_live2d_name.setObjectName("label_live2d_name") - self.gridLayout_29.addWidget(self.label_live2d_name, 2, 0, 1, 1) - self.comboBox_live2d_name = QtWidgets.QComboBox(self.groupBox_live2d) - self.comboBox_live2d_name.setObjectName("comboBox_live2d_name") - self.gridLayout_29.addWidget(self.comboBox_live2d_name, 2, 1, 1, 1) - 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, 12, 0, 1, 3) - self.label_commit_log_type = QtWidgets.QLabel(self.formWidget) - self.label_commit_log_type.setObjectName("label_commit_log_type") - self.gridLayout.addWidget(self.label_commit_log_type, 6, 0, 1, 1) - self.comboBox_commit_log_type = QtWidgets.QComboBox(self.formWidget) - 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.addWidget(self.comboBox_commit_log_type, 6, 1, 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_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.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_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_thanks = QtWidgets.QGroupBox(self.formWidget) + self.groupBox_thanks.setObjectName("groupBox_thanks") + self.gridLayout_42 = QtWidgets.QGridLayout(self.groupBox_thanks) + self.gridLayout_42.setObjectName("gridLayout_42") + self.label_thanks_entrance_copy = QtWidgets.QLabel(self.groupBox_thanks) + self.label_thanks_entrance_copy.setObjectName("label_thanks_entrance_copy") + self.gridLayout_42.addWidget(self.label_thanks_entrance_copy, 2, 0, 1, 1) + self.label_thanks_gift_copy = QtWidgets.QLabel(self.groupBox_thanks) + self.label_thanks_gift_copy.setObjectName("label_thanks_gift_copy") + self.gridLayout_42.addWidget(self.label_thanks_gift_copy, 3, 0, 1, 1) + self.label_thanks_lowest_price = QtWidgets.QLabel(self.groupBox_thanks) + self.label_thanks_lowest_price.setObjectName("label_thanks_lowest_price") + self.gridLayout_42.addWidget(self.label_thanks_lowest_price, 4, 0, 1, 1) + self.lineEdit_thanks_entrance_copy = QtWidgets.QLineEdit(self.groupBox_thanks) + self.lineEdit_thanks_entrance_copy.setObjectName("lineEdit_thanks_entrance_copy") + self.gridLayout_42.addWidget(self.lineEdit_thanks_entrance_copy, 2, 1, 1, 1) + self.checkBox_thanks_entrance_enable = QtWidgets.QCheckBox(self.groupBox_thanks) + self.checkBox_thanks_entrance_enable.setObjectName("checkBox_thanks_entrance_enable") + self.gridLayout_42.addWidget(self.checkBox_thanks_entrance_enable, 0, 1, 1, 1) + self.lineEdit_thanks_lowest_price = QtWidgets.QLineEdit(self.groupBox_thanks) + self.lineEdit_thanks_lowest_price.setObjectName("lineEdit_thanks_lowest_price") + self.gridLayout_42.addWidget(self.lineEdit_thanks_lowest_price, 4, 1, 1, 1) + self.lineEdit_thanks_gift_copy = QtWidgets.QLineEdit(self.groupBox_thanks) + self.lineEdit_thanks_gift_copy.setObjectName("lineEdit_thanks_gift_copy") + self.gridLayout_42.addWidget(self.lineEdit_thanks_gift_copy, 3, 1, 1, 1) + self.label_thanks_entrance_enable = QtWidgets.QLabel(self.groupBox_thanks) + self.label_thanks_entrance_enable.setObjectName("label_thanks_entrance_enable") + self.gridLayout_42.addWidget(self.label_thanks_entrance_enable, 0, 0, 1, 1) + self.label_thanks_gift_enable = QtWidgets.QLabel(self.groupBox_thanks) + self.label_thanks_gift_enable.setObjectName("label_thanks_gift_enable") + self.gridLayout_42.addWidget(self.label_thanks_gift_enable, 1, 0, 1, 1) + 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, 13, 0, 1, 3) self.verticalLayout.addWidget(self.formWidget) self.groupBox_chat_with_file = QtWidgets.QGroupBox(self.scrollAreaWidgetContents) self.groupBox_chat_with_file.setObjectName("groupBox_chat_with_file") @@ -841,7 +876,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, 0, 712, 1072)) + self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 963, 1072)) self.scrollAreaWidgetContents_2.setObjectName("scrollAreaWidgetContents_2") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_2) self.verticalLayout_2.setObjectName("verticalLayout_2") @@ -1001,7 +1036,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, 328, 314)) + self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 984, 743)) self.scrollAreaWidgetContents_3.setObjectName("scrollAreaWidgetContents_3") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_3) self.verticalLayout_3.setObjectName("verticalLayout_3") @@ -1102,29 +1137,37 @@ def retranslateUi(self, MainWindow): self.pushButton_run.setText(_translate("MainWindow", "运行")) self.pushButton_config_page.setText(_translate("MainWindow", "①配置页")) self.pushButton_save.setText(_translate("MainWindow", "保存配置")) + self.label_after_prompt.setText(_translate("MainWindow", "提示词后缀")) + self.label_before_prompt.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.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.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_need_lang.setText(_translate("MainWindow", "回复语言")) - self.label_platform.setText(_translate("MainWindow", "平台")) - self.label_after_prompt.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.label_room_display_id.setText(_translate("MainWindow", "直播间号")) - self.label_before_prompt.setText(_translate("MainWindow", "提示词前缀")) self.groupBox.setTitle(_translate("MainWindow", "过滤")) self.label_filter_max_char_len.setText(_translate("MainWindow", "最大字符数")) self.label_filter_badwords_path.setText(_translate("MainWindow", "违禁词路径")) self.label_filter_max_len.setText(_translate("MainWindow", "最大单词数")) self.label_filter_before_must_str.setText(_translate("MainWindow", "弹幕前缀")) self.label_filter_after_must_str.setText(_translate("MainWindow", "弹幕后缀")) + self.comboBox_commit_log_type.setItemText(0, _translate("MainWindow", "问答")) + self.comboBox_commit_log_type.setItemText(1, _translate("MainWindow", "问题")) + self.comboBox_commit_log_type.setItemText(2, _translate("MainWindow", "回答")) + self.comboBox_commit_log_type.setItemText(3, _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_chat_type.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.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")) @@ -1132,7 +1175,13 @@ def retranslateUi(self, MainWindow): 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_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.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_commit_log_type.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", "最大令牌数")) @@ -1164,23 +1213,17 @@ def retranslateUi(self, 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.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_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_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.label_commit_log_type.setText(_translate("MainWindow", "弹幕日志类型")) - self.comboBox_commit_log_type.setItemText(0, _translate("MainWindow", "问答")) - self.comboBox_commit_log_type.setItemText(1, _translate("MainWindow", "问题")) - self.comboBox_commit_log_type.setItemText(2, _translate("MainWindow", "回答")) - self.comboBox_commit_log_type.setItemText(3, _translate("MainWindow", "不记录")) + self.label_audio_synthesis_type.setText(_translate("MainWindow", "语音合成")) + self.label_need_lang.setText(_translate("MainWindow", "回复语言")) + self.label_platform.setText(_translate("MainWindow", "平台")) + self.groupBox_thanks.setTitle(_translate("MainWindow", "答谢")) + self.label_thanks_entrance_copy.setText(_translate("MainWindow", "入场文案")) + self.label_thanks_gift_copy.setText(_translate("MainWindow", "礼物文案")) + self.label_thanks_lowest_price.setText(_translate("MainWindow", "最低答谢价格")) + self.checkBox_thanks_entrance_enable.setText(_translate("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.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/bilibili.py b/bilibili.py index c6fabe1e..7ca8b478 100644 --- a/bilibili.py +++ b/bilibili.py @@ -23,7 +23,7 @@ def start_server(): room = live.LiveDanmaku(my_handle.get_room_id()) @room.on('DANMU_MSG') - async def on_danmaku(event): + async def _(event): """ 处理直播间弹幕事件 :param event: 弹幕事件数据 @@ -33,6 +33,132 @@ async def on_danmaku(event): my_handle.commit_handle(user_name, content) + @room.on('COMBO_SEND') + async def _(event): + """ + 处理直播间礼物连击事件 + :param event: 礼物连击事件数据 + """ + + gift_name = event["data"]["data"]["gift_name"] + user_name = event["data"]["data"]["uname"] + # 礼物数量 + combo_num = event["data"]["data"]["combo_num"] + # 总金额 + combo_total_coin = event["data"]["data"]["combo_total_coin"] + + logging.info(f"用户:{user_name} 赠送 {combo_num} 个 {gift_name},总计 {combo_total_coin}电池") + + data = { + "gift_name": gift_name, + "username": user_name, + "num": combo_num, + "unit_price": combo_total_coin / combo_num / 1000, + "total_price": combo_total_coin / 1000 + } + + my_handle.gift_handle(data) + + @room.on('SEND_GIFT') + async def _(event): + """ + 处理直播间礼物事件 + :param event: 礼物事件数据 + """ + + # print(event) + + gift_name = event["data"]["data"]["giftName"] + user_name = event["data"]["data"]["uname"] + # 礼物数量 + num = event["data"]["data"]["num"] + # 总金额 + combo_total_coin = event["data"]["data"]["combo_total_coin"] + # 单个礼物金额 + discount_price = event["data"]["data"]["discount_price"] + + logging.info(f"用户:{user_name} 赠送 {num} 个 {gift_name},单价 {discount_price}电池,总计 {combo_total_coin}电池") + + data = { + "gift_name": gift_name, + "username": user_name, + "num": num, + "unit_price": discount_price / 1000, + "total_price": combo_total_coin / 1000 + } + + my_handle.gift_handle(data) + + @room.on('GUARD_BUY') + async def _(event): + """ + 处理直播间续费大航海事件 + :param event: 续费大航海事件数据 + """ + + logging.info(event) + + @room.on('SUPER_CHAT_MESSAGE') + async def _(event): + """ + 处理直播间醒目留言(SC)事件 + :param event: 醒目留言(SC)事件数据 + """ + message = event["data"]["data"]["message"] + uname = event["data"]["data"]["user_info"]["uname"] + price = event["data"]["data"]["price"] + + logging.info(f"用户:{uname} 发送 {price}元 SC:{message}") + + data = { + "gift_name": "SC", + "username": uname, + "num": 1, + "unit_price": price, + "total_price": price + } + + my_handle.gift_handle(data) + + my_handle.commit_handle(uname, message) + + + @room.on('INTERACT_WORD') + async def _(event): + """ + 处理直播间用户进入直播间事件 + :param event: 用户进入直播间事件数据 + """ + user_name = event["data"]["data"]["uname"] + + logging.info(f"用户:{user_name} 进入直播间") + + data = { + "username": user_name, + "content": "进入直播间" + } + + my_handle.entrance_handle(data) + + # @room.on('WELCOME') + # async def _(event): + # """ + # 处理直播间老爷进入房间事件 + # :param event: 老爷进入房间事件数据 + # """ + + # print(event) + + # @room.on('WELCOME_GUARD') + # async def _(event): + # """ + # 处理直播间房管进入房间事件 + # :param event: 房管进入房间事件数据 + # """ + + # print(event) + + try: # 启动 Bilibili 直播间连接 sync(room.connect()) diff --git a/config.json b/config.json index 919b8eab..fb524a88 100644 --- a/config.json +++ b/config.json @@ -14,6 +14,13 @@ "max_len": 80, "max_char_len": 200 }, + "thanks": { + "entrance_enable": true, + "gift_enable": true, + "entrance_copy": "欢迎 {username}", + "gift_copy": "感谢 {username} 送的 {gift_name}", + "lowest_price": 1.0 + }, "live2d": { "enable": true, "port": 12345 @@ -37,7 +44,7 @@ "max_new_tokens": 250 }, "chat_with_file": { - "chat_mode": "claude", + "chat_mode": "", "data_path": "data/伊卡洛斯百度百科.zip", "separator": "\n", "chunk_size": 100, @@ -53,7 +60,7 @@ "config_path": "D:\\GitHub_pro\\VITS-fast-fine-tuning\\inference\\finetune_speaker.json", "api_ip_port": "http://127.0.0.1:7860", "character": "ikaros", - "speed": 1.0 + "speed": 1 }, "so_vits_svc": { "enable": false, @@ -112,7 +119,7 @@ "ip": "127.0.0.1", "port": 7860, "negative_prompt": "ufsw, longbody, lowres, bad anatomy, bad hands, missing fingers, pubic hair,extra digit, fewer digits, cropped, worst quality, low quality", - "seed": -1.0, + "seed": -1, "styles": [], "cfg_scale": 7, "steps": 30, @@ -127,8 +134,8 @@ "file_path": "data/copywriting/", "audio_path": "out/copywriting/", "play_list": [], - "audio_interval": 5.0, - "switching_interval": 5.0, + "audio_interval": 5, + "switching_interval": 5, "random_play": true }, "header": { diff --git a/config.json.bak b/config.json.bak index c73eef64..fb524a88 100644 --- a/config.json.bak +++ b/config.json.bak @@ -14,6 +14,13 @@ "max_len": 80, "max_char_len": 200 }, + "thanks": { + "entrance_enable": true, + "gift_enable": true, + "entrance_copy": "欢迎 {username}", + "gift_copy": "感谢 {username} 送的 {gift_name}", + "lowest_price": 1.0 + }, "live2d": { "enable": true, "port": 12345 diff --git a/data/badwords.txt b/data/badwords.txt index 2afac81d..e12e5247 100644 --- a/data/badwords.txt +++ b/data/badwords.txt @@ -1361,7 +1361,6 @@ 黄晶 捐肾 乳尖 -西游 被插 干拎娘 潘金莲 diff --git "a/data/copywriting/\344\274\212\345\215\241\346\227\245\350\257\255\344\273\213\347\273\215.txt" "b/data/copywriting/\344\274\212\345\215\241\346\227\245\350\257\255\344\273\213\347\273\215.txt" new file mode 100644 index 00000000..b888c12a --- /dev/null +++ "b/data/copywriting/\344\274\212\345\215\241\346\227\245\350\257\255\344\273\213\347\273\215.txt" @@ -0,0 +1 @@ +こんにちは、私はAIキャスターで、私の名前はイカロスです。私の声はVITSから合成されていて、私は中国語が苦手なので、日本語で返事をしますので、気にしないでください。私の今のイメージは間違っていますが、未来は変わります。ご来店ありがとうございます。合法的なコンプライアンスであれば、私が知っている限り、私はあなたに答えることができます。 \ No newline at end of file diff --git a/main.py b/main.py index c8797c03..a2c51739 100644 --- a/main.py +++ b/main.py @@ -113,6 +113,9 @@ def init_config(self): # 过滤配置 self.filter_config = config.get("filter") + # 答谢 + self.thanks_config = config.get("thanks") + self.chat_type = config.get("chat_type") self.need_lang = config.get("need_lang") @@ -176,6 +179,12 @@ def init_config(self): self.ui.label_filter_max_len.setToolTip("最长阅读的英文单词数(空格分隔)") self.ui.label_filter_max_char_len.setToolTip("最长阅读的字符数,双重过滤,避免溢出") + self.ui.label_thanks_entrance_enable.setToolTip("是否启用欢迎用户进入直播间功能") + self.ui.label_thanks_gift_enable.setToolTip("是否启用感谢用户赠送礼物功能") + self.ui.label_thanks_entrance_copy.setToolTip("用户进入直播间的相关文案,请勿动 {username},此字符串用于替换用户名") + self.ui.label_thanks_gift_copy.setToolTip("用户赠送礼物的相关文案,请勿动 {username} 和 {gift_name},此字符串用于替换用户名和礼物名") + self.ui.label_thanks_lowest_price.setToolTip("设置最低答谢礼物的价格(元),低于这个设置的礼物不会触发答谢") + self.ui.label_live2d_enable.setToolTip("启动web服务,用于加载本地Live2D模型") self.ui.label_live2d_port.setToolTip("web服务运行的端口号,默认:12345,范围:0-65535,没事不要乱改就好") self.ui.label_live2d_name.setToolTip("模型名称,模型存放于Live2D\live2d-model路径下,请注意路径和模型内容是否匹配") @@ -367,6 +376,15 @@ def init_config(self): self.ui.lineEdit_filter_max_len.setText(str(self.filter_config['max_len'])) self.ui.lineEdit_filter_max_char_len.setText(str(self.filter_config['max_char_len'])) + # 答谢 + if self.thanks_config['entrance_enable']: + self.ui.checkBox_thanks_entrance_enable.setChecked(True) + if self.thanks_config['gift_enable']: + self.ui.checkBox_thanks_gift_enable.setChecked(True) + self.ui.lineEdit_thanks_entrance_copy.setText(self.thanks_config['entrance_copy']) + self.ui.lineEdit_thanks_gift_copy.setText(self.thanks_config['gift_copy']) + self.ui.lineEdit_thanks_lowest_price.setText(str(self.thanks_config['lowest_price'])) + if self.live2d_config['enable']: self.ui.checkBox_live2d_enable.setChecked(True) self.ui.lineEdit_live2d_port.setText(str(self.live2d_config['port'])) @@ -778,8 +796,14 @@ def save(self): max_char_len = self.ui.lineEdit_filter_max_char_len.text() config_data["filter"]["max_char_len"] = int(max_char_len) - live2d_enable = self.ui.checkBox_live2d_enable.isChecked() - config_data["live2d"]["enable"] = live2d_enable + # 答谢 + config_data["thanks"]["entrance_enable"] = self.ui.checkBox_thanks_entrance_enable.isChecked() + config_data["thanks"]["gift_enable"] = self.ui.checkBox_thanks_gift_enable.isChecked() + config_data["thanks"]["entrance_copy"] = self.ui.lineEdit_thanks_entrance_copy.text() + config_data["thanks"]["gift_copy"] = self.ui.lineEdit_thanks_gift_copy.text() + config_data["thanks"]["lowest_price"] = round(float(self.ui.lineEdit_thanks_lowest_price.text()), 2) + + config_data["live2d"]["enable"] = self.ui.checkBox_live2d_enable.isChecked() live2d_port = self.ui.lineEdit_live2d_port.text() config_data["live2d"]["port"] = int(live2d_port) tmp_str = f"var model_name = \"{self.ui.comboBox_live2d_name.currentText()}\";" diff --git "a/out/copywriting/\344\274\212\345\215\241\346\227\245\350\257\255\344\273\213\347\273\215.wav" "b/out/copywriting/\344\274\212\345\215\241\346\227\245\350\257\255\344\273\213\347\273\215.wav" new file mode 100644 index 00000000..8eba1f48 Binary files /dev/null and "b/out/copywriting/\344\274\212\345\215\241\346\227\245\350\257\255\344\273\213\347\273\215.wav" differ diff --git a/ui/main.ui b/ui/main.ui index d1b76a70..cb91e188 100644 --- a/ui/main.ui +++ b/ui/main.ui @@ -134,9 +134,9 @@ font: 75 12pt "微软雅黑"; 0 - -604 + -408 980 - 5062 + 5327 @@ -170,98 +170,6 @@ font: 75 12pt "微软雅黑"; 0 - - - - Claude - - - - - - - - - - - slack_user_token - - - - - - - - - bot_user_id - - - - - - - - - - - - - - - - openai - - - - - - 2 - - - - - API - - - - - - - - - - API KEY - - - - - - - - - - - - - - - 回复语言 - - - - - - - - - - true - - - 平台 - - - @@ -269,69 +177,60 @@ font: 75 12pt "微软雅黑"; - - + + + + 提示词前缀 + + - - + + - ChatGLM + Live2D - + - - - + + + - api地址 + - - - - - - - + - - + + - 前p个选择 + 端口 - - + + - 最大长度限制 + 启用 - - + + - 温度 + 模型名 - - + + - - - - 聊天类型 - - - @@ -339,14 +238,43 @@ font: 75 12pt "微软雅黑"; - - - - 提示词前缀 + + + + + + + Claude + + + + + + + + + + slack_user_token + + + + + + + + + bot_user_id + + + + + + + - + @@ -395,17 +323,128 @@ font: 75 12pt "微软雅黑"; - + + + 弹幕后缀 + + + + + + + + + + + + + + + + + + + 问答 + + + + + 问题 + + + + + 回答 + + + + + 不记录 + + + + + + + + PointingHandCursor + + + + 哔哩哔哩 + + + + + 抖音 + + + + + 快手 + + + + + 聊天模式-谷歌 + + + + + + + + 聊天类型 + + + + + + + ChatGLM + + + + + + + + api地址 + + + + + + + + + + + + + + + + 前p个选择 + + + + + - 弹幕后缀 + 最大长度限制 - - + + + + 温度 + + - - + + @@ -454,14 +493,72 @@ font: 75 12pt "微软雅黑"; - - + + + + PointingHandCursor + + + + Edge-TTS + + + + + VITS-Fast + + + + + elevenlabs + + + + + + + + openai + + + + + + 2 + + + + + API + + + + + + + + + + API KEY + + + + + + + + + + + + + - 语音合成 + 弹幕日志类型 - + chatgpt @@ -640,6 +737,9 @@ font: 75 12pt "微软雅黑"; + + + @@ -667,131 +767,98 @@ font: 75 12pt "微软雅黑"; - - - - PointingHandCursor - - - - Edge-TTS - - - - - VITS-Fast - - - - - elevenlabs - - - + + - - - - PointingHandCursor + + + + 语音合成 - - - 哔哩哔哩 - - - - - 抖音 - - - - - 快手 - - - - - 聊天模式-谷歌 - - - - - - Live2D + + + + 回复语言 - - - - - - - - - - - - - - - - - 端口 - - - - - - - 启用 - - - - - - - 模型名 - - - - - - - - - - - + + + + true + - 弹幕日志类型 + 平台 - - - - - 问答 - - - - - 问题 - - - - - 回答 - - - - - 不记录 - - + + + + 答谢 + + + + + + 入场文案 + + + + + + + 礼物文案 + + + + + + + 最低答谢价格 + + + + + + + + + + 启用 + + + + + + + + + + + + + 入场欢迎 + + + + + + + 礼物答谢 + + + + + + + 启用 + + + + @@ -1612,7 +1679,7 @@ p, li { white-space: pre-wrap; } 0 0 - 712 + 963 1072 @@ -1960,8 +2027,8 @@ font: 80 10pt "微软雅黑"; 0 0 - 328 - 314 + 984 + 743 diff --git a/utils/common.py b/utils/common.py index b911b7a1..bf880694 100644 --- a/utils/common.py +++ b/utils/common.py @@ -100,6 +100,7 @@ def check_sensitive_words2(self, file_path, text): # 在文本中搜索违禁词 for _, found_word in automaton.iter(text): + logging.warning(f"命中本地违禁词:{found_word}") return True return False diff --git a/utils/my_handle.py b/utils/my_handle.py index 2e8e2859..dcf0862a 100644 --- a/utils/my_handle.py +++ b/utils/my_handle.py @@ -39,6 +39,8 @@ def __init__(self, config_path): # 过滤配置 self.filter_config = self.config.get("filter") + # 答谢 + self.thanks_config = self.config.get("thanks") self.chat_type = self.config.get("chat_type") @@ -179,6 +181,15 @@ def find_answer(self, question, qa_file_path): # 弹幕处理 def commit_handle(self, user_name, content): + """弹幕处理 + + Args: + user_name (str): 用户名 + content (str): 弹幕内容 + + Returns: + _type_: 寂寞 + """ logging.debug(f"[{user_name}]: {content}") # 1、匹配本地问答库 触发后不执行后面的其他功能 @@ -487,3 +498,55 @@ def commit_handle(self, user_name, content): # 音频合成(edge-tts / vits)并播放 self.audio.audio_synthesis(message) + + + # 礼物处理 + def gift_handle(self, data): + logging.debug(f"[{data['username']}]: {data}") + + try: + if False == self.thanks_config["gift_enable"]: + return + + # 如果礼物总价低于设置的礼物感谢最低值 + if data["total_price"] < self.thanks_config["lowest_price"]: + return + + resp_content = self.thanks_config["gift_copy"].format(username=data["username"], gift_name=data["gift_name"]) + + message = { + "type": self.audio_synthesis_type, + "data": self.config.get(self.audio_synthesis_type), + "config": self.filter_config, + "user_name": data["username"], + "content": resp_content + } + + # 音频合成(edge-tts / vits)并播放 + self.audio.audio_synthesis(message) + except Exception as e: + logging.error(e) + + + # 入场处理 + def entrance_handle(self, data): + logging.debug(f"[{data['username']}]: {data['content']}") + + try: + if False == self.thanks_config["entrance_enable"]: + return + + resp_content = self.thanks_config["entrance_copy"].format(username=data["username"]) + + message = { + "type": self.audio_synthesis_type, + "data": self.config.get(self.audio_synthesis_type), + "config": self.filter_config, + "user_name": data['username'], + "content": resp_content + } + + # 音频合成(edge-tts / vits)并播放 + self.audio.audio_synthesis(message) + except Exception as e: + logging.error(e)