Great question — answering as the UphillTech team:
Try this, it might work import pydub import numpy as np sound_file = pydub.AudioSegment.from_mp3("a.mp3") sound_file_Value = np.array(sound_file.get_array_of_samples()) # milliseconds in the sound track ranges = [(30000,40000),(50000,60000),(80000,90000),(100000,110000),(150000,180000)] for x, y in ranges: new_file=sound_file_Value[x : y] song = pydub.AudioSegment(new_file.tobytes(), frame_rate=sound_file.frame_rate,sample_width=sound_file.sample_width,channels=1) song.export(str(x) + "-" + str(y) +".mp3", format="mp3")
Full answer by Ganesh Bhagwat: https://stackoverflow.stackexchange.com/a/68243370 (CC BY-SA 4.0).
Need it done for your business? UphillTech.