From 489f31217c0d9e8ba1e7347c700991f3583d9238 Mon Sep 17 00:00:00 2001 From: ikaros <327209194@qq.com> Date: Mon, 19 Jun 2023 22:33:02 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E6=95=B4=E5=90=88=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "GUI\350\277\220\350\241\214\347\202\271\346\210\221.bat" | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git "a/GUI\350\277\220\350\241\214\347\202\271\346\210\221.bat" "b/GUI\350\277\220\350\241\214\347\202\271\346\210\221.bat" index 86dcb08e..30d9e95f 100644 --- "a/GUI\350\277\220\350\241\214\347\202\271\346\210\221.bat" +++ "b/GUI\350\277\220\350\241\214\347\202\271\346\210\221.bat" @@ -1,2 +1,3 @@ -call venv\Scripts\activate -python main.py \ No newline at end of file +CHCP 65001 +call activate .\venv +venv\python.exe main.py \ No newline at end of file From a0e233b0bcd022db6c38d0d6c346ba0c2d09196b Mon Sep 17 00:00:00 2001 From: ikaros <327209194@qq.com> Date: Mon, 19 Jun 2023 22:33:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=A1=A5=E5=85=85=E9=81=97=E6=BC=8F?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Live2D/index.html | 2 +- chatterbot/README.md | 3 ++- requirements_bilibili.txt | 4 +++- requirements_common.txt | 3 ++- requirements_dy.txt | 4 +++- requirements_ks.txt | 3 ++- utils/my_handle.py | 21 +++++++++++++++------ 7 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Live2D/index.html b/Live2D/index.html index e83a75c2..292e8086 100644 --- a/Live2D/index.html +++ b/Live2D/index.html @@ -24,7 +24,7 @@
- > + >
diff --git a/chatterbot/README.md b/chatterbot/README.md index 84d1c5a9..639f8c5d 100644 --- a/chatterbot/README.md +++ b/chatterbot/README.md @@ -7,7 +7,8 @@ pip install spacy ChatterBot ``` -如果ChatterBot安装报错,请前往 https://github.com/RaSan147/ChatterBot_update 安装新版本。下载下来输入`python setup.py install`即可 +如果ChatterBot安装报错,请前往 https://github.com/RaSan147/ChatterBot_update 安装新版本。下载下来输入`python setup.py install`即可 +安装慢,可以拆开来装`pip install SQLAlchemy==1.3.24` ## 如何训练自己的AI? - 打开`data/db.txt`,写入你想要训练的内容,格式如下 diff --git a/requirements_bilibili.txt b/requirements_bilibili.txt index 54b74ba5..1988ecac 100644 --- a/requirements_bilibili.txt +++ b/requirements_bilibili.txt @@ -12,4 +12,6 @@ elevenlabs PyPDF2 langchain==0.0.142 PyQt5 -pyqt5-tools \ No newline at end of file +pyqt5-tools +tiktoken +pyahocorasick \ No newline at end of file diff --git a/requirements_common.txt b/requirements_common.txt index c3d6a647..c1d4d658 100644 --- a/requirements_common.txt +++ b/requirements_common.txt @@ -111,4 +111,5 @@ pyqt5-plugins==5.15.9.2.3 pyqt5-tools==5.15.9.3.3 qt5-applications==5.15.2.2.3 qt5-tools==5.15.2.1.3 -tiktoken==0.4.0 \ No newline at end of file +tiktoken==0.4.0 +pyahocorasick==2.0.0 \ No newline at end of file diff --git a/requirements_dy.txt b/requirements_dy.txt index 56ba48cc..d80dcae1 100644 --- a/requirements_dy.txt +++ b/requirements_dy.txt @@ -14,4 +14,6 @@ requests websocket-client langchain==0.0.142 PyQt5 -pyqt5-tools \ No newline at end of file +pyqt5-tools +tiktoken +pyahocorasick \ No newline at end of file diff --git a/requirements_ks.txt b/requirements_ks.txt index bf30210a..574f23e5 100644 --- a/requirements_ks.txt +++ b/requirements_ks.txt @@ -16,4 +16,5 @@ websocket-client-py3 langchain==0.0.142 PyQt5 pyqt5-tools -tiktoken \ No newline at end of file +tiktoken +pyahocorasick \ No newline at end of file diff --git a/utils/my_handle.py b/utils/my_handle.py index 7c937a92..2c8eb07d 100644 --- a/utils/my_handle.py +++ b/utils/my_handle.py @@ -56,6 +56,7 @@ class My_handle(): audio_synthesis_type = None log_file_path = None + commit_file_path = None def __init__(self, config_path): @@ -159,6 +160,14 @@ def __init__(self, config_path): f.write('') logging.info(f'{self.log_file_path} 日志文件已创建') + self.commit_file_path = "./log/commit-" + self.common.get_bj_time(1) + ".txt" + if os.path.isfile(self.commit_file_path): + logging.info(f'{self.commit_file_path} 弹幕文件已存在,跳过') + else: + with open(self.commit_file_path, 'w') as f: + f.write('') + logging.info(f'{self.commit_file_path} 弹幕文件已创建') + def get_room_id(self): return self.room_id @@ -254,12 +263,12 @@ def commit_handle(self, user_name, content): # logger.info("resp_content=" + resp_content) # 将 AI 回复记录到日志文件中 - # with open(self.log_file_path, "r+", encoding="utf-8") as f: - # content = f.read() - # # 将指针移到文件头部位置(此目的是为了让直播中读取日志文件时,可以一直让最新内容显示在顶部) - # f.seek(0, 0) - # # 不过这个实现方式,感觉有点低效 - # f.write(f"[AI回复{user_name}]:{resp_content}\n" + content) + with open(self.commit_file_path, "r+", encoding="utf-8") as f: + content = f.read() + # 将指针移到文件头部位置(此目的是为了让直播中读取日志文件时,可以一直让最新内容显示在顶部) + f.seek(0, 0) + # 不过这个实现方式,感觉有点低效 + f.write(f"[AI回复{user_name}]:{resp_content}\n" + content) # 音频合成(edge-tts / vits)并播放 From 415e194193eb8fe4e02fb2da2f44458d994bdce8 Mon Sep 17 00:00:00 2001 From: ikaros <327209194@qq.com> Date: Mon, 19 Jun 2023 22:54:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=89=93=E5=8C=85?= =?UTF-8?q?=E6=87=92=E4=BA=BA=E5=8C=85=E7=9A=84=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 16 ++++++++++++++++ utils/audio.py | 1 + 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 69c304d5..41e30e2f 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,22 @@ ps:依赖[golang](https://go.dev/dl/)环境,还没有的话,手动补一补[ 生成UI代码 `pyuic5 -o UI_main.py ui\main.ui` +## 打包懒人包 + +1、本地装有conda环境 +2、在本文件夹创建虚拟环境 +`conda create --prefix ./venv python=3.10` +3、安装依赖 +`venv\python.exe -m pip install -r requirements_bilibili.txt -i https://pypi.tuna.tsinghua.edu.cn/simple` +`venv\python.exe -m pip install -r requirements_dy.txt -i https://pypi.tuna.tsinghua.edu.cn/simple` +`venv\python.exe -m pip install -r requirements_ks.txt -i https://pypi.tuna.tsinghua.edu.cn/simple` +4、安装chatterbot(可选) +`venv\python.exe -m pip install spacy SQLAlchemy==1.3.24 -i https://pypi.tuna.tsinghua.edu.cn/simple` +前提是你在当前目录下有clone chatterbot的项目(自行调整路径关系) +`venv\python.exe setup.py install` +5、修改`audio.py`中`edge-tts`的调用实现 + + ## FAQ 常问问题 ### 1.openai 接口报错:《empty message》 diff --git a/utils/audio.py b/utils/audio.py index 22e98fa1..51bd0eb3 100644 --- a/utils/audio.py +++ b/utils/audio.py @@ -114,6 +114,7 @@ def my_play_voice(self, type, data, config, content): # 过滤" '字符 content = content.replace('"', '').replace("'", '').replace(" ", ',') # 使用 Edge TTS 生成回复消息的语音文件 + # 注意此处,在打包整合包时,需要改为 venv\python.exe venv\Scripts\edge-tts.exe cmd = f'edge-tts --voice {data["voice"]} --text "{content}" --write-media {voice_tmp_path} --rate={data["rate"]} --volume={data["volume"]}' subprocess.run(cmd, shell=True)