forked from sandboxdream/AI-Vtuber
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff31566
commit 81c1991
Showing
16 changed files
with
1,039 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
venv\python.exe main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.