There are a lot of libs to work with mp3 tags, but I need just 2 functions - split mp3 file in 2 parts and the second one to merge 5 mp3.
Can you suggest anything? Thanks!
I wrote a library (pydub) for pretty much this exact use case:
from pydub import AudioSegment
sound = AudioSegment.from_mp3("/path/to/file.mp3")
# len() and slicing are in milliseconds
halfway_point = len(sound) / 2
second_half = sound[halfway_point:]
# Concatenation is just adding
second_half_3_times = second_half + second_half + second_half
# writing mp3 files is a one liner
second_half_3_times.export("/path/to/new/file.mp3", format="mp3")
If you'd like to add silence between parts of a sound:
two_sec_silence = AudioSegment.silent(duration=2000)
sound_with_gap = sound[:1000] + two_sec_silence + sound[1000:]