python-3.xpydub

Pydub AudioSegment export has no sound


I have this simple code:

from pydub import AudioSegment

audio = AudioSegment.from_wav("recordings/source.wav")
audio.export("recordings/export.wav", format="wav")

The source.wav is a 5-second recording. The code generates the export.wav, but the file is completely empty. It's a 0s wav file.

There is nothing else to my code, only the part that I pasted here. My goal is to eventually extract a chunk of an audio file, but it's already not working at this stage.

I tried to run the debugging suggested on the Read.me

import logging

l = logging.getLogger("pydub.converter")
l.setLevel(logging.DEBUG)
l.addHandler(logging.StreamHandler())

But I am not getting any errors. The script executes itself without issue. I also tried AudioSegment.from_file, without success.

What am I missing?

I am using pydub 0.25.1


Solution

  • I didn't fix it, but using an .mp3 file instead of a .wav worked.