-
Notifications
You must be signed in to change notification settings - Fork 0
/
segmenterEus.m
executable file
·35 lines (31 loc) · 1.02 KB
/
segmenterEus.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function [binaryAudio,voiceSegments,backgroundSegments,aux]=segmenterEus(dlRuns,params,wins,fs)
%
% Please reference the following paper:
% Aggelos Pikrakis, Yannis Kopsinis, Nadine Kroher, Jose Miguel Diaz-Banez,
% "Unsupervised Singing Voice Detection Using Dictionary Learning", 24th
% European Signal Processing Conference (EUSIPCO), Budapest, Hungary, 2016.
for k=1:dlRuns
params.initdict = randn(size(params.data,1),params.dictsize);
[~,X] = ksvd(params,'');
X=full(X);
fprintf('Run %% %d\n',k);
[w(k,:)]=weightFunction(X);
end
aux=w;
if size(w,1)>1
w=medfilt1(mean(w),round(fs/wins)); % 1 s long median filter
else
w=medfilt1(w,round(fs/wins));
end
G=w;G(G<eps)=[];
Th=multithresh(G,1); % Otsu threshold is computed here
% Detect vocal segments
bind= w>=Th;
binaryAudio=zeros(size(w));
binaryAudio(bind)=1;
voiceSegments=detectSegments(binaryAudio);
% Detect background segments
bind= w<=multithresh(G,1);
binaryAudio=zeros(size(w));
binaryAudio(bind)=1;
backgroundSegments=detectSegments(binaryAudio);