Skip to content

Python script that slices audio with silence detection

License

Notifications You must be signed in to change notification settings

pikechu/audio-slicer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Python script that slices audio with silence detection

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%