You are on page 1of 24

Short-Time Analysis of Speech

Bagian 2

MK: Aplikasi Pengolahan Sinyal Digital


Bersama: Tri Budi Santoso
Laboratorium Sinyal, PENS-ITS
Referensi: Rabiner & Schafer, Introduction to Digital Speech Processing
Bahasan Minggu Lalu..

Pengantar model untuk suatu speech


signal analysis

Short time Energy & Zero Crossing Rate

Short time Autocorrelation Function


Yang dibahas hari
Short time Fourier Transform ini.

Spectrogram Sinyal Wicara


2. Short Time Energy & Zero Crossing Rate

Dua fungsi dsar short time analysis yang


cukup banyak digunakan adalah:
Short-time Energy

Short-time zero crossing rate


Short time Energy & Zero Crossing Rate

Short-time Energy
Secara matematik dimodelkan sebagai:


En xmwn m x 2 mw2 n m
2

m m

Bisa juga dituliskan dalam bentuk operasi konvolusi sebagai:

En x 2 nhe n
n n

Dimana he[n]=w2[n] respon impulse filter linear


Short time Energy & Zero Crossing Rate
Dari suatu file sinyal wicara ada.wav

Sinyal wicara kata "ada"


0.4

0.3
voiced
unvoiced
0.2

0.1
magnitude

-0.1

-0.2

-0.3

-0.4
0 2000 4000 6000 8000 10000 12000 14000 16000 18000
sample ke-n
Short time Energy & Zero Crossing Rate

Contoh perhitungan energi dengan Matlab untuk satu frame sinyal

Ambil satu frame sampel pada daerah unvoiced (sampel ke 2001 s/d
2320), lakukan penghitungan nilai energinya
Ambil satu frame sampel pada daerah voiced (sampel ke 3001 s/d 3320),
lakukan penghitungan nilai energinya

[y,Fs]=wavread('ada.wav');

y1=y(2001:2320);
e_y1=sum(y1.^2)

y2=y(3001:3320);
e_y2=sum(y2.^2)

Hasilnya di dapatkan sebagai berikut:


e_y1 = 0.0011
e_y2 = 0.7692
Short time Energy & Zero Crossing Rate

Short-time zero crossing rate


Didefinisikan sebagai pembobotan rata-rata pada banyaknya
perubahan tanda pada speech signal (+/-) di dalam satu time
window (frame).
Direprresentasikan dalam terminologi linear filtering sebagai:


Z n 0.5 sgn xm sgn xm 1wn m
m

Note : n n
1 ;x 0
di mana : sgn n
1 ;x 0
Contoh program Matlab
%File Name: zero_cross_01.m
[y,Fs]=wavread('ada.wav');
figure(1);
plot(y);
title('Sinyal wicara kata "ada"')
xlabel('sample ke-n');ylabel('magnitude')

y1=y(2001:2320);
zeros1 = find( (y1(1:end-1) ./ y1(2:end)) <= 0 );
figure(2)
t=2001:2320;
title('Zero Crossing pada Unvoiced')
y2=y(3001:3320);
plot(t,y1,'b', t(zeros1), 0, 'ro'); zeros2 = find( (y2(1:end-1) ./ y2(2:end)) <= 0 );
title('Zero Crossing pada Unvoiced') figure(3)
xlabel('sample ke-n');ylabel('magnitude') t=3001:3320;
length(zeros1) plot(t,y2,'b', t(zeros2), 0, 'ro');
title('Zero Crossing pada Voiced')
xlabel('sample ke-n');ylabel('magnitude')
length(zeros2)
Short time Energy & Zero Crossing Rate

Zero Crossing rate pada Unvoiced


-3
x 10 Zero Crossing pada Unvoiced
6

2
magnitude

-2

-4

-6
2000 2050 2100 2150 2200 2250 2300 2350
sample ke-n

Zero Crossing yang terjadi sebanyak 47


Short time Energy & Zero Crossing Rate

Zero Crossing rate pada Voiced


Zero Crossing pada Voiced
0.1

0.05

0
magnitude

-0.05

-0.1

-0.15
3000 3050 3100 3150 3200 3250 3300 3350
sample ke-n

Zero Crossing yang terjadi sebanyak 23


Short time Energy & Zero Crossing Rate

Pada contoh lain (Buku Rabiner) ditunjukkan bahwa short time energy dan
zero crossing pada suatu sampel sinyal wicara dengan window hamming
sepanjang 20 ms dan frekuensi sampling 16 kHz, didapatkan hasil bahwa:
Daerah Unvoiced:
- zero crossing rate tinggi
- energy relatif rendah
Daerah Voiced:
- zero crossing rendah
- energy relatif tinggi
3. Short Time Autocorrelation Function

Short time autocorrelation function (STATF), didefinisikan


sebagai fungsi autkorelasi deterministik pada sekuen
xn[m] = x[m]w[n-m], yang dipilih dengan window tergeser
terhadap waktu n.


n l x mx m l
n n (8)
m

di mana n n
Short time Autocorrelation Function

Contoh sinyal dan Autokorelasinya


Short time Autocorrelation Function

Dengan menggunakan sampel sinyal yang sama pada file ada.wav

Sinyal wicara kata "ada"


0.4

0.3
voiced
unvoiced
0.2

0.1
magnitude

-0.1

-0.2

-0.3

-0.4
0 2000 4000 6000 8000 10000 12000 14000 16000 18000
sample ke-n
Short time Autocorrelation Function

