我想检测给定wav.file中的拍手数量。这是我的第一次尝试。我可以画出眼镜,但是如何打印声音中的拍手数量。 我的输出应该给我"一个鼓掌"或"两个鼓掌"。
hfile = 'one.wav';
[y, Fs] = wavread(hfile);
mono1 = mean(y,2);
[S,F,T,P] = spectrogram(mono1,w,120,N,Fs);
thresh_l=1000;
thresh_h=10000000;
% take the segment of P relating to your frequencies of interest
P2 = P(F>thresh_l&F<thresh_h,:);
%show the mean power in that band over time
m = mean(P2);
plot(T,m);
答案 0 :(得分:2)
对我来说,这似乎是你在时域而不是频域做的事情。
如果音频文件很干净,你可以这样做:
代码如下所示:
hfile = 'one.wav';
[y, Fs] = wavread(hfile);
threshold = [user-defined]; %// amplitude to stop looping at
radius = [user-defined]; %// radius to floor after clap is detected
number_of_claps = 0;
while true
[max_value,idx] = max(y); %// detect loudest amplitude
if (max_value < threshold) %// break if all claps are found
break;
end
min_bound = max(1,idx-radius);
max_bound = min(idx+radius,length(y));
y(min_bound:max_bound) = 0; %// ignore region around the clap
number_of_claps = number_of_claps + 1;
end
number_of_claps
可能有必要更改地板程序,使其忽略索引右侧的较大部分,因为&#34;衰变&#34;拍手信号的一部分将持续比上升部分更长。