0

I am trying to loop through a large list of audio files and want to chop them up into 5 second pieces.

Relevant code for the problem is as below.

for file in os.listdir(directory):
    
    f = sf.SoundFile(file)
    
    audio_file = AudioSegment.from_file(file, "wav")

I am getting an error: "AttributeError: 'bytes' object has no attribute 'seek'"

I appreciate the file is in bytes format, but I have attempted to convert it to a string, etc with no luck as I get a permission denied error when I do that.

user6074035
  • 107
  • 1
  • 9

1 Answers1

0

If you are using pydub, you can use AudioSegment.from_wav(file) or AudioSegment.from_raw(file, sample_width, frame_rate)

hack3r-0m
  • 700
  • 6
  • 20
  • conda install -c conda-forge ffmpeg was a library which was missing for me, the above was not working for me until I installed it. – user6074035 Dec 12 '20 at 23:02