Skip to content

Commit

Permalink
修复 文案音频暂停后 会被弹幕重新激活的bug。优化 文案模式 GUI相关交互
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed Jul 8, 2023
1 parent 8ac8e4a commit 63955c6
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 29 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,8 @@ if __name__ == '__main__':
- 修复 文案模式 没有运行就可以进行合成、播放、暂停操作的bug
- 优化 文案模式 音频播放部分的实现逻辑。新增加载文案不存在就创建的机制。追加了文案页的各个配置和相关说明。
- 修复 audio子线程sleep阻塞主线程弹幕监听的问题。
- 修复 文案音频暂停后 会被弹幕重新激活的bug。
- 优化 文案模式 GUI相关交互

</details>

Expand Down
18 changes: 7 additions & 11 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"max_char_len": 200
},
"live2d": {
"enable": false,
"enable": true,
"port": 12345
},
"openai": {
Expand All @@ -37,7 +37,7 @@
"max_new_tokens": 250
},
"chat_with_file": {
"chat_mode": "claude",
"chat_mode": "",
"data_path": "data/伊卡洛斯百度百科.zip",
"separator": "\n",
"chunk_size": 100,
Expand All @@ -53,7 +53,7 @@
"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.0
"speed": 1
},
"so_vits_svc": {
"enable": false,
Expand Down Expand Up @@ -107,7 +107,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.0,
"seed": -1,
"styles": [],
"cfg_scale": 7,
"steps": 30,
Expand All @@ -121,13 +121,9 @@
"copywriting": {
"file_path": "data/copywriting/",
"audio_path": "out/copywriting/",
"play_list": [
"测试文案2.wav",
"测试文案3.wav",
"吐槽.wav"
],
"audio_interval": 5.0,
"switching_interval": 5.0,
"play_list": [],
"audio_interval": 5,
"switching_interval": 5,
"random_play": true
},
"header": {
Expand Down
3 changes: 3 additions & 0 deletions data/copywriting/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
你好,我是测试文案。
加载这块还有点问题,需要修改一下。
然后我们保存文案,再合成音频。
37 changes: 24 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,11 @@ def copywriting_select(self):

self.ui.textEdit_copywriting_edit.setText(content)

logging.info(f"成功加载文案:{select_file_path}")
self.show_message_box("提示", f"成功加载文案:{select_file_path}", QMessageBox.Information, 3000)

self.copywriting_refresh_list()


# 加载文案按钮
def on_pushButton_copywriting_select_clicked(self):
Expand All @@ -1046,19 +1051,25 @@ def on_pushButton_copywriting_select_clicked(self):

# 刷新列表
def copywriting_refresh_list(self):
# 文案数据回显到UI
tmp_str = ""
copywriting_file_names = self.get_dir_txt_filename(self.copywriting_config['file_path'])
for tmp in copywriting_file_names:
tmp_str = tmp_str + tmp + "\n"
self.ui.textEdit_copywriting_list.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)
try:
# 文案数据回显到UI
tmp_str = ""
copywriting_file_names = self.get_dir_txt_filename(self.copywriting_config['file_path'])
for tmp in copywriting_file_names:
tmp_str = tmp_str + tmp + "\n"
self.ui.textEdit_copywriting_list.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)

logging.info("刷新文件列表")
except Exception as e:
logging.error(e)
self.show_message_box("错误", f"刷新失败!{e}", QMessageBox.Critical)


# 刷新列表按钮
Expand Down
Binary file added out/copywriting/test.wav
Binary file not shown.
11 changes: 6 additions & 5 deletions utils/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ def only_play_audio(self):
pygame.time.Clock().tick(10)
Audio.mixer_normal.music.stop()

# 延时执行恢复文案播放
self.delayed_execution_unpause_copywriting_play()
if Audio.copywriting_play_flag == 1:
# 延时执行恢复文案播放
self.delayed_execution_unpause_copywriting_play()

Audio.mixer_normal.quit()

Expand Down Expand Up @@ -433,15 +434,15 @@ def merge_audio_files(self, directory, base_filename, last_index, pause_duration
# 只进行文案音频合成
async def copywriting_synthesis_audio(self, file_path):
try:
file_path = os.path.join(copywriting["file_path"], file_path)
logging.info(f"即将合成的文案:{file_path}")

max_len = self.config.get("filter", "max_len")
max_char_len = self.config.get("filter", "max_char_len")
audio_synthesis_type = self.config.get("audio_synthesis_type")
vits = self.config.get("vits")
copywriting = self.config.get("copywriting")
edge_tts_config = self.config.get("edge-tts")
file_path = os.path.join(copywriting["file_path"], file_path)

logging.info(f"即将合成的文案:{file_path}")

# 从文件路径提取文件名
file_name = self.common.extract_filename(file_path)
Expand Down

0 comments on commit 63955c6

Please sign in to comment.