Search for sound clip within larger sound clip
Afficher commentaires plus anciens
I have this small 5-second sound bite which I know exists exactly n-number of times within a larger sound clip (as an exact copy). I need to find a way to "search" the larger sound clip and return the location (as a time) as an output.
I guess you could say it's like sound comparison. I'd like to avoid taking a screenshot of the sound in a program like audacity and compare images.
Any suggestions how to do this?
1 commentaire
Sean de Wolski
le 10 Juin 2011
Could you please provides us with a small sample set of data?
Also, look at strfind.
Réponses (2)
Daniel Shub
le 10 Juin 2011
A simple solution is to calculate the cross-correlation between the short signal and the long signal.
doc xcorr
The times of the big peaks in the cross-correlation are the times at which the signal occurred. It is a little more difficult than using findstr, but it can handle a little noise. If there is lots of noise, the problem gets harder (but you said it was exact).
If your larger sound clip is too long you will run into some problems, but with cross-correlation you can break it into shorter pieces without any problems.
Matt Fig
le 10 Juin 2011
Here is an example:
% Load three sound clips.
y = load('train');
y2 = load('gong');
y3 = load('handel');
% Make a new one, all three together:
soundclip = [y.y;y2.y;y3.y];
% Play sound to see what happened:
sound(soundclip,y.Fs);
When this is done playing
% Find the gong in soundclip...
idx = findstr(soundclip.',y2.y.') % Returns starting index of gong.
Notice that FINDSTR needs row vectors.
Catégories
En savoir plus sur Audio and Video Data dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!