Skip to content

Commit cd050b5

Browse files
authored
Merge pull request #17 from Ikaros-521/owner
补充遗漏依赖;补充打包懒人包的说明
2 parents 68a7ce5 + 415e194 commit cd050b5

10 files changed

Lines changed: 48 additions & 14 deletions

GUI运行点我.bat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
call venv\Scripts\activate
2-
python main.py
1+
CHCP 65001
2+
call activate .\venv
3+
venv\python.exe main.py

Live2D/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<body style="width: 100% !important; height: 100% !important;">
2525
<div id="landlord" style="width: 100% !important; height: 100% !important;">
2626
<!-- 320*380px -->
27-
<canvas id="live2d" class="live2d" style="width: 100% !important; height: 100% !important;"></canvas>></canvas>
27+
<canvas id="live2d" class="live2d" style="width: 100% !important; height: 100% !important;"></canvas>>
2828
</div>
2929
<script type="text/javascript" src="./js/jquery.min.js"></script>
3030
<script src="./js/main.js"></script>

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,22 @@ ps:依赖[golang](https://go.dev/dl/)环境,还没有的话,手动补一补[
284284
生成UI代码 `pyuic5 -o UI_main.py ui\main.ui`
285285

286286

287+
## 打包懒人包
288+
289+
1、本地装有conda环境
290+
2、在本文件夹创建虚拟环境
291+
`conda create --prefix ./venv python=3.10`
292+
3、安装依赖
293+
`venv\python.exe -m pip install -r requirements_bilibili.txt -i https://pypi.tuna.tsinghua.edu.cn/simple`
294+
`venv\python.exe -m pip install -r requirements_dy.txt -i https://pypi.tuna.tsinghua.edu.cn/simple`
295+
`venv\python.exe -m pip install -r requirements_ks.txt -i https://pypi.tuna.tsinghua.edu.cn/simple`
296+
4、安装chatterbot(可选)
297+
`venv\python.exe -m pip install spacy SQLAlchemy==1.3.24 -i https://pypi.tuna.tsinghua.edu.cn/simple`
298+
前提是你在当前目录下有clone chatterbot的项目(自行调整路径关系)
299+
`venv\python.exe setup.py install`
300+
5、修改`audio.py``edge-tts`的调用实现
301+
302+
287303
## FAQ 常问问题
288304

289305
### 1.openai 接口报错:《empty message》

chatterbot/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
pip install spacy ChatterBot
88
```
99

10-
如果ChatterBot安装报错,请前往 https://github.com/RaSan147/ChatterBot_update 安装新版本。下载下来输入`python setup.py install`即可
10+
如果ChatterBot安装报错,请前往 https://github.com/RaSan147/ChatterBot_update 安装新版本。下载下来输入`python setup.py install`即可
11+
安装慢,可以拆开来装`pip install SQLAlchemy==1.3.24`
1112

1213
## 如何训练自己的AI?
1314
- 打开`data/db.txt`,写入你想要训练的内容,格式如下

requirements_bilibili.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ elevenlabs
1212
PyPDF2
1313
langchain==0.0.142
1414
PyQt5
15-
pyqt5-tools
15+
pyqt5-tools
16+
tiktoken
17+
pyahocorasick

requirements_common.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,5 @@ pyqt5-plugins==5.15.9.2.3
111111
pyqt5-tools==5.15.9.3.3
112112
qt5-applications==5.15.2.2.3
113113
qt5-tools==5.15.2.1.3
114-
tiktoken==0.4.0
114+
tiktoken==0.4.0
115+
pyahocorasick==2.0.0

requirements_dy.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ requests
1414
websocket-client
1515
langchain==0.0.142
1616
PyQt5
17-
pyqt5-tools
17+
pyqt5-tools
18+
tiktoken
19+
pyahocorasick

requirements_ks.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ websocket-client-py3
1616
langchain==0.0.142
1717
PyQt5
1818
pyqt5-tools
19-
tiktoken
19+
tiktoken
20+
pyahocorasick

utils/audio.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def my_play_voice(self, type, data, config, content):
114114
# 过滤" '字符
115115
content = content.replace('"', '').replace("'", '').replace(" ", ',')
116116
# 使用 Edge TTS 生成回复消息的语音文件
117+
# 注意此处,在打包整合包时,需要改为 venv\python.exe venv\Scripts\edge-tts.exe
117118
cmd = f'edge-tts --voice {data["voice"]} --text "{content}" --write-media {voice_tmp_path} --rate={data["rate"]} --volume={data["volume"]}'
118119
subprocess.run(cmd, shell=True)
119120

utils/my_handle.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class My_handle():
5656
audio_synthesis_type = None
5757

5858
log_file_path = None
59+
commit_file_path = None
5960

6061

6162
def __init__(self, config_path):
@@ -159,6 +160,14 @@ def __init__(self, config_path):
159160
f.write('')
160161
logging.info(f'{self.log_file_path} 日志文件已创建')
161162

163+
self.commit_file_path = "./log/commit-" + self.common.get_bj_time(1) + ".txt"
164+
if os.path.isfile(self.commit_file_path):
165+
logging.info(f'{self.commit_file_path} 弹幕文件已存在,跳过')
166+
else:
167+
with open(self.commit_file_path, 'w') as f:
168+
f.write('')
169+
logging.info(f'{self.commit_file_path} 弹幕文件已创建')
170+
162171

163172
def get_room_id(self):
164173
return self.room_id
@@ -254,12 +263,12 @@ def commit_handle(self, user_name, content):
254263
# logger.info("resp_content=" + resp_content)
255264

256265
# 将 AI 回复记录到日志文件中
257-
# with open(self.log_file_path, "r+", encoding="utf-8") as f:
258-
# content = f.read()
259-
# # 将指针移到文件头部位置(此目的是为了让直播中读取日志文件时,可以一直让最新内容显示在顶部)
260-
# f.seek(0, 0)
261-
# # 不过这个实现方式,感觉有点低效
262-
# f.write(f"[AI回复{user_name}]:{resp_content}\n" + content)
266+
with open(self.commit_file_path, "r+", encoding="utf-8") as f:
267+
content = f.read()
268+
# 将指针移到文件头部位置(此目的是为了让直播中读取日志文件时,可以一直让最新内容显示在顶部)
269+
f.seek(0, 0)
270+
# 不过这个实现方式,感觉有点低效
271+
f.write(f"[AI回复{user_name}]:{resp_content}\n" + content)
263272

264273

265274
# 音频合成(edge-tts / vits)并播放

0 commit comments

Comments
 (0)