Python AudioSegment会产生MemoryError,而我有足够的内存

Python AudioSegment会产生MemoryError,而我有足够的内存,python,pydub,audiosegment,Python,Pydub,Audiosegment,我正在尝试将两个mp3文件与AudioSegment(pydub)连接起来。对于小文件(小于35MB),它可以正常工作。对于更大的,我有一个记忆错误。 Python版本:3.6.2 这是我的密码。谢谢你的帮助 from pydub import AudioSegment import eyed3 import os import gc import psutil def make_files(path_to_files, audiofiles): pre_sermon = AudioS

我正在尝试将两个mp3文件与AudioSegment(pydub)连接起来。对于小文件(小于35MB),它可以正常工作。对于更大的,我有一个记忆错误。 Python版本:3.6.2

这是我的密码。谢谢你的帮助

from pydub import AudioSegment
import eyed3
import os
import gc
import psutil

def make_files(path_to_files, audiofiles):
    pre_sermon = AudioSegment.from_mp3("pre_sermon.mp3")
    for file_name in audiofiles:     
        sermon = AudioSegment.from_mp3(path_to_files + file_name)      
        combined = pre_sermon + sermon

        audiofile = eyed3.load(path_to_files + file_name)
        combined.export(f'combined/{file_name}', format="mp3", bitrate='128k', tags={'title': audiofile.tag.title, 
                                                                                     'artist': audiofile.tag.artist, 
                                                                                     'album': audiofile.tag.album, 
                                                                                     'comment': audiofile.tag.comments[0].text})

        del combined
        del sermon
        gc.collect()

general_path = 'C:\\projects\\python\\files\\mp3\\sermons\\'
files = set(os.listdir('sermons/'))
combined_files = set(os.listdir('combined/'))
difference = {filename:str(os.stat(os.path.join(general_path, filename)).st_size/1000000) + ' MB' for filename in (files - combined_files)}

print(psutil.virtual_memory())
print(difference)
make_files('sermons/', difference.keys())

使用64位python解释器解决了这个问题。谢谢你,加阿罗

您使用的是32位python解释器还是64位python解释器?32位解释器。我将尝试使用64位。这就是问题所在!非常感谢。