Puneet Kalra - www.Puneetk.com

home | pwing | pikk

biography | facebook | contact

“Developing real time human a like robotics system with extra ordinary artificial intelligence, Not only artificial intelligence. A system that can learn new things itself” ~Puneet Kalra

< SUBSCRIBE >VIA FACEBOOK
FAVOURITES
Videos »
GET INSPIRED

Posts Tagged ‘Java’

Basics of Java Speech Grammar Format ( JSGF )

March 12th, 2010

Hello Everyone,

This post is my response to those 4 help requests that i received in last few days. This one is going to be very basic and essentials of Java Speech Grammar Format ( JSGF ).

Every single file defines a single grammar only. Each grammar contains two parts:
The grammar header and the grammar body.

Grammar header format : #JSGF version char-encoding locale;

“#JSGF” is required and “version char-encoding locale;” is optional.

Grammar header example : #JSGF V1.0; & #JSGF V1.0 ISO8859-5 en;



After declaring Grammar Header, We need to specify the Grammar name.

Grammar name format : grammar grammarName;

This is a mandatory line. Else javax.speech.recognition.GrammarException will be thrown. Not only on Grammar Name, you will get GrammarExpection If you made any kind of mistake in grammar file.

Grammar Name Example : grammar helloWorld;



Once you are done with above part, you next step will be defining Grammar body.
The grammar body defines rules. you can define a rule only once. If you declare same rule twice then it will overwritten.

Rule Definition Format : public <ruleName> = ruleExpansion;

“public” is optional and remaining part is mandatory.
The rule expansion defines how the rule may be spoken. It is a logical combination of tokens (text that may be spoken) and references to other rules.

Rule Example : public <greet> = Hello;

The rule <greet> refers to a single token Hello. So to say rule <greet>, User must say word “Hello”.

A simple rule expansion can refer to one or more tokens or rules.

public <greet> = Hello;
public <completeGreet> = <greet> World;

Now, rule <completeGreet> refers to rule <greet> and token World. To say rule <completeGreet>, User must say “Hello World”.

Lets complete a simple “Hello World” grammar file.

#JSGF V1.0;

grammar simpleExample;

public <greet> = Hello;
public <completeGreet> = <greet> World;

This grammar file will allow you SR application to recognize 2 sentences. “Hello” and “Hello World”.

Now lets play a little bit with rule expansions.

Alternatives : “|”

public <greet> = Hello | Hey | Hi;

To say rule <greet>, User must say “Hello” or “Hey” or “Hi” But ONLY one of these three words.

Parentheses : “( )”

public <greet> = Hello ( World | User | Friend );
public <command> = ( Open | Close ) ( Door | Window );

To say rule <greet>, User must say “Hello World” or “Hello User” or “Hello Friend”.
And, to say rule <command>, User must say “Open Door” or “Open Window” or “Close Door” or “Close Window”.

Optional Grouping : “[ ]”

public <greet> = [ Hello ] World;

To say rule <greet>, User must say “Hello World” or “World”. As “Hello” is defined inside the Optional Grouping. So user may say it or not but “World” is mandatory.

Kleene Star : “*”

public <greet> = ( Hello | Hey | Hi )* World;

Any group or expansion followed by asterisk symbol indicates that it may be spoken zero or more times. For example “Hey Hello World” or “World” or “Hello Hello Hello World”.

Plus Operator : “+”

public <greet> = ( Hello | Hey | Hi )+ World;

A Plus Operator works same as “Kleene Star”, The only thing that makes difference is any group or expansion followed by plus symbol indicates that it may be spoken one ( NOT ZERO ) or more times.

You can also add comments in grammar file.

// One line comment
/* Multiple lines comment*/
/**
* Documentation comment
* @author Puneet Kalra
*/


Hope this tutorial clears all your doubts on JSGF.

More updates to come soon!
Regards,

Another Open Source Project (Pwing)

January 28th, 2010

Finally,

We have published “Pwing”, An other Open Source project.

