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.
If you are using pydub, you can use
AudioSegment.from_wav(file)
orAudioSegment.from_raw(file, sample_width, frame_rate)