File Exchange

image thumbnail

Silence removal in speech signals

version (958 KB) by Theodoros Giannakopoulos
A simple method for silence removal in speech streams


Updated 18 Mar 2014

View License

This is a simple method for silence removal and segmentation of audio streams that contain speech. The method is based in two simple audio features (signal energy and spectral centroid). As long as the feature sequences are extracted, as thresholding approach is applied on those sequence, in order to detect the speech segments.

More advanced silence removal and general audio analysis methods can be found in the MATLAB AUDIO ANALYSIS LIBRARY ( which is part of the book INTRODUCTION TO AUDIO ANALYSIS: A MATLAB APPROACH (

Cite As

Theodoros Giannakopoulos (2020). Silence removal in speech signals (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (15)

Nikolay, did you have any success improving the speech detection elements of the functions?

Does anyone have any suggestion of quick modifications to alter the code to be more selective when choosing between speech and 'silence'? Some parts of the voiced speech are being removed when using these functions.

The current code is used to segment the sentencces in the audio file. Can anybody tell me how to segment the audio file for extracting words. Thanks in advance.

Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be
aware that exceeding your available stack space can crash MATLAB and/or your computer.this error appears when debugging this code

but if we want to save these silence intervals than which function we need to performed?


Ooops, it should be like this
output = [output; segments{i}];


Thanks, It has very helpful comments and also works perfectly. It is also possible to add a few lines of code to concatenate the cell "segments" in order to have the removed silence version of the input signal, e.g.:

function [segments, fs, output] = detectVoiced(x, t)

output = [];
for i = length(segments)
output = [segments{i}; output];


how to run this coding give the steps and also i want use this code for my research work


Has this video been removed? I cant take a look at it.

Dear Nikolay. First of all thank you for your comments. Some notes on them:
(a) mp3 IO was not supported in older Matlab versions. Furthermore, audioread seems to have some OS compatibility issues, so I stuck with WAV file format only. Personally, I prefer to use some extrernal script for transcoding (e.g. commandline ffmpeg...)
(b) optioned listening seems right to me to: I will change this in the future
(c) GUI is also some fututre plan
(d) It's true that the precision / recall is not 100%: this is due to the very simple audio features adopted. One can rely to more sophisticated features for better results (e.g. mfccs, other spectral features etc).
I'd be glad to see your new results using and expanding this algorithm.
Again, thank you for your comments!

Nikolay S.

Excellent submission, works fine on the example, and additional files. Almost what I was looking for. Luckily I’ve checked the File Exchange before I’ve written a version of my own. In my case I’m interested in removing silence gaps form several hours recording from some sort of an audio surveillance device. This way I wish to save listeners time and storage space. A few comments, if I may:
• Why limiting the supported file formats to .wav? “audioread” supports MP3 and many other common audio formats.
• For my case I am not always interested to listen to the segments with voice/audio data, though I’d like to have the option.
• I am interested is storing relevant segments, ignoring silence gaps and irrelevant segments. This naturally demands some dialogs and GUI.
• I’ve noted sometimes speech is not properly detected, I’m still investigating this...
I plan to work on your code, to shape it into the application I want (which is a bit different from the current functionality). As mentioned above your code is an excellent starting point. If you want to, I can share the results later on, perhaps even submitting it.
Keep up the good work!

Son Duong



Minor changes in description

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux