Skip to content

Commit

Permalink
Merge pull request #17 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
补充遗漏依赖;补充打包懒人包的说明
  • Loading branch information
Ikaros-521 authored Jun 19, 2023
2 parents 68a7ce5 + 415e194 commit cd050b5
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 14 deletions.
5 changes: 3 additions & 2 deletions GUI运行点我.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
call venv\Scripts\activate
python main.py
CHCP 65001
call activate .\venv
venv\python.exe main.py
2 changes: 1 addition & 1 deletion Live2D/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<body style="width: 100% !important; height: 100% !important;">
<div id="landlord" style="width: 100% !important; height: 100% !important;">
<!-- 320*380px -->
<canvas id="live2d" class="live2d" style="width: 100% !important; height: 100% !important;"></canvas>></canvas>
<canvas id="live2d" class="live2d" style="width: 100% !important; height: 100% !important;"></canvas>>
</div>
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script src="./js/main.js"></script>
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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》
Expand Down
3 changes: 2 additions & 1 deletion chatterbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`,写入你想要训练的内容,格式如下
Expand Down
4 changes: 3 additions & 1 deletion requirements_bilibili.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ elevenlabs
PyPDF2
langchain==0.0.142
PyQt5
pyqt5-tools
pyqt5-tools
tiktoken
pyahocorasick
3 changes: 2 additions & 1 deletion requirements_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
tiktoken==0.4.0
pyahocorasick==2.0.0
4 changes: 3 additions & 1 deletion requirements_dy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ requests
websocket-client
langchain==0.0.142
PyQt5
pyqt5-tools
pyqt5-tools
tiktoken
pyahocorasick
3 changes: 2 additions & 1 deletion requirements_ks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ websocket-client-py3
langchain==0.0.142
PyQt5
pyqt5-tools
tiktoken
tiktoken
pyahocorasick
1 change: 1 addition & 0 deletions utils/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
21 changes: 15 additions & 6 deletions utils/my_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class My_handle():
audio_synthesis_type = None

log_file_path = None
commit_file_path = None


def __init__(self, config_path):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)并播放
Expand Down

0 comments on commit cd050b5

Please sign in to comment.