Skip to content

Commit

Permalink
Merge pull request Ikaros-521#137 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
新增本地问答音频库,机制类似点歌,匹配命中后直接播放;新增自定义上下限音频随机变速(GUI未适配)
  • Loading branch information
Ikaros-521 authored Jul 19, 2023
2 parents a81fa6d + 1b51d7f commit b5faf68
Show file tree
Hide file tree
Showing 12 changed files with 862 additions and 563 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ AI Vtuber是一个由 ChatterBot/GPT/Claude/langchain本地or云端/chatglm/text
- [3.ERROR: Conmunicate.`__init__`() got an unexpected keyword argument 'text'](#3error-conmunicate__init__-got-an-unexpected-keyword-argument-text)
- [4.File ".\flask_api_full_song.py", line 38, in wav2wav out_audio, out_sr = svc_model.infer(spk, tran, raw_path) ValueError: too many values to unpack (expected 2)](#4file-%5Cflask_api_full_songpy-line-38-in-wav2wav--out_audio-out_sr--svc_modelinferspk-tran-raw_path-valueerror-too-many-values-to-unpack-expected-2)
- [♏️补充](#%E8%A1%A5%E5%85%85)
- [b站直播监听](#b%E7%AB%99%E7%9B%B4%E6%92%AD%E7%9B%91%E5%90%AC)
- [<span id="dy">抖音弹幕获取</span>](#span-iddy%E6%8A%96%E9%9F%B3%E5%BC%B9%E5%B9%95%E8%8E%B7%E5%8F%96span)
- [快手弹幕获取](#%E5%BF%AB%E6%89%8B%E5%BC%B9%E5%B9%95%E8%8E%B7%E5%8F%96)
- [ChatGPT](#chatgpt)
Expand All @@ -89,6 +90,7 @@ AI Vtuber是一个由 ChatterBot/GPT/Claude/langchain本地or云端/chatglm/text
- [Live2D](#live2d)
- [Stable Diffusion](#stable-diffusion)
- [VITS-fast-fine-tuning](#vits-fast-fine-tuning)
- [DDSP-SVC](#ddsp-svc)
- [so-vits-svc](#so-vits-svc)
- [聊天模式 百度](#%E8%81%8A%E5%A4%A9%E6%A8%A1%E5%BC%8F-%E7%99%BE%E5%BA%A6)
- [🀅开发&项目相关](#%F0%9F%80%85%E5%BC%80%E5%8F%91%E9%A1%B9%E7%9B%AE%E7%9B%B8%E5%85%B3)
Expand All @@ -105,6 +107,8 @@ AI Vtuber是一个由 ChatterBot/GPT/Claude/langchain本地or云端/chatglm/text
- [⭐️Star 经历](#%EF%B8%8Fstar-%E7%BB%8F%E5%8E%86)
- [🤝贡献](#%E8%B4%A1%E7%8C%AE)
- [🎉鸣谢](#%E9%B8%A3%E8%B0%A2)
- [💸投资方](#%E6%8A%95%E8%B5%84%E6%96%B9)
- [🙌赞助](#%E8%B5%9E%E5%8A%A9)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -1091,6 +1095,8 @@ cmd输入命令即可:`doctoc /path/to/file`
### 2023-07-19
- GUI适配DDSP-SVC;补充说明文档
- 优化audio中vits接口的设计&优化代码减少冗余
- 新增本地问答音频库,机制类似点歌,通过编辑音频文件名做为触发匹配关键词,优先级第二高,匹配命中后直接会进行匹配音频的播放。
- 新增自定义上下限音频随机变速,对普通音频播放和文案音频播放可以进行随机变速配置。(GUI未适配)

</details>

Expand Down
419 changes: 229 additions & 190 deletions UI_main.py

Large diffs are not rendered by default.

34 changes: 33 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"before_prompt": "请简要回复:",
"after_prompt": "",
"commit_log_type": "回答",
"local_qa": false,
"filter": {
"before_must_str": [],
"after_must_str": [],
Expand Down Expand Up @@ -57,6 +56,18 @@
"local_vector_embedding_model": "sebastian-hofstaetter/distilbert-dot-tas_b-b256-msmarco"
},
"audio_synthesis_type": "edge-tts",
"audio_random_speed": {
"normal": {
"enable": false,
"speed_min": 0.8,
"speed_max": 1.5
},
"copywriting": {
"enable": false,
"speed_min": 0.8,
"speed_max": 1.5
}
},
"vits": {
"config_path": "D:\\GitHub_pro\\VITS-fast-fine-tuning\\inference\\finetune_speaker.json",
"api_ip_port": "http://127.0.0.1:7860",
Expand Down Expand Up @@ -118,6 +129,16 @@
"instruction_template": "Vicuna-v1.1",
"your_name": ""
},
"local_qa": {
"text": {
"enable": true,
"file_path": "data/本地问答库.txt"
},
"audio": {
"enable": true,
"file_path": "out/本地问答音频/"
}
},
"choose_song": {
"enable": true,
"start_cmd": "点歌 ",
Expand Down Expand Up @@ -150,6 +171,17 @@
"copywriting": {
"file_path": "data/copywriting/",
"audio_path": "out/copywriting/",
"play_list": [
"伊卡日语介绍.wav",
"吐槽.wav"
],
"audio_interval": 5.0,
"switching_interval": 5.0,
"random_play": true
},
"copywriting2": {
"file_path": "data/copywriting2/",
"audio_path": "out/copywriting2/",
"play_list": [],
"audio_interval": 5.0,
"switching_interval": 5.0,
Expand Down
42 changes: 37 additions & 5 deletions config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"before_prompt": "请简要回复:",
"after_prompt": "",
"commit_log_type": "回答",
"local_qa": false,
"filter": {
"before_must_str": [],
"after_must_str": [],
Expand Down Expand Up @@ -57,11 +56,23 @@
"local_vector_embedding_model": "sebastian-hofstaetter/distilbert-dot-tas_b-b256-msmarco"
},
"audio_synthesis_type": "edge-tts",
"audio_random_speed": {
"normal": {
"enable": false,
"speed_min": 0.8,
"speed_max": 1.5
},
"copywriting": {
"enable": false,
"speed_min": 0.8,
"speed_max": 1.5
}
},
"vits": {
"config_path": "D:\\GitHub_pro\\VITS-fast-fine-tuning\\inference\\finetune_speaker.json",
"api_ip_port": "http://127.0.0.1:7860",
"character": "ikaros",
"speed": 1
"speed": 1.0
},
"ddsp_svc": {
"enable": false,
Expand Down Expand Up @@ -118,6 +129,16 @@
"instruction_template": "Vicuna-v1.1",
"your_name": "你"
},
"local_qa": {
"text": {
"enable": true,
"file_path": "data/本地问答库.txt"
},
"audio": {
"enable": true,
"file_path": "out/本地问答音频/"
}
},
"choose_song": {
"enable": true,
"start_cmd": "点歌 ",
Expand All @@ -136,7 +157,7 @@
"ip": "127.0.0.1",
"port": 7860,
"negative_prompt": "ufsw, longbody, lowres, bad anatomy, bad hands, missing fingers, pubic hair,extra digit, fewer digits, cropped, worst quality, low quality",
"seed": -1,
"seed": -1.0,
"styles": [],
"cfg_scale": 7,
"steps": 30,
Expand All @@ -150,9 +171,20 @@
"copywriting": {
"file_path": "data/copywriting/",
"audio_path": "out/copywriting/",
"play_list": [
"伊卡日语介绍.wav",
"吐槽.wav"
],
"audio_interval": 5.0,
"switching_interval": 5.0,
"random_play": true
},
"copywriting2": {
"file_path": "data/copywriting2/",
"audio_path": "out/copywriting2/",
"play_list": [],
"audio_interval": 5,
"switching_interval": 5,
"audio_interval": 5.0,
"switching_interval": 5.0,
"random_play": true
},
"header": {
Expand Down
2 changes: 2 additions & 0 deletions data/copywriting2/测试文案.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
你好,我是文案2的测试文案。
这是新机制,您可以配置2套文案,使其在文案1和文案2之间切换。
24 changes: 24 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ def init_config(self):
# 日志
self.captions_config = config.get("captions")

# 本地问答
self.local_qa_config = config.get("local_qa")

# 过滤配置
self.filter_config = config.get("filter")

Expand Down Expand Up @@ -258,6 +261,12 @@ def init_config(self):
self.ui.label_captions_enable.setToolTip("是否启用字幕日志记录,字幕输出内容为当前合成播放的音频的文本")
self.ui.label_captions_file_path.setToolTip("字幕日志存储路径")

# 本地问答
self.ui.label_local_qa_text_enable.setToolTip("是否启用本地问答文本匹配,完全命中设定的问题后,自动合成对应的回答")
self.ui.label_local_qa_text_file_path.setToolTip("本地问答文本数据存储路径")
self.ui.label_local_qa_audio_enable.setToolTip("是否启用本地问答音频匹配,部分命中音频文件名后,直接播放对应的音频文件")
self.ui.label_local_qa_audio_file_path.setToolTip("本地问答音频文件存储路径")

self.ui.label_filter_before_must_str.setToolTip("弹幕过滤,必须携带的触发前缀字符串(任一)\n例如:配置#,那么就需要发送:#你好")
self.ui.label_filter_after_must_str.setToolTip("弹幕过滤,必须携带的触发后缀字符串(任一)\n例如:配置。那么就需要发送:你好。")
self.ui.label_filter_badwords_path.setToolTip("本地违禁词数据路径(你如果不需要,可以清空文件内容)")
Expand Down Expand Up @@ -480,6 +489,14 @@ def init_config(self):
self.ui.checkBox_captions_enable.setChecked(True)
self.ui.lineEdit_captions_file_path.setText(self.captions_config['file_path'])

# 本地问答
if self.local_qa_config['text']['enable']:
self.ui.checkBox_local_qa_text_enable.setChecked(True)
self.ui.lineEdit_local_qa_text_file_path.setText(self.local_qa_config['text']['file_path'])
if self.local_qa_config['audio']['enable']:
self.ui.checkBox_local_qa_audio_enable.setChecked(True)
self.ui.lineEdit_local_qa_audio_file_path.setText(self.local_qa_config['audio']['file_path'])

tmp_str = ""
for tmp in self.filter_config['before_must_str']:
tmp_str = tmp_str + tmp + "\n"
Expand Down Expand Up @@ -953,6 +970,12 @@ def save(self):
config_data["captions"]["enable"] = self.ui.checkBox_captions_enable.isChecked()
config_data["captions"]["file_path"] = self.ui.lineEdit_captions_file_path.text()

# 本地问答
config_data["local_qa"]["text"]["enable"] = self.ui.checkBox_local_qa_text_enable.isChecked()
config_data["local_qa"]["text"]["file_path"] = self.ui.lineEdit_local_qa_text_file_path.text()
config_data["local_qa"]["audio"]["enable"] = self.ui.checkBox_local_qa_audio_enable.isChecked()
config_data["local_qa"]["audio"]["file_path"] = self.ui.lineEdit_local_qa_audio_file_path.text()

# 通用多行分隔符
separators = [" ", "\n"]

Expand Down Expand Up @@ -1392,6 +1415,7 @@ async def copywriting_synthetic_audio_main(self):
# 刷新文案和音频列表
self.copywriting_refresh_list()


# 合成音频
def copywriting_synthetic_audio(self):
if self.running_flag != 1:
Expand Down
Binary file added out/本地问答音频/关键词1.wav
Binary file not shown.
Binary file added out/本地问答音频/关键词2.wav
Binary file not shown.
Loading

0 comments on commit b5faf68

Please sign in to comment.