Hello I want to split an AudioSegment
into chunks that are all 10 seconds long. I tried it like this:
for n in range(int(duration/10)):
start = n*1000*10
end = (n*10+10)*1000
audio_segment = audio[start:end]
The problem is now that i want to access these chunks. But when I enter the audio_segment
variable into the function i am using the following error pops up:
TypeError: a bytes-like object is required, not 'AudioSegment'
.
This error obviously tells me that it only accepts a bytes-like object
. I can turn the AudioSegment
into a bytes-like object
by exporting it into a mp3 and then open it up again as rb
but this solution takes very long and is in my opinion not good because I really do not need these segments to be saved.
Can anyone help me access the AudioSegment
as a bytes-like object
without saving it?