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

Basics of Java Speech Grammar Format ( JSGF ) ( 12 - Mar - 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,


Just a quick update ( 4 - Mar - 2010 )

Hello everyone.

I’m busy in developing a Web/Desktop/Networking based application for European client of MBNInformatics in which Web part is developed in PHP and Desktop part is developed in Java and Networking is required in both sides.

And why i’m posting this update ? Reason is Help requests from Guests/Users. Firstly i would like to thank all of you, that you found me capable for solving your technical problems. And I’m extremely sorry to those I haven’t replied yet.

I have noted all your requests and i will try to solve all of them as soon as i get some free time. Also please be patient as i have about 14 help requests But i will reply you for sure. :)

Regards,


Happy Holi Everyone ! ( 28 - Feb - 2010 )

Happy Holi

Enjoy Everyone! :D


Video Capturing In Java Using JMF ( 7 - Feb - 2010 )

Hello Everyone,

I’m back with something new, while exploring Java and this time the API is : Java Media Framework (JMF).

Well this time I’m going to share how you can create Video Capturing Application Or you can say a Webcam in Java using JMF API.

Here’s a cap :
Cap Of Video Capturing Application Created In Java

No more words and without wasting more time. Lets get to the main point.

Here’s the code :  Click Here
Comments on all main lines of code are provided in file.

More to come soon!..


Statistics Day ! ( 2 - Feb - 2010 )

Statistics for Puneet Kalra’s Blog

  • 400 Successful Days
  • Single Domain ( puneetk.com )
  • Hosted by 2 Webhosts ( servage & globat )
  • Faced 1 Server crash
  • 7 major projects
  • 2 open source projects ( pikk & pwing )
  • 20 articles published
  • Used 3 wordpress themes
  • 69 comments posted
  • 4000+ spam comments ( 270+ spam on pending )
  • Visitors from 55 countries ( 220 cities, Mostly from India, USA, UK, Israel, Germany & Chile )
  • 2530 Visits and 6583 Pageviews
  • 554 Unique Followers
  • 310 relative searches on Google
  • 121 pages cached by Google
  • and thousands of hours spent on exploring java and other technologies..

Happy Statistics Day! :D