Skip to content

Commit

Permalink
音频合成后的路径统一为绝对路径,稳妥点
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed Nov 14, 2023
1 parent aa51ba2 commit ccb6539
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions utils/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,11 +698,13 @@ async def only_play_audio(self):

# 如果文案标志位为2,则说明在播放中,需要暂停
if Audio.copywriting_play_flag == 2:
logging.debug(f"暂停文案播放,等待一个切换间隔")
# 文案暂停
self.pause_copywriting_play()
Audio.copywriting_play_flag = 1
# 等待一个切换时间
await asyncio.sleep(float(self.config.get("copywriting", "switching_interval")))
logging.debug(f"切换间隔结束,准备播放普通音频")

# 是否启用字幕输出
if captions_config["enable"]:
Expand Down Expand Up @@ -737,6 +739,7 @@ async def only_play_audio(self):
}
Audio.audio_player.play(data_json)
else:
logging.debug(f"voice_tmp_path={voice_tmp_path}")
# 使用pygame播放音频
Audio.mixer_normal.music.load(voice_tmp_path)
Audio.mixer_normal.music.play()
Expand Down Expand Up @@ -934,6 +937,7 @@ def pause_copywriting_play(self):
logging.info("暂停文案播放")
Audio.copywriting_play_flag = 0
if self.config.get("play_audio", "player") == "audio_player":
pass
Audio.audio_player.pause_stream()
else:
Audio.mixer_copywriting.music.pause()
Expand All @@ -945,6 +949,7 @@ def unpause_copywriting_play(self):
Audio.copywriting_play_flag = 2
# print(f"Audio.copywriting_play_flag={Audio.copywriting_play_flag}")
if self.config.get("play_audio", "player") == "audio_player":
pass
Audio.audio_player.resume_stream()
else:
Audio.mixer_copywriting.music.unpause()
Expand Down
2 changes: 2 additions & 0 deletions utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ def get_new_audio_path(self, audio_out_path, file_name):
audio_out_path = './' + audio_out_path
voice_tmp_path = os.path.normpath(os.path.join(audio_out_path, file_name))

voice_tmp_path = os.path.abspath(voice_tmp_path)

return voice_tmp_path

# 获取所有的声卡设备信息
Expand Down

0 comments on commit ccb6539

Please sign in to comment.