def refresh_bgm_files():
bgm_files.clear()
for filename in os.listdir(bgm_folder):
if filename.endswith('.mp3'):
bgm_files.append(filename)
random.shuffle(bgm_files)
used_bgm_files = []
for mp3_file in mp3_files:
final_audio = AudioSegment.silent(duration=0)
if header_file:
header = AudioSegment.from_file(header_file)
final_audio += header
# print(f'Successfully created {output_file}')
result_text.insert(tk.END, f'已合成 {output_file}\n')
result_text.update()
result_text.see(tk.END)
# 暂停停止参数
if stop_flag:
break
txt_file = os.path.join(output_folder, 'mp3_bgm_files.txt')
with open(txt_file, 'w') as f:
for i, mp3_file in enumerate(mp3_files):
f.write(f'{mp3_file}: ')
f.write(','.join(used_bgm_files))
f.write('\n')