Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 918 Bytes

README.md

File metadata and controls

47 lines (34 loc) · 918 Bytes

audio-slicer

Python scripts that slice audios with silence detection

Requirements

pip install librosa
pip install soundfile  # Optional. You can use any library you like to write audio files.

or

pip install -r requirements.txt

Usage

Using Python class

import librosa
import soundfile

from slicer import Slicer

audio, sr = librosa.load('example.wav', sr=None)  # Load an audio file with librosa
slicer = Slicer(
    sr=sr,
    db_threshold=-40,
    min_length=5000,
    win_l=400,
    win_s=20,
    max_silence_kept=500
)
chunks = slicer.slice(audio)
for i, chunk in enumerate(chunks):
    soundfile.write(f'example_{i}.wav', chunk, sr)  # Save sliced audio files with soundfile

Using CLI

TODO

Note

This script may be quite slow due to convolution operations. Since the Slicer class is thread-safe, using multi-threading can speed up the process.