mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 13:12:03 +00:00
i've tested, now you can too
This commit is contained in:
@@ -11,13 +11,17 @@ kexc = [ 8, -16, 26, -48, 86, -162, 294, -502, 718, -728, 184 672, -610, -67
|
||||
kexc = shift(kexc,sh);
|
||||
kexc = [kexc(1:sh) zeros(1,512-25) kexc(sh+1:25)];
|
||||
figure(1)
|
||||
clf
|
||||
plot(kexc)
|
||||
figure(2)
|
||||
G = fft(kexc);
|
||||
subplot(211)
|
||||
plot((1:256)*(4000/256),unwrap(angle(G(1:256))))
|
||||
subplot(212)
|
||||
plot(20*log10(abs(G)))
|
||||
|
||||
f=fopen("glottal.c","wt");
|
||||
fprintf(f,"float glottal[]={\n");
|
||||
fprintf(f,"const float glottal[]={\n");
|
||||
for m=1:255
|
||||
fprintf(f," %f,\n",angle(G(m)));
|
||||
endfor
|
||||
|
||||
@@ -7,14 +7,19 @@ function lsp_pdf(lsp)
|
||||
|
||||
% LSPs
|
||||
|
||||
figure(3);
|
||||
figure(1);
|
||||
clf;
|
||||
[x,y] = hist(lsp(:,1),100);
|
||||
plot(y*4000/pi,x,";1;");
|
||||
plot(y*4000/pi,x,"+;1;");
|
||||
hold on;
|
||||
for i=2:c
|
||||
for i=2:5
|
||||
[x,y] = hist(lsp(:,i),100);
|
||||
legend = sprintf(";%d;",i);
|
||||
legend = sprintf("+%d;%d;",i,i);
|
||||
plot(y*4000/pi,x,legend);
|
||||
endfor
|
||||
for i=6:c
|
||||
[x,y] = hist(lsp(:,i),100);
|
||||
legend = sprintf("+%d;%d;",i-5,i);
|
||||
plot(y*4000/pi,x,legend);
|
||||
endfor
|
||||
hold off;
|
||||
@@ -22,29 +27,65 @@ function lsp_pdf(lsp)
|
||||
|
||||
% LSP differences
|
||||
|
||||
figure(4);
|
||||
figure(2);
|
||||
clf;
|
||||
subplot(211)
|
||||
[x,y] = hist(lsp(:,1),100);
|
||||
plot(y,x,";1;");
|
||||
plot(y*4000/pi,x,"1;1;");
|
||||
hold on;
|
||||
for i=2:5
|
||||
[x,y] = hist(lsp(:,i) - lsp(:,i-1),100);
|
||||
legend = sprintf(";%d;",i);
|
||||
plot(y,x,legend);
|
||||
legend = sprintf("%d;%d;",i,i);
|
||||
plot(y*4000/pi,x,legend);
|
||||
endfor
|
||||
hold off;
|
||||
grid;
|
||||
|
||||
subplot(212)
|
||||
[x,y] = hist(lsp(:,6)-lsp(:,5),100);
|
||||
plot(y,x,";6;");
|
||||
plot(y*4000/pi,x,"1;6;");
|
||||
hold on;
|
||||
for i=7:c
|
||||
[x,y] = hist(lsp(:,i) - lsp(:,i-1),100);
|
||||
legend = sprintf(";%d;",i);
|
||||
plot(y,x,legend);
|
||||
legend = sprintf("%d;%d;",i-5,i);
|
||||
plot(y*4000/pi,x,legend);
|
||||
endfor
|
||||
hold off;
|
||||
grid;
|
||||
|
||||
% LSP differences delta from last frame
|
||||
|
||||
lspd(:,1) = lsp(:,1);
|
||||
lspd(:,2:10) = lsp(:,2:10) - lsp(:,1:9);
|
||||
|
||||
[m,n] = size(lspd);
|
||||
lspdd = lspd(5:m,:) - lspd(1:m-4,:);
|
||||
|
||||
figure(3);
|
||||
clf;
|
||||
subplot(211)
|
||||
for i=1:5
|
||||
[x,y] = hist(lspdd(:,i),100);
|
||||
legend = sprintf("%d;%d;",i,i);
|
||||
plot(y*4000/pi,x,legend);
|
||||
hold on;
|
||||
endfor
|
||||
hold off;
|
||||
grid;
|
||||
axis([-200 200 0 35000]);
|
||||
|
||||
subplot(212)
|
||||
for i=6:10
|
||||
[x,y] = hist(lspdd(:,i),100);
|
||||
legend = sprintf("%d;%d;",i-5,i);
|
||||
plot(y*4000/pi,x,legend);
|
||||
hold on;
|
||||
endfor
|
||||
hold off;
|
||||
grid;
|
||||
axis([-200 200 0 16000]);
|
||||
|
||||
figure(4);
|
||||
clf;
|
||||
plot((4000/pi)*(lsp(2:r,3)-lsp(1:r-1,3)))
|
||||
endfunction
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
function phase2(samname, png)
|
||||
N = 16000;
|
||||
|
||||
f=45;
|
||||
model = load("../src/hts1a_model.txt");
|
||||
f=43;
|
||||
model = load("../src/hts1a_phase_model.txt");
|
||||
phase = load("../src/hts1a_phase_phase.txt");
|
||||
Wo = model(f,1);
|
||||
P=2*pi/Wo;
|
||||
@@ -15,13 +15,13 @@ function phase2(samname, png)
|
||||
A = model(f,3:(L+2));
|
||||
phi = phase(f,1:L);
|
||||
phi = zeros(1,L);
|
||||
for m=L/2:L
|
||||
phi(m) = 2*pi*rand(1,1);
|
||||
end
|
||||
phi(3) = -pi/2;
|
||||
phi(4) = -pi/4;
|
||||
phi(5) = pi/2;
|
||||
|
||||
s = zeros(1,N);
|
||||
|
||||
for m=1:L
|
||||
for m=3:5
|
||||
s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi(m));
|
||||
s = s + s_m;
|
||||
endfor
|
||||
@@ -30,6 +30,13 @@ function phase2(samname, png)
|
||||
clf;
|
||||
plot(s(1:250));
|
||||
|
||||
figure(2);
|
||||
clf;
|
||||
subplot(211)
|
||||
plot((1:L)*Wo*4000/pi, 20*log10(A),'+');
|
||||
subplot(212)
|
||||
plot((1:L)*Wo*4000/pi, phi,'+');
|
||||
|
||||
fs=fopen(samname,"wb");
|
||||
fwrite(fs,s,"short");
|
||||
fclose(fs);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
% Copyright David Rowe 2009
|
||||
% This program is distributed under the terms of the GNU General Public License
|
||||
% Version 2
|
||||
%
|
||||
% Plots a raw speech sample file, you can optionally specify the start and end
|
||||
% samples and create a large and small PNGs
|
||||
|
||||
function pl(samname1, start_sam, end_sam, pngname)
|
||||
|
||||
@@ -19,7 +22,7 @@ function pl(samname1, start_sam, end_sam, pngname)
|
||||
figure(1);
|
||||
clf;
|
||||
plot(s(st:en));
|
||||
axis([1 en-st min(s) max(s)]);
|
||||
axis([1 en-st 1.1*min(s) 1.1*max(s)]);
|
||||
|
||||
if (nargin == 4)
|
||||
|
||||
|
||||
@@ -4,8 +4,16 @@
|
||||
%
|
||||
% Plot ampltiude modelling information from dump files.
|
||||
|
||||
function plamp(samname, f)
|
||||
function plamp(samname, f, samname2)
|
||||
|
||||
% switch some stuff off to unclutter display
|
||||
|
||||
plot_lsp = 0;
|
||||
plot_snr = 0;
|
||||
plot_vsnr = 0;
|
||||
plot_sw = 0;
|
||||
plot_pw = 0;
|
||||
|
||||
sn_name = strcat(samname,"_sn.txt");
|
||||
Sn = load(sn_name);
|
||||
|
||||
@@ -17,6 +25,16 @@ function plamp(samname, f)
|
||||
Sw_ = load(sw__name);
|
||||
endif
|
||||
|
||||
ew_name = strcat(samname,"_ew.txt");
|
||||
if (file_in_path(".",ew_name))
|
||||
Ew = load(ew_name);
|
||||
endif
|
||||
|
||||
rk_name = strcat(samname,"_rk.txt");
|
||||
if (file_in_path(".",rk_name))
|
||||
Rk = load(rk_name);
|
||||
endif
|
||||
|
||||
model_name = strcat(samname,"_model.txt");
|
||||
model = load(model_name);
|
||||
|
||||
@@ -50,12 +68,24 @@ function plamp(samname, f)
|
||||
snr = load(snr_name);
|
||||
endif
|
||||
|
||||
% optional second file, for exploring post filter
|
||||
|
||||
model2q_name = " ";
|
||||
if nargin == 3
|
||||
model2q_name = strcat(samname2,"_qmodel.txt");
|
||||
if file_in_path(".",modelq_name)
|
||||
model2q = load(model2q_name);
|
||||
end
|
||||
end
|
||||
|
||||
Ew_on = 1;
|
||||
k = ' ';
|
||||
do
|
||||
figure(1);
|
||||
clf;
|
||||
% s = [ Sn(2*(f-2)-1,:) Sn(2*(f-2),:) ];
|
||||
s = [ Sn(2*f-1,:) Sn(2*f,:) ];
|
||||
size(s);
|
||||
plot(s);
|
||||
axis([1 length(s) -20000 20000]);
|
||||
|
||||
@@ -66,13 +96,14 @@ function plamp(samname, f)
|
||||
plot((1:L)*Wo*4000/pi, 20*log10(Am),";Am;r");
|
||||
axis([1 4000 -10 80]);
|
||||
hold on;
|
||||
% plot((0:255)*4000/256, Sw(f-2,:),";Sw;");
|
||||
plot((0:255)*4000/256, Sw(f,:),";Sw;");
|
||||
|
||||
if plot_sw
|
||||
plot((0:255)*4000/256, Sw(f,:),";Sw;");
|
||||
end
|
||||
|
||||
if (file_in_path(".",modelq_name))
|
||||
Amq = modelq(f,3:(L+2));
|
||||
plot((1:L)*Wo*4000/pi, 20*log10(Amq),";Amq;g" );
|
||||
if (file_in_path(".",pw_name))
|
||||
if (file_in_path(".",pw_name) && plot_pw)
|
||||
plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;c");
|
||||
endif
|
||||
signal = Am * Am';
|
||||
@@ -82,8 +113,13 @@ function plamp(samname, f)
|
||||
plot((1:L)*Wo*4000/pi, 20*log10(Amq) - 20*log10(Am), Am_err_label);
|
||||
endif
|
||||
|
||||
if (file_in_path(".",snr_name))
|
||||
snr_label = sprintf(";phase SNR %4.2f dB;",snr(f));
|
||||
if file_in_path(".",model2q_name)
|
||||
Amq2 = model2q(f,3:(L+2));
|
||||
plot((1:L)*Wo*4000/pi, 20*log10(Amq2),";Amq2;m" );
|
||||
end
|
||||
|
||||
if (file_in_path(".",snr_name) && plot_vsnr)
|
||||
snr_label = sprintf(";Voicing SNR %4.2f dB;",snr(f));
|
||||
plot(1,1,snr_label);
|
||||
endif
|
||||
|
||||
@@ -96,11 +132,11 @@ function plamp(samname, f)
|
||||
noise = (orig-synth) * (orig-synth)';
|
||||
snr_phase = 10*log10(signal/noise);
|
||||
|
||||
phase_err_label = sprintf(";phase_err SNR %4.2f dB;",snr_phase);
|
||||
plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label);
|
||||
%phase_err_label = sprintf(";phase_err SNR %4.2f dB;",snr_phase);
|
||||
%plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label);
|
||||
endif
|
||||
|
||||
if (file_in_path(".",lsp_name))
|
||||
if (file_in_path(".",lsp_name) && plot_lsp)
|
||||
for l=1:10
|
||||
plot([lsp(f,l)*4000/pi lsp(f,l)*4000/pi], [60 80], 'r');
|
||||
endfor
|
||||
@@ -108,33 +144,21 @@ function plamp(samname, f)
|
||||
|
||||
hold off;
|
||||
|
||||
if (file_in_path(".",phase_name))
|
||||
figure(3);
|
||||
plot((1:L)*Wo*4000/pi, phase(f,1:L), ";phase;");
|
||||
axis;
|
||||
if (file_in_path(".",phase_name_))
|
||||
hold on;
|
||||
plot((1:L)*Wo*4000/pi, phase_(f,1:L), ";phase_;");
|
||||
hold off;
|
||||
endif
|
||||
figure(2);
|
||||
endif
|
||||
|
||||
% autocorrelation function to research voicing est
|
||||
|
||||
%M = length(s);
|
||||
%sw = s .* hanning(M)';
|
||||
%for k=0:159
|
||||
% R(k+1) = sw(1:320-k) * sw(1+k:320)';
|
||||
%endfor
|
||||
%figure(4);
|
||||
%R_label = sprintf(";R(k) %3.2f;",max(R(20:159))/R(1));
|
||||
%plot(R/R(1),R_label);
|
||||
%grid
|
||||
%if (file_in_path(".",phase_name))
|
||||
%figure(3);
|
||||
%plot((1:L)*Wo*4000/pi, phase(f,1:L), ";phase;");
|
||||
%axis;
|
||||
%if (file_in_path(".",phase_name_))
|
||||
%hold on;
|
||||
%plot((1:L)*Wo*4000/pi, phase_(f,1:L), ";phase_;");
|
||||
%hold off;
|
||||
%endif
|
||||
%figure(2);
|
||||
%endif
|
||||
|
||||
% interactive menu
|
||||
|
||||
printf("\rframe: %d menu: n-next b-back p-png q-quit ", f);
|
||||
printf("\rframe: %d menu: n-next b-back p-png q-quit e-toggle Ew", f);
|
||||
fflush(stdout);
|
||||
k = kbhit();
|
||||
if (k == 'n')
|
||||
@@ -143,6 +167,13 @@ function plamp(samname, f)
|
||||
if (k == 'b')
|
||||
f = f - 1;
|
||||
endif
|
||||
if (k == 'e')
|
||||
if (Ew_on == 1)
|
||||
Ew_on = 0;
|
||||
else
|
||||
Ew_on = 1;
|
||||
endif
|
||||
endif
|
||||
|
||||
% optional print to PNG
|
||||
|
||||
@@ -157,7 +188,7 @@ function plamp(samname, f)
|
||||
pngname = sprintf("%s_%d_sw.png",samname,f);
|
||||
print(pngname, '-dpng', "-S500,500")
|
||||
pngname = sprintf("%s_%d_sw_large.png",samname,f);
|
||||
print(pngname, '-dpng', "-S800,600")
|
||||
print(pngname, '-dpng', "-S1200,800")
|
||||
endif
|
||||
|
||||
until (k == 'q')
|
||||
|
||||
@@ -112,7 +112,7 @@ function plphase(samname, f)
|
||||
axis;
|
||||
if (file_in_path(".", phase_name_))
|
||||
hold on;
|
||||
plot((1:L)*Wo*4000/pi, phase_(f,1:L)*180/pi, "g;phase_;");
|
||||
plot((1:L)*Wo*4000/pi, phase_(f,1:L)*180/pi, "g;phase after;");
|
||||
grid
|
||||
hold off;
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user