Pwing Logo Pwing is a GUI toolkit, Is a set of widgets/components for use in designing applications with graphical user interfaces (GUI’s). It is based on Swing toolkit, part of Sun Microsystem’s Java Foundation Classes (JFC) API. It is developed to provide a better set of components to create more interactive GUI based applications in Java. Each component facilitates a specific user-computer interaction, and appears as a visible part of the computer’s GUI.
 

Pwing Example

 



Examples, Executable JAR’s , Source JAR’s and Complete package is available for download.


Official Pwing Website : http://puneetk.com/pwing
Pwing’s SF Website : http://sourceforge.net/projects/pwing/


Regards,

Pwing

January 22nd, 2010
Pwing - Custom GUI for Java

Pwing - Custom GUI for Java

Introducing Pwing ..

Pwing is a GUI toolkit, Is a set of widgets/components for use in designing applications with graphical user interfaces (GUI’s). It is based on Swing toolkit, part of Sun Microsystem’s Java Foundation Classes (JFC) API. It is developed to provide a better set of components to create more interactive GUI based applications in Java. Each component facilitates a specific user-computer interaction, and appears as a visible part of the computer’s GUI.

Pwing is currently being developed by a merge team of my trainees and Parul Kalra’s trainees at MBN Informatics. Soon it will be published as Open Source project on SourceForge.

Stay tuned !

Expanding Dictionary Of Acoustic Model

January 5th, 2010

Hello Everyone,

Today I’m going to tell you how to expand dictionary of acoustic model for Sphinx4. In simple words, This tutorial will tell you how you can add more words in Sphinx’s words database (Dictionary) and let it recognize those words, which are not available in default acoustic models provided by CMU Sphinx. This tutorial is based on “HelloWorld” example provided by CMU Sphinx.

Important Files in this example :
1 ) HelloWorld.java
2) hello.gram
3) helloworld.config.xml

Acoustic Model used in this example :
WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar

Lets say, We are creating a SR system for ABC National airlines. Everything will go fine and Sphinx will recognize most of the words except the name of cities and states of India.  Now, I will tell you, How to add name of cities and states in dictionary.

PART ONE
Step 1 :
Create a txt file “words.txt”, Write all the names of cities and states in it and save.
Step 2 : Open this link : http://www.speech.cs.cmu.edu/tools/lmtool.html
Step 3 : On that page, go to “Sentence corpus file:” section, Browse to “words.txt” file and click “Compile Knowledge Base”.
Step 4 : On next page, Click on “Dictionary” link and save that .DIC file.

PART TWO
Step 1 : Extract WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar file.
Step 2 : Go to edu\cmu\sphinx\model\acoustic\WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz\dict folder.
Step 3 : Open “cmudict.0.6d” file in that folder.
Step 4 : Copy data from .DIC file, you have downloaded in PART ONE, paste it in “cmudict.0.6d” file and save.
Step 5 : Zip the extracted hierarchy back as it was and Zip file named should be same as JAR file.

Now, remove “WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar” file from Project’s CLASSPATH and add “WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.zip” instead of it.

That’s it ! We are done.  Now Sphinx will also recognize all name of cities and states that we wrote in “words.txt” file.
Now, FAQ time. I will be posting FAQ and few important notes in comments. :)

If you have any quires, Please feel free to ask.
Regards,

I’m still alive

November 24th, 2009

Hello everyone,

It’s been almost a month, I haven’t updated my website.  Just 3 weeks left to my final exams for 2 years technical diploma (ANIIT) from NIIT.  And i will have to attend 2 exams ( EJB 3.0, and Software Testing / Quality Assurance ) plus I will have to submit a project before i can attend those exams.  My topic for project is “Image processing”. I’m not really worried about exams and project. Project is almost done. :)

My current research topics :
Computational linguistics , and Continuous Speech Recognition Algorithms

Now a days, I’m working with Spain based company named <UNDEFINED> is Official Adobe’s Enterprise Solution Partner. They have a long list of technologies for developing Desktop and Web based RIA’s but they mainly work on : Adobe Flex, Adobe AIR, Adobe Flash With PHP and Java.  Company’s Website

That’s it for now ! Signing off.

Puneet Kalra