Skip to content

Commit

Permalink
修复 文案模式 合成音频失败的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed Jul 8, 2023
1 parent 2f55133 commit 86aa6f2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ if __name__ == '__main__':

### 2023-07-08
- 新增 文案模式,基本完成功能。可以自定义文案、合成音频、配置相关信息、循环暂停播放文案。
- 修复 文案模式 合成音频失败的bug

</details>

Expand Down
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"local_max_query": 3,
"local_vector_embedding_model": "sebastian-hofstaetter/distilbert-dot-tas_b-b256-msmarco"
},
"audio_synthesis_type": "vits",
"audio_synthesis_type": "edge-tts",
"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
2 changes: 0 additions & 2 deletions data/copywriting/测试文案.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
我要开始复读了喵。
复读1
复读2
复读3
33
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,6 @@ def run(self):
# 程序入口
if __name__ == '__main__':
common = Common()
audio = Audio()

if getattr(sys, 'frozen', False):
# 当前是打包后的可执行文件
Expand Down Expand Up @@ -1408,6 +1407,8 @@ def run(self):
# 配置文件路径
config_path = os.path.join(file_relative_path, 'config.json')

audio = Audio(config_path, 2)

# 日志文件路径
file_path = "./log/log-" + common.get_bj_time(1) + ".txt"
Configure_logger(file_path)
Expand Down
Binary file added out/copywriting/测试文案.wav
Binary file not shown.
14 changes: 8 additions & 6 deletions utils/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ class Audio:
mixer_normal = pygame.mixer
mixer_copywriting = pygame.mixer

def __init__(self, config_path=None):
if config_path is None:
return

self.common = Common()
def __init__(self, config_path, type=1):
self.config = Config(config_path)
self.common = Common()

# 文案模式
if type == 2:
return


# 日志文件路径
file_path = "./log/log-" + self.common.get_bj_time(1) + ".txt"
Expand Down Expand Up @@ -295,7 +297,7 @@ def only_play_audio(self):
voice_tmp_path = ""

try:
voice_tmp_path = self.voice_tmp_path_queue.get(block=False, timeout=1) # 从队列中获取音频文件路径
voice_tmp_path = self.voice_tmp_path_queue.get(block=False) # 从队列中获取音频文件路径
except Empty:

# 如果文案标志位为1,则说明在暂停中,需要恢复
Expand Down

0 comments on commit 86aa6f2

Please sign in to comment.