Skip to content

Commit

Permalink
增加GUI版;对config.json的结构做了调整
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed Jun 17, 2023
1 parent ff31566 commit 81c1991
Show file tree
Hide file tree
Showing 16 changed files with 1,039 additions and 213 deletions.
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,19 @@ douyin/config2.json
douyin/out/*.mp3
douyin/log/*.txt

# 测试文件夹
test/
game/

dev/
ui/
main.py
main.py

/data/vector_base
.idea

# 本地chatterbot项目路径
chatterbot/ChatterBot_update/

# 虚拟环境
venv/
1 change: 1 addition & 0 deletions GUI运行点我.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
venv\python.exe main.py
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# AI Vtuber

<div style="text-align: center;">
_✨ AI Vtuber ✨_
_✨ AI Vtuber ✨_

<a href="https://github.com/Ikaros-521/AI-Vtuber/stargazers">
<img alt="GitHub stars" src="https://img.shields.io/github/stars/Ikaros-521/AI-Vtuber?color=%09%2300BFFF&style=flat-square">
Expand Down Expand Up @@ -55,7 +55,7 @@ pip install -r requirements_ks.txt
配置都在`config.json`
```
{
// 你的直播间号,兼容全平台,都是直播间页面的链接中最后的数字。例如:123
// 你的直播间号,兼容全平台,都是直播间页面的链接中最后的数字和字母。例如:123
"room_display_id": "你的直播间号",
// 选用的聊天类型:chatterbot/gpt/claude/langchain_pdf/langchain_pdf+gpt/chatglm/none 其中none就是复读机模式
"chat_type": "none",
Expand Down Expand Up @@ -114,8 +114,11 @@ pip install -r requirements_ks.txt
"audio_synthesis_type": "edge-tts",
// vits相关配置
"vits": {
// 配置文件的路径
"vits_config_path": "E:\\GitHub_pro\\VITS-fast-fine-tuning\\inference\\finetune_speaker.json",
// 推理服务运行的链接(需要完整的URL)
"vits_api_ip_port": "http://127.0.0.1:7860",
// 选择的说话人,配置文件中的speaker中的其中一个
"character": "ikaros"
},
// edge-tts相关配置
Expand Down Expand Up @@ -146,6 +149,7 @@ pip install -r requirements_ks.txt
// chatgpt相关配置
"chatgpt": {
"model": "gpt-3.5-turbo",
// 控制生成文本的随机性。较高的温度值会使生成的文本更随机和多样化,而较低的温度值会使生成的文本更加确定和一致。
"temperature": 0.9,
"max_tokens": 2048,
"top_p": 1,
Expand Down Expand Up @@ -222,6 +226,12 @@ ps:依赖[golang](https://go.dev/dl/)环境,还没有的话,手动补一补[

运行 `python ks.py`

## 开发
### UI设计
打开QT设计师~o( =∩ω∩= )m `pyqt5-tools designer`
生成UI代码 `pyuic5 -o UI_main.py ui\main.ui`


## FAQ 常问问题

### 1.openai 接口报错:《empty message》
Expand All @@ -244,6 +254,12 @@ MIT许可证。详情请参阅LICENSE文件。
### 快手弹幕获取
[kuaishou-live](https://github.com/YunzhiYike/kuaishou-live)

### Claude
[claude-api](https://github.com/bincooo/claude-api)

### ChatGLM
[ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B)

### langchain_pdf
参考:[LangChainSummarize](https://github.com/Ikaros-521/LangChainSummarize)

Expand Down Expand Up @@ -272,6 +288,12 @@ ChatterBot 的核心思想是:基于历史对话数据,使用机器学习和
### 2023-06-16
增加Edge-TTS的语速、音量调节参数。

### 2023-06-17
- 增加GUI版。
- 增加GUI运行的bat文件,需要配合本地虚拟环境运行。请到releases下载。
- 对config.json的结构做了调整,增加了弹幕前后缀过滤配置。
- 增加langchain_pdf_local的配置内容,待和主线整合后合并。

</details>

## Star 经历
Expand All @@ -286,4 +308,5 @@ ChatterBot 的核心思想是:基于历史对话数据,使用机器学习和

<a href="https://github.com/Ikaros-521/AI-Vtuber/graphs/contributors">
<img src="https://contrib.rocks/image?repo=Ikaros-521/AI-Vtuber" />
<img style="border-radius: 50%; height:66px;" src="https://avatars.githubusercontent.com/u/46062705?v=4" />
</a>
618 changes: 618 additions & 0 deletions UI_main.py

Large diffs are not rendered by default.

71 changes: 41 additions & 30 deletions bilibili.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,46 @@
import logging

# 导入所需的库
from bilibili_api import live, sync

from utils.my_handle import My_handle

my_handle = My_handle("config.json")
if my_handle is None:
print("程序初始化失败!")
exit(0)


# 初始化 Bilibili 直播间
room = live.LiveDanmaku(my_handle.get_room_id())


@room.on('DANMU_MSG')
async def on_danmaku(event):
"""
处理直播间弹幕事件
:param event: 弹幕事件数据
"""
content = event["data"]["info"][1] # 获取弹幕内容
user_name = event["data"]["info"][2][1] # 获取发送弹幕的用户昵称

my_handle.commit_handle(user_name, content)

from utils.common import Common
from utils.logger import Configure_logger
from utils.my_handle import My_handle

try:
# 启动 Bilibili 直播间连接
sync(room.connect())
except KeyboardInterrupt:
print('程序被强行退出')
finally:
print('关闭连接...')
exit(0)
def start_server():
common = Common()
# 日志文件路径
file_path = "./log/log-" + common.get_bj_time(1) + ".txt"
Configure_logger(file_path)

my_handle = My_handle("config.json")
if my_handle is None:
logging.info("程序初始化失败!")
exit(0)


# 初始化 Bilibili 直播间
room = live.LiveDanmaku(my_handle.get_room_id())


@room.on('DANMU_MSG')
async def on_danmaku(event):
"""
处理直播间弹幕事件
:param event: 弹幕事件数据
"""
content = event["data"]["info"][1] # 获取弹幕内容
user_name = event["data"]["info"][2][1] # 获取发送弹幕的用户昵称

my_handle.commit_handle(user_name, content)


try:
# 启动 Bilibili 直播间连接
sync(room.connect())
except KeyboardInterrupt:
logging.warning('程序被强行退出')
finally:
logging.warning('关闭连接...')
exit(0)
41 changes: 32 additions & 9 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
{
"room_display_id": "你的直播间房间号",
"platform": "bilibili",
"room_display_id": "27833311",
"chat_type": "none",
"need_lang": "none",
"before_prompt": "请简要回复:",
"after_prompt": "",
"badwords_path": "data/badwords.txt",
"max_len": 30,
"max_char_len": 50,
"filter": {
"before_must_str": [],
"after_must_str": [
".",
"",
"?",
""
],
"badwords_path": "data/badwords.txt",
"max_len": 30,
"max_char_len": 50
},
"openai": {
"api": "https://api.openai.com/v1",
"api_key": [
"你的api key"
"你的api_key"
]
},
"claude": {
Expand All @@ -31,6 +41,17 @@
"chunk_overlap": 50,
"model_name": "gpt-3.5-turbo-0301",
"chain_type": "stuff",
"show_cost": false
},
"langchain_pdf_local": {
"bot_user_id": "",
"slack_user_token": "",
"data_path": "data/伊卡洛斯百度百科.zip",
"separator": "\n",
"chunk_size": 100,
"chunk_overlap": 50,
"embedding_model": "sebastian-hofstaetter/distilbert-dot-tas_b-b256-msmarco",
"chain_type": "stuff",
"show_cost": true
},
"audio_synthesis_type": "edge-tts",
Expand All @@ -57,10 +78,12 @@
"model": "gpt-3.5-turbo",
"temperature": 0.9,
"max_tokens": 2048,
"top_p": 1,
"presence_penalty": 0,
"frequency_penalty": 0,
"top_p": 1.0,
"presence_penalty": 0.0,
"frequency_penalty": 0.0,
"preset": "请扮演一个AI虚拟主播。不要回答任何敏感问题!不要强调你是主播,只需要回答问题!"
},
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.42"
"header": {
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.42"
}
}
89 changes: 89 additions & 0 deletions config.json.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"platform": "bilibili",
"room_display_id": "你的直播间号",
"chat_type": "none",
"need_lang": "none",
"before_prompt": "请简要回复:",
"after_prompt": "",
"filter": {
"before_must_str": [],
"after_must_str": [
".",
"。",
"?",
"?"
],
"badwords_path": "data/badwords.txt",
"max_len": 30,
"max_char_len": 50
},
"openai": {
"api": "https://api.openai.com/v1",
"api_key": [
"你的api_key"
]
},
"claude": {
"slack_user_token": "",
"bot_user_id": ""
},
"chatglm": {
"api_ip_port": "http://127.0.0.1:8000",
"max_length": 2048,
"top_p": 0.7,
"temperature": 0.95
},
"langchain_pdf": {
"openai_api_key": "你的api key",
"data_path": "",
"separator": "\n",
"chunk_size": 100,
"chunk_overlap": 50,
"model_name": "gpt-3.5-turbo-0301",
"chain_type": "stuff",
"show_cost": false
},
"langchain_pdf_local": {
"bot_user_id": "",
"slack_user_token": "",
"data_path": "data/伊卡洛斯百度百科.zip",
"separator": "\n",
"chunk_size": 100,
"chunk_overlap": 50,
"embedding_model": "sebastian-hofstaetter/distilbert-dot-tas_b-b256-msmarco",
"chain_type": "stuff",
"show_cost": true
},
"audio_synthesis_type": "edge-tts",
"vits": {
"config_path": "E:\\GitHub_pro\\VITS-fast-fine-tuning\\inference\\finetune_speaker.json",
"api_ip_port": "http://127.0.0.1:7860",
"character": "ikaros"
},
"edge-tts": {
"voice": "zh-CN-XiaoyiNeural",
"rate": "+0%",
"volume": "+0%"
},
"elevenlabs": {
"api_key": "",
"voice": "Domi",
"model": "eleven_monolingual_v1"
},
"chatterbot": {
"name": "bot",
"db_path": "db.sqlite3"
},
"chatgpt": {
"model": "gpt-3.5-turbo",
"temperature": 0.9,
"max_tokens": 2048,
"top_p": 1.0,
"presence_penalty": 0.0,
"frequency_penalty": 0.0,
"preset": "请扮演一个AI虚拟主播。不要回答任何敏感问题!不要强调你是主播,只需要回答问题!"
},
"header": {
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.42"
}
}
6 changes: 6 additions & 0 deletions dy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@
# 导入所需的库
import json, re

from utils.common import Common
from utils.logger import Configure_logger
from utils.my_handle import My_handle

common = Common()
# 日志文件路径
file_path = "./log/log-" + common.get_bj_time(1) + ".txt"
Configure_logger(file_path)

my_handle = My_handle("config.json")
if my_handle is None:
Expand Down
7 changes: 7 additions & 0 deletions ks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@
from ks_pb2 import SCWebLiveWatchingUsers
from ks_pb2 import SCWebEnterRoomAck

from utils.common import Common
from utils.logger import Configure_logger
from utils.my_handle import My_handle

common = Common()
# 日志文件路径
file_path = "./log/log-" + common.get_bj_time(1) + ".txt"
Configure_logger(file_path)

my_handle = My_handle("config.json")
if my_handle is None:
print("程序初始化失败!")
Expand Down
Loading

0 comments on commit 81c1991

Please sign in to comment.