Skip to content

Commit

Permalink
文案模式增加了一组文案配置,也就是说有2块文案,会进行左右切换的播放,都播放完毕后会进行新的一轮播放
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed Jul 20, 2023
1 parent 7c5ca16 commit b53d11f
Show file tree
Hide file tree
Showing 12 changed files with 466 additions and 268 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,15 @@ out_audio, out_sr = svc_model.infer(spk, tran, raw_path)
out_audio, out_sr, n_frames = svc_model.infer(spk, tran, raw_path)
```

#### 5.RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
问题:pydub依赖ffmpeg,但环境不存在ffmpeg
解决方案:安装ffmpeg并配置环境变量
ffmpeg安装教程:[ffmpeg安装教程](https://blog.csdn.net/HYEHYEHYE/article/details/122000352)
ffmpeg官方下载:[http://ffmpeg.org/download.html](http://ffmpeg.org/download.html)
ffmpeg本仓库内下载:[releases](https://github.com/Ikaros-521/AI-Vtuber/releases/tag/v0.13.0)

简述就是下载,解压,配置ffmpeg的bin到系统环境变量path中,完事。

</details>


Expand Down Expand Up @@ -919,6 +928,10 @@ cmd输入命令即可:`doctoc /path/to/file`
- [x] 监听1秒2弹幕的直播间,复读机配合vits-fast做语音合成,持续工作30分钟,正常监听并合成音频。

## 🖹待办事项
- [ ] chatglm拥有记忆功能
- [ ] 文案字幕显示
- [ ] 礼物答谢combo情况下的重复答谢问题
- [ ] LLM输出后,后置的过滤(双重过滤)
- [ ] 懒人包优化
- [ ] 接入更多的LLM(科大讯飞、new bing等)
- [ ] 接入更多的TTS方案
Expand All @@ -931,7 +944,7 @@ cmd输入命令即可:`doctoc /path/to/file`
- [ ] 本机语音直接交流模式(本地版本whisper,其他方式)
- [ ] 本地的用户拉黑机制
- [ ] 礼物互动机制(跳舞,唱歌)
- [ ] 用户入场、投食感谢(自定义 文案)
- [x] 用户入场、投食感谢(自定义 文案)
- [ ] 弹幕跳过机制
- [ ] 点歌后的弹幕触发问题(如:只取最新的几个)
- [ ] 弹幕丢失bug修复(很可能是线程sleep造成的)
Expand Down Expand Up @@ -1097,6 +1110,8 @@ cmd输入命令即可:`doctoc /path/to/file`
- 优化audio中vits接口的设计&优化代码减少冗余
- 新增本地问答音频库,机制类似点歌,通过编辑音频文件名做为触发匹配关键词,优先级第二高,匹配命中后直接会进行匹配音频的播放。
- 新增自定义上下限音频随机变速,对普通音频播放和文案音频播放可以进行随机变速配置。(GUI未适配)
- 增加ffmpeg缺失的解决方案
- 文案模式增加了一组文案配置,也就是说有2块文案,会进行左右切换的播放,都播放完毕后会进行新的一轮播放。

</details>

Expand Down
246 changes: 141 additions & 105 deletions UI_main.py

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,16 @@
},
"copywriting": {
"file_path": "data/copywriting/",
"file_path2": "data/copywriting2/",
"audio_path": "out/copywriting/",
"audio_path2": "out/copywriting2/",
"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": [],
"play_list2": [
"test.wav"
],
"audio_interval": 5.0,
"switching_interval": 5.0,
"random_play": true
Expand Down
13 changes: 5 additions & 8 deletions config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,16 @@
},
"copywriting": {
"file_path": "data/copywriting/",
"file_path2": "data/copywriting2/",
"audio_path": "out/copywriting/",
"audio_path2": "out/copywriting2/",
"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": [],
"play_list2": [
"test.wav"
],
"audio_interval": 5.0,
"switching_interval": 5.0,
"random_play": true
Expand Down
2 changes: 2 additions & 0 deletions data/copywriting2/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
随便测一个看看。
第二句话
2 changes: 2 additions & 0 deletions data/copywriting2/test2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
随便合成几句。
测试用
51 changes: 45 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,19 @@ def init_config(self):

# 文案
self.ui.label_copywriting_file_path.setToolTip("文案文件存储路径,默认不可编辑。不建议更改。")
self.ui.label_copywriting_file_path2.setToolTip("文案文件存储路径2,默认不可编辑。不建议更改。")
self.ui.label_copywriting_audio_path.setToolTip("文案音频文件存储路径,默认不可编辑。不建议更改。")
self.ui.label_copywriting_audio_path2.setToolTip("文案音频文件存储路径2,默认不可编辑。不建议更改。")
self.ui.label_copywriting_audio_interval.setToolTip("文案音频播放之间的间隔时间。就是前一个文案播放完成后,到后一个文案开始播放之间的间隔时间。")
self.ui.label_copywriting_switching_interval.setToolTip("文案音频切换到弹幕音频的切换间隔时间(反之一样)。\n就是在播放文案时,有弹幕触发并合成完毕,此时会暂停文案播放,然后等待这个间隔时间后,再播放弹幕回复音频。")
self.ui.label_copywriting_switching_random_play.setToolTip("文案随机播放,就是不根据播放音频文件列表的顺序播放,而是随机打乱顺序进行播放。")
self.ui.label_copywriting_list.setToolTip("加载配置文件中配置的文案路径(data/copywriting/)下的所有文件,请勿放入其他非文案文件")
self.ui.label_copywriting_play_list.setToolTip("此处填写需要播放的音频文件全名,填写完毕后点击 保存配置。文件全名从音频列表中复制,换行分隔,请勿随意填写")
self.ui.label_copywriting_audio_list.setToolTip("加载配置文件中配置的音频路径(data/audio_path/)下的所有文件,请勿放入其他非音频文件")
self.ui.label_copywriting_play_list2.setToolTip("此处填写需要播放的音频文件全名,填写完毕后点击 保存配置。文件全名从音频列表2中复制,换行分隔,请勿随意填写")
self.ui.label_copywriting_audio_list.setToolTip("加载配置文件中配置的音频路径(out/copywriting/)下的所有文件,请勿放入其他非音频文件")
self.ui.label_copywriting_audio_list2.setToolTip("加载配置文件中配置的音频路径2(out/copywriting2/)下的所有文件,请勿放入其他非音频文件")
self.ui.label_copywriting_select.setToolTip("输入要加载的文案文件全名,文件全名从文案列表中复制。如果文件不存在,则会自动创建")
self.ui.pushButton_copywriting_select.setToolTip("加载 左侧输入框中的文件内容输出到下方编辑框内。如果文件不存在,则会自动创建")
self.ui.pushButton_copywriting_select.setToolTip("加载 左侧输入框中的文件相对/绝对路径的文件内容,输出到下方编辑框内。如果文件不存在,则会自动创建")
self.ui.pushButton_copywriting_refresh_list.setToolTip("刷新 文案列表、音频列表中的内容,用于加载新数据")
self.ui.label_copywriting_edit.setToolTip("此处由上方 选择的文案通过加载读取文件内容,在此可以修改文案内容,方便重新合成")
self.ui.pushButton_copywriting_save.setToolTip("保存上方 文案编辑框中的内容到文案文件中")
Expand Down Expand Up @@ -732,7 +736,9 @@ def init_config(self):

# 文案 刷新列表
self.ui.lineEdit_copywriting_file_path.setText(self.copywriting_config['file_path'])
self.ui.lineEdit_copywriting_file_path2.setText(self.copywriting_config['file_path2'])
self.ui.lineEdit_copywriting_audio_path.setText(self.copywriting_config['audio_path'])
self.ui.lineEdit_copywriting_audio_path2.setText(self.copywriting_config['audio_path2'])
self.ui.lineEdit_copywriting_audio_interval.setText(str(self.copywriting_config['audio_interval']))
self.ui.lineEdit_copywriting_switching_interval.setText(str(self.copywriting_config['switching_interval']))
if self.copywriting_config['random_play']:
Expand All @@ -742,6 +748,10 @@ def init_config(self):
for tmp in self.copywriting_config['play_list']:
tmp_str = tmp_str + tmp + "\n"
self.ui.textEdit_copywriting_play_list.setText(tmp_str)
tmp_str = ""
for tmp in self.copywriting_config['play_list2']:
tmp_str = tmp_str + tmp + "\n"
self.ui.textEdit_copywriting_play_list2.setText(tmp_str)

# 聊天
self.ui.lineEdit_talk_username.setText(self.talk_config['username'])
Expand Down Expand Up @@ -1181,6 +1191,11 @@ def save(self):
if 0 != len(play_list):
play_list = play_list[1:]
config_data["copywriting"]["play_list"] = play_list
copywriting_play_list = self.ui.textEdit_copywriting_play_list2.toPlainText()
play_list = [token.strip() for separator in separators for part in copywriting_play_list.split(separator) if (token := part.strip())]
if 0 != len(play_list):
play_list = play_list[1:]
config_data["copywriting"]["play_list2"] = play_list

config_data["header"]["userAgent"] = self.ui.lineEdit_header_useragent.text()

Expand Down Expand Up @@ -1331,8 +1346,9 @@ def copywriting_select(self):
self.show_message_box("警告", "请输入 文案路径喵~", QMessageBox.Critical, 3000)
return

logging.info(f"准备加载 {self.copywriting_config['file_path']} 路径下的 [{select_file_path}]")
new_file_path = os.path.join(self.copywriting_config['file_path'], select_file_path)
# 传入完整文件路径 绝对或相对
logging.info(f"准备加载 文件:[{select_file_path}]")
new_file_path = os.path.join(select_file_path)

content = common.read_file_return_content(new_file_path)
if content is None:
Expand Down Expand Up @@ -1362,13 +1378,23 @@ def copywriting_refresh_list(self):
for tmp in copywriting_file_names:
tmp_str = tmp_str + tmp + "\n"
self.ui.textEdit_copywriting_list.setText(tmp_str)
tmp_str = ""
copywriting_file_names = self.get_dir_txt_filename(self.copywriting_config['file_path2'])
for tmp in copywriting_file_names:
tmp_str = tmp_str + tmp + "\n"
self.ui.textEdit_copywriting_list2.setText(tmp_str)

# 文案音频数据回显到UI
tmp_str = ""
copywriting_audio_file_names = self.get_dir_audio_filename(self.copywriting_config['audio_path'])
for tmp in copywriting_audio_file_names:
tmp_str = tmp_str + tmp + "\n"
self.ui.textEdit_copywriting_audio_list.setText(tmp_str)
tmp_str = ""
copywriting_audio_file_names = self.get_dir_audio_filename(self.copywriting_config['audio_path2'])
for tmp in copywriting_audio_file_names:
tmp_str = tmp_str + tmp + "\n"
self.ui.textEdit_copywriting_audio_list2.setText(tmp_str)

logging.info("刷新文件列表")
except Exception as e:
Expand All @@ -1389,7 +1415,7 @@ def copywriting_save(self):
logging.warning(f"请输入 文案路径喵~")
return

new_file_path = os.path.join(self.copywriting_config['file_path'], select_file_path)
new_file_path = os.path.join(select_file_path)
if True == common.write_content_to_file(new_file_path, content):
self.show_message_box("提示", "保存成功~", QMessageBox.Information, 3000)
else:
Expand All @@ -1404,7 +1430,20 @@ def on_pushButton_copywriting_save_clicked(self):
# 合成音频 正经版
async def copywriting_synthetic_audio_main(self):
select_file_path = self.ui.lineEdit_copywriting_select.text()
ret = await audio.copywriting_synthesis_audio(select_file_path)

# 将一个文件路径的字符串切分成路径和文件名
folder_path, file_name = common.split_path_and_filename(select_file_path)

# 判断文件是哪个路径的
if folder_path == config.get("copywriting", "file_path"):
folder_path = config.get("copywriting", "audio_path")
elif folder_path == config.get("copywriting", "file_path2"):
folder_path = config.get("copywriting", "audio_path2")
else:
logging.error(f"文件路径与配置不匹配,将默认输出到同路径")
self.show_message_box("提示", f"文件路径与配置不匹配,将默认输出到同路径", QMessageBox.Information, 3000)

ret = await audio.copywriting_synthesis_audio(select_file_path, folder_path)
if ret is None:
logging.error(f"合成失败!请排查原因")
self.show_message_box("错误", "合成失败!请排查原因", QMessageBox.Critical)
Expand Down
Binary file added out/copywriting2/test.wav
Binary file not shown.
Binary file added out/copywriting2/test2.wav
Binary file not shown.
Loading

0 comments on commit b53d11f

Please sign in to comment.