def convert_mp3_to_wav(mp3_path, wav_path, max_length=10):
try:
if os.path.exists(wav_path):
return True #todo ideally check here whether file is valid but blah for now
sound = AudioSegment.from_mp3(mp3_path)
sound = sound[:max_length*1000]
sound.export(wav_path, format='wav')
except (IOError, CouldntDecodeError) as ie:
print "Error while converting mp3 to wav: %s" % mp3_path
return False
return True
评论列表
文章目录