Lab 1 - Sinewave Speech Analysis_Synthesis in Matlab - 030614

4
LAB 1 – SINEWAVE SPEECH ANALYSIS/SYNTHESIS IN MATLAB Estimated time to complete this lab: 30 minutes Sebuah percakapan jika dianalisis dan disintesis menggunakan pendekatan sinyal akan memiliki beberapa sinyal sinusoidal yang tergabung manjadi satu. Dengan menganalisis tiga sinyal percakapan yang memiliki keragaman frekuensi dan amplitude yang harmonis bisa menjadi dasar untuk memprediksi suatu percakapan dengan mudah. Pengolahan sinyal seperti ini kini dikenal dengan istilah Sinewave Speech. Di dalam lab ini kita akan menggunakan file-file berikut untuk melakukan proses pengolahan sinyal percakapan: synthtrax.m – menyediakan fungsi utama untuk proses sintesis slinterp.m – menyediakan fungsi tambahan untuk melakukan interpolasi sinyal secara linier readswi.m – menyediakan fungsi untuk membaca file dengan format SWI melalui MATLAB s1pars.swi, s6pars.swi – file-file berisi parameter uji CATATAN: Pastikan semua file di atas disimpan dalam satu folder yang tepat. Lab Objectives After completing this lab, students will be able to: Resynthesize the sinewave speech Lab Procedures A. Resynthesizing the Sinewave Speech Sinewave Speech Analysis/Synthesis in MATLAB 1-1

description

Matlab

Transcript of Lab 1 - Sinewave Speech Analysis_Synthesis in Matlab - 030614

Page 1: Lab 1 - Sinewave Speech Analysis_Synthesis in Matlab - 030614

LAB 1 – SINEWAVE SPEECH ANALYSIS/SYNTHESIS IN MATLAB

Estimated time to complete this lab: 30 minutes

Sebuah percakapan jika dianalisis dan disintesis menggunakan pendekatan sinyal akan memiliki beberapa sinyal sinusoidal yang tergabung manjadi satu. Dengan menganalisis tiga sinyal percakapan yang memiliki keragaman frekuensi dan amplitude yang harmonis bisa menjadi dasar untuk memprediksi suatu percakapan dengan mudah. Pengolahan sinyal seperti ini kini dikenal dengan istilah Sinewave Speech.

Di dalam lab ini kita akan menggunakan file-file berikut untuk melakukan proses pengolahan sinyal percakapan:

synthtrax.m – menyediakan fungsi utama untuk proses sintesis

slinterp.m – menyediakan fungsi tambahan untuk melakukan interpolasi sinyal secara linier

readswi.m – menyediakan fungsi untuk membaca file dengan format SWI melalui MATLAB

s1pars.swi, s6pars.swi – file-file berisi parameter uji

CATATAN: Pastikan semua file di atas disimpan dalam satu folder yang tepat.

Lab ObjectivesAfter completing this lab, students will be able to:

Resynthesize the sinewave speech

Lab ProceduresA. Resynthesizing the Sinewave Speech

In this exercise, we will develop LPC analysis for speech and audio class that was created before. Use the following routine to …

Main routine: [F,M] = swsmodel(D,R,H) returns four sinusoids, with frequencies defined by rows of F and magnitudes defined by rows of M, tracking the formants in the speech sample D (of sampling rate R). Each column of F and M corresponds to H samples (so the analysis frame rate is R/H).

Note: the sound is resampled to 8 kHz within the routine to focus the LPC on the main formant region, below 4 kHz.

Support routine: [A,G,E] = lpcfit(D,P,H,W,O) fits P-th order LPC (all-pole, autoregressive) models to sound waveform D, using W-point windows advanced by H samples. Rows of A contain all-pole filter coefficiets [1 a1 a2 .. aP], with corresponding elements of G giving the

Sinewave Speech Analysis/Synthesis in MATLAB 1-1

Page 2: Lab 1 - Sinewave Speech Analysis_Synthesis in Matlab - 030614

frame gain (residual RMS). E is the actual excitation residual. Specifying OV as zero prevents overlap-add of the residual, for perfect reconstruction but a less useful E.

Support routine: [F,M] = lpca2frq(A) factorizes the LPC polynomial defined in each row of A (as from lpcfit.m) and returns the sorted positive frequencies (up to P/2 of them) in columns of F, each with a corresponding approximate magnitude in M.

Bonus routine: D = lpcsynth(A,G,E,H,OV) resynthesizes from LPC parameters returned by lpcfit, or using noise excitation if E is omitted.

Follow this these steps to Resynthesize the sinewave speech:

1. Open MATLAB R2014a.

2. In the workspce, please enter the following script to call the source file (mpgr1_sx419.wav) and the main routine (swsmodel).

[d,r] = wavread('mpgr1_sx419.wav');[F,M] = swsmodel(d,r);

3. Shows all the frequencies in the graph.plot(F');

4. Listen the sound resulted.dr = synthtrax(F,M,r);sound(dr,r)

5. Compare to noise-excited reconstruction of LPC analysis.[a,g] = lpcfit(d);dl = lpcsynth(a,g);sound(dl,a);

6. The LPC reconstruction is based on more or less the same information as the sinewave replica, but it sounds less 'weird'. Please compare the spectrograms!

subplot(311)specgram(d,256,r);title('Original');subplot(312)specgram(dr,256,r);title('Sine wave replica');subplot(313)specgram(dl,256,r);title('Noise-excited LPC reconstruction');

Sinewave Speech Analysis/Synthesis in MATLAB 1-2

Page 3: Lab 1 - Sinewave Speech Analysis_Synthesis in Matlab - 030614

7. Observe the result.

Sinewave Speech Analysis/Synthesis in MATLAB 1-3