import auditok def segment_audio(audio_name): audio_regions = auditok.split(audio_name, min_dur=2, # minimum duration of a valid audio in seconds max_dur=8, # maximum duration of an audio segment max_silence=0.8, # maximum duration of tolerated continuous silence within an event energy_threshold=55, # threshold of detection sampling_rate=16000 ) for i, r in enumerate(audio_regions): filename = r.save(audio_name[:-4]+"_{meta.start:.3f}-{meta.end:.3f}.wav")