Das geht mit dem Paket pydub.
from pydub import AudioSegment
def cut_mp3(input_path, output_path, start_time, end_time):
audio = AudioSegment.from_mp3(input_path)
trimmed_audio = audio[start_time:end_time]
trimmed_audio.export(output_path, format="mp3")
input_file = "input.mp3"
output_file = "output.mp3"
start_time = 1000 # Startzeit in Millisekunden (hier: 1 Sekunde)
end_time = 3000 # Endzeit in Millisekunden (hier: 3 Sekunden)
cut_mp3(input_file, output_file, start_time, end_time)