Skip to content

Script used to trim audio sample around a speech segment.

Notifications You must be signed in to change notification settings

Lokhozt/sample_trimmer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sample Trimmer

Introduction

This standalone script is used to normalize speech samples to a given samplerate and duration. It was designed to process batch of recorded keywords.

How it works

Its uses energy to determine the speech segment and return a window centered on that segment.

First the audio files are loaded and resampled (facultative):

alt text

Then energy and mean energy is processed:

alt text

Finally, the resulting window is set around the speech segment:

alt text

When the script fail to determine a proper window the concerned files are specified in a troublesome.txt file in the output directory.

Usage

Installation

The script uses librosa for resampling, wavio to write result file and numpy for the processing.

pip install librosa wavio numpy

Uses

usage: trimmer.py [-h] [--window_length WINDOW_LENGTH] [--resample RESAMPLE]
                  source_folder destination_folder duration

Sample split is designed to process a batch a wav files by trimming them to a
specified duration.

positional arguments:
  source_folder         Source folder containing wav files
  destination_folder    Destintion folder where trimmed file will be written
  duration              Desired duration

optional arguments:
  -h, --help            show this help message and exit
  --window_length WINDOW_LENGTH
                        Analysis window length in second
  --resample RESAMPLE   Resample file to given sample rate prior to trimming

About

Script used to trim audio sample around a speech segment.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages