Project Development: Speech Processing, Proj03

Sunday, March 21, 2010

Speech Processing, Proj03

//Purdue Cal - ECE 595C.
//Spring 2010.
//Project 03.

//Copyright @ 2010 antonio081014 ;
//All codes are in Matlab.

Report Link:

Task One: How to plot the frequency spectrum and the spectrum envelop.
1. use the Matlab function lpc to generalize the coefficients alphas for the windowed samples in each frame.
2. use the Matlab function freqz to plot the spectrum envelop.
3. use the Matlab fft to generalize the features in Frequency domain, and then plot it in half (symmetry).

    for i=1:3
        ftmp = fft(data(:,i), 2048);   % data is the windowed signal.
        [a, g] = lpc(data(:,i), 7);       % 7th order.
        hold on;
        [h, w] = freqz([1], a, 1024, fs);  % plot the spectrum envelop.
        plot(abs(h) / max(abs(h)), 'r');
        plot(abs(ftmp(1:1024)) / max(abs(ftmp(1:1024))), 'g'); % plot the freq spectrum.
        title(['Frame: #', num2str(i)]);
        legend('The spectrum envelop','The freq spectrum');

It shows the spectrum envelop in red, and the frequency feature in green.

Task Two: Generate the LP model by using Toeplitz Method.
1. Get the autocorrelation of the original signals.
2. Generate the matrix by using Matlab function Toeplitz .
3. Get the coefficients alphas according to the normal equations in the matrix form.

    tmp_data = norm_spch(201:600);
    c = xcorr(tmp_data,4, 'coeff');    % It can generate 2 * N -1 poles there. 4 -> 7.
    T = toeplitz(c(2:end));  % The first is 1, which is not necessary.
    alpha = inv(T) * c(2:end);
    lpca = lpc(tmp_data, 7);
    % Verified through the following steps.
    test_sp = filter([0  -lpca(2:end)], 1, tmp_data);
    plot(test_sp, 'r');
    hold on
    plot(tmp_data, 'g');
    err_sig = tmp_data - test_sp;
    title('The error signal generated by using Toeplitz Method');

It plots the original signal (green) and the estimated signal (red) generated by using Toeplitz method.

No comments:

Post a Comment