Skip to content

Commit

Permalink
Différentes fonctions
Browse files Browse the repository at this point in the history
  • Loading branch information
YouriT committed Dec 5, 2013
1 parent f6daddd commit 9dd5c03
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 3 deletions.
41 changes: 41 additions & 0 deletions MATLAB_CODE_SOURCE/diffBetweenSignals.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
function [matches] = diffBetweenSignals(word,alphabet)

delimitations = endpointdetection(word);
lpcDico = cell(1,length(alphabet));

for i=1:length(alphabet)
lpcDico{i} = lpc(cell2mat(alphabet(i)),50);
end

temp = 9999;
slice = cell(1,length(delimitations));
matches = zeros(1,length(delimitations));
currentLetter = 0;

for i=1:length(delimitations)
slice{i} = word(delimitations{i}(1):delimitations{i}(2));
lpcLetter = lpc(slice{i},50);
for j=1:length(alphabet)
tLpcLetter = lpcLetter;
tLpcDico = lpcDico{j};
if length(tLpcLetter) < length(tLpcDico)
tLpcLetter(length(tLpcDico)) = 0;
elseif length(tLpcLetter) > length(tLpcDico)
tLpcDico(length(tLpcLetter)) = 0;
end
% subplot(length(alphabet),1,j);
% plot([1:51],tLpcLetter,[1:51],tLpcDico);
diff = sqrt(sum((tLpcLetter-tLpcDico).^2));
% diff
% temp
if diff < temp
temp = diff;
currentLetter = j;
end
end
% return;
matches(i) = currentLetter;
currentLetter = 0;
temp = 9999;
end
end
6 changes: 6 additions & 0 deletions MATLAB_CODE_SOURCE/displaySignals.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function displaySignals(signals)
for i=1:length(signals)
subplot(length(signals),1,i);
plot(cell2mat(signals(i)));
end
end
33 changes: 30 additions & 3 deletions MATLAB_CODE_SOURCE/endpointdetection.m
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
function [startP, endP] = endpointdetection(inputSignal)
function [points] = endpointdetection(inputSignal)
P = inputSignal .^ 2;
noiseValue = sum(P)/length(P);
plot(P)
line([0,length(inputSignal)],[noiseValue,noiseValue]);

points = {};
increment = 1;

startDetected = 0;
startP = 0;
endP = 0;
remember = 0;
endCounter = 0;
for i=1:length(P)
if P(i) > noiseValue && startDetected == 0
startP = i;
startDetected = 1;
elseif P(i) < noiseValue && startDetected == 1
endP = i;
return;
if endP == 0
endP = i;
remember = i;
elseif endCounter < 800
endCounter = endCounter+1;
elseif endCounter >= 800
points{increment} = [startP, endP];
startP = 0;
endP = 0;
remember = 0;
endCounter = 0;
increment = increment + 1;
startDetected = 0;
end
elseif P(i) > noiseValue && startDetected == 1
endP = 0;
remember = 0;
i = remember;
endCounter = 0;
end
end
end
5 changes: 5 additions & 0 deletions MATLAB_CODE_SOURCE/record2data.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function [R] = record2data(duration)
recordSignal = record(8000, duration);
signal = getaudiodata(recordSignal);
R = cell2mat(detectVoiced(signal, 8000));
end

0 comments on commit 9dd5c03

Please sign in to comment.