这里的初学者。我试图循环遍历到mp3文件的路径列表,并合并所有mp3s:
combined_sounds = AudioSegment.from_mp3('./00.mp3')
for file in files:
sound = AudioSegment.from_mp3(file)
combined_sounds= combined_sounds + sound;
# ....在查看列表之前,我需要定义combined_sounds --但在遍历循环之前,我不想将任何东西放入其中。现在,我的小问题是使用一个空的mp3文件00.mp3,但这不是最好的解决方案。我怎样才能做到这一点?
我尝试了combined_sounds = ''和combined_sounds = None,但当我进入循环并尝试将其转换为AudioSegment时,两者都会给我带来错误。我可以在循环之前创建一个空的AudioSegment吗?
发布于 2020-06-26 08:13:38
您可以使用empty()函数在AudioSegment中创建一个空白段:
combined_sounds = AudioSegment.empty()
for file in files:
sound = AudioSegment.from_mp3(file)
combined_sounds += soundhttps://stackoverflow.com/questions/62589859
复制相似问题