Sunday, January 23, 2011

Progress Bar Demo

import java.awt.*;
import javax.swing.*;
Interface Design
class Progress extends JFrame{
PbThread t1;
JProgressBar pb;
JLabel l;

Progress() {
super("Progress Bar");
setLayout(null);
setResizable(false);
setSize(300,100);

pb=new JProgressBar();
add(pb);
pb.setBounds(10,12,270,25);
l=new JLabel();
l.setText("");
add(l);
l.setBounds(120,40,97,25);

Dimension ss=Toolkit.getDefaultToolkit().getScreenSize();
Dimension ws=getSize();
this.setBounds((ss.width-ws.width)/2,(ss.height-ws.height)/2,ws.width,ws.height);

t1=new PbThread(pb,l);
t1.start();
}
public static void main(String args[]){
Progress p=new Progress();
p.setVisible(true);
}
}

Thread to show Progress
class PbThread extends Thread{
JProgressBar pb1;
JLabel l1=new JLabel();

PbThread(JProgressBar pb,JLabel l) {
this.pb1=pb;
this.l1=l;
}
public void run(){
pb1.setMaximum(100);
pb1.setMinimum(0);
for(int x=0;x<=100;x++) {
pb1.setValue(x);
l1.setText(x+"%");
try {
sleep(100);
}
catch(InterruptedException e) {
JOptionPane.showMessageDialog(null,e,"Error",JOptionPane.ERROR_MESSAGE);
}
if(x==100)
System.exit(0);
}
}
}

Thursday, January 13, 2011

Strangest Buildings in the World

Mind House (Barcelona, Spain)

Cathedral of Brasilia (Brazil)

La Pedrera (Barcelona, Spain)

Atomium (Brussels, Belgium)

Kansas City Library (Missouri, USA)

Rotating Tower, Dubai, UAE

Habitat 67 (Montreal, Canada)

Nautilus House (Mexico City, Mexico)

The National Library (Minsk, Belarus)

National Theatre (Beijing, China)

House Attack (Viena, Austria)

Bibliotheca Alexandrina (Egypt)

Cubic Houses (Kubus woningen) (Rotterdam, Netherlands)

Eden project (United Kingdom)

Montreal Biosphere (Canada)

Wonderworks (Pigeon Forge, TN, USA)

The Basket Building (Ohio, USA)

Kunsthaus (Graz, Austria)

Saturday, January 1, 2011

Speech Recognition Using Correlation

Correlation represents the similarities between the two signals. Here I use Correlation to recognize the uttered word (Expecially in the same voice).
First of all have to record the uttered word, sample it and save in a wav file and use this function to check whether it has already in the database.
Fs is the sampling frequency.

function speechRecog_corr(filename)

voice=wavread(filename); % READ THE FILE
x=voice;
x=x';
x=x(1,:); % GET THE FIRST RAW
x=x';

y1=wavread('test1.wav');
y1=y1';
y1=y1(1,:);
y1=y1';
z1=xcov(x,y1); % FIND THE COVARIANCE
m1=max(z1);

y2=wavread('test2.wav');
y2=y2';
y2=y2(1,:);
y2=y2';
z2=xcov(x,y2);
m2=max(z2);

y3=wavread('test3.wav');
y3=y3';
y3=y3(1,:);
y3=y3';
z3=xcov(x,y3);
m3=max(z3);

y4=wavread('test4.wav');
y4=y4';
y4=y4(1,:);
y4=y4';
z4=xcov(x,y4);
m4=max(z4);

y5=wavread('test5.wav');
y5=y5';
y5=y5(1,:);
y5=y5';
z5=xcov(x,y5);
m5=max(z5);

m6=5; % SET THE REFERENCE
a=[m1 m2 m3 m4 m5 m6];
m=max(a); % GET THE MAXIMUM CORRELATION

if m<=m1
    soundsc(wavread('test1.wav'),Fs) % PLAY THE FILE
        elseif m<=m2
    soundsc(wavread('test2.wav'),Fs)
        elseif m<=m3
    soundsc(wavread('test3.wav'),Fs)
        elseif m<=m4
    soundsc(wavread('test4.wav'),Fs)
        elseif m<=m5
    soundsc(wavread('test5.wav'),Fs)
        else % IF NOT ALREADY KNOWN WORD
soundsc(wavread('denied.wav'),Fs) 
end