from pydub import AudioSegment, silence # file download from here #https://www.jw.org/mos/d-s%E1%BA%BDn-yiisi/biible/nwt/books/S%C9%A9ngre/1/ audio = AudioSegment.from_file("nwt_01_Ge_MM_01.mp3") # Détecter les silences silences = silence.detect_silence(audio, min_silence_len=500, silence_thresh=-40) # Découper en fonction des silences détectés start = 0 for i, (silence_start, silence_end) in enumerate(silences): segment = audio[start:silence_start] # en supposant le dossier segemtns exist deja filename = f"segments/segment_{i+1}.mp3" segment.export(filename, format="mp3") print(f"Segment sauvegardé : {filename}") start = silence_end