Program Matlab
%File Name: korelasi_01.m
[y,Fs]=wavread('ada.wav');

y1=y(1801:2440);
y1_c=xcorr(y1);yy=length(y1_c);
t=-yy/2:(yy/2)-1;length(t);
figure(1);plot(y1,'linewidth',2);grid on;axis([0 640 -.1 .1]);title('Unvoiced');
figure(2);plot(t,y1_c,'linewidth',2);grid on;axis([-yy/2 yy/2 -.1 .1]);
title('Korelasi Unvoiced');

y2=y(2501:3140);y2_c=xcorr(y2);
t=-yy/2:(yy/2)-1;length(t);
figure(3);plot(y2,'linewidth',2);grid on;
axis([0 640 -.1 .1]);title('Voiced');
figure(4);plot(t,y2_c,'linewidth',2);grid on;
axis([-yy/2 yy/2 -.5 1.1]); title('Korelasi Voiced');
Short time Autocorrelation Function
Segmen 0.1
Unvoiced

sinyal
0.08

0.06

0.04

0.02

Sinyal Unvoiced 0
Voiced
0.1 -0.02

-0.04
0.08
-0.06

0.06 -0.08

0.04 -0.1
0 100 200 300 400 500 600

0.02

-0.02

Sinyal-0.04
Voiced
-0.06

-0.08

-0.1
0 100 200 300 400 500 600
Short time Autocorrelation Function
Korelasi Unvoiced

Hasil 0.1

0.08

0.06

Autokorelasi 0.04

0.02

Unvoiced -0.02

-0.04

-0.06

-0.08

-0.1
-600 -400 -200 0 200 400 600

Korelasi Voiced

Voiced
0.5

-0.5
-600 -400 -200 0 200 400 600
4. Short time Fourier Transform
Untuk sinyal waktu diskrit, secara matematik
dituliskan sebagai:
sinyal dengan window tergeser

e xmwn me

j j m 9
X n
m

Dengan menggunakan sampel sinyal yang sama


pada file ada.wav
Hasil STFT bisa dilihat seperti berikut..
Short time Fourier Transform

%File Name: STFT_01.m


clear all;
[y,Fs]=wavread('ada.wav');

y1=y(1801:2440);
Y_1=20*log10(abs(fft(y1)));
ff=length(Y_1);
f=1:ff;
figure(1);plot((f/ff)*Fs,Y_1,'linewidth',2);
axis([0 Fs/2 -70 30]);
title('STFT Unvoiced');xlabel('frekuensi Hz');
ylabel('Mamgnitudo dB');grid on;

y2=y(2501:3140);
Y_2=20*log10(abs(fft(y2)));
f=1:length(Y_2);
figure(2);plot((f/ff)*Fs,Y_2,'linewidth',2);
axis([0 Fs/2 -70 30]);
title('STFT Voiced');xlabel('frekuensi Hz');
ylabel('Mamgnitudo dB');grid on;
Short time Fourier Transform
STFT Unvoiced
30

20

10

STFT Segmen Voiced 0

Mamgnitudo dB
-10

-20

-30

STFT Voiced -40


30
-50
20
-60
10
-70
0 0 1000 2000 3000 4000 5000 6000 7000 8000
frekuensi Hz
Mamgnitudo dB

-10

-20

-30

-40
STFT Segmen Voiced
-50

-60

-70
0 1000 2000 3000 4000 5000 6000 7000 8000
frekuensi Hz
5. Spectrogram Sinyal Wicara
Spectrogram merupakan suatu tampilan sederhana pada magnitudo STF.
Secara spesifik, gambar disamping merupakan gambaran dari sebuah fungsi
matematik berikut ini:

S (tr , f k ) 20 log X rR k 20 log 10 X rR k


~

Dimana
sb-x: domain waktu
tr=rRT

Sb-y: domain frekuensi


fk = k(NT)
Spectrogram Sinyal Wicara

Gambaran Spectrogram dengan wavesurfer

Frekuensi

Magnitudo

Waktu
Spectrogram Sinyal Wicara

Untuk kata ada

clear all;
Fs=10000;
[y,Fs]=wavread('ada.wav');
y_res=resample(y,16000,Fs);

figure(1) 1
plot(y_res) 0.9
axis off; 0.8

0.7
figure(2)
0.6
specgram(y_res)
Frequency

0.5

0.4

0.3

0.2

0.1

0
1000 2000 3000 4000 5000 6000 7000 8000
Time
Tugas
Buat sebuah perekaman untuk kalimat saya mahasiswa politeknik
elektronika negeri surabaya. Ucapkan dengan prosodi normal,
sehingga lawan bicara anda merasa jela waktu mendengarkannya.
Lakukan pembentukan frame-frame dalam hal ini durasi satu frame
20 ms dan tanpa overlapping antar frame
Lakukan pemilahan voice dan silent/unvoice dengan menggunakan
teknik zero crossing. Hitung berapa prosentase waktu yang berisi
voice? Berapa prosentase waktu berisi unvoice/silent?
Ambil salah satu frame yang brerisi sinyal voice, lakukan proses
autokorelasi, dan hitung jarak antar dua puncak berdekatan.
Lakukan hal yang sama untuk sinyal unvoice, dan amati perbedaan
mendasar dari hasil proses autokorelasi terhadap dua kondisi sinyal
tersebut.

You might also like