0

I am developing small voice based interaction tool using sphinx (Speech to Text) and FreeTTS(Text to Speech) in java.

for eg : FreeTTS gives voice command like Name : user will reply his name and age and place.everything is static.

How to write hello.gram in sphinx to achieve this

public<greet>=[<name>] [<age>] [<place>];
<name> = john | max;
<age> = ten | nine ;
<place> = France | Spain;

Voice command : What is your name my reply : Max

Observation : Max ten

Voice command : what is your age my reply : nine

Observation : nine France

I want only names should be observed when i say name.its highly intermittent too :(

Thanks in advance.

modified based on Alexander's answer.

Community
  • 1
  • 1
Spartan
  • 3,213
  • 6
  • 26
  • 31

2 Answers2

1

There is no magical method to do what you want. You have to specify all phrases that you want to be recognized in your grammar. The only thing I can recommend is to factorize some rules, e.g. numbers:

<digits> = one | two | three | four ;
<decades> = twenty | thirty | forty ;
<numto44> = <decades> | <decades> <digits> ;

Alexander Solovets
  • 2,447
  • 15
  • 22
  • 1
    thanks your input and i tried what you mentioned. public = [ ] [ ] []; sometime decades getting printed when i say digits. How to code when i want to say name , only the names which i mentioned only has to recognize. after that i will say digits. – Spartan Nov 20 '15 at 11:39
  • Take a look at this http://cmusphinx.sourceforge.net/doc/sphinx4/edu/cmu/sphinx/jsgf/JSGFGrammar.html to learn how JSGF rules are composed. Note, that you can also add weights to your rules. In case of ambiguity the rule with the higher weight is favored. – Alexander Solovets Nov 20 '15 at 15:30
0

You can use below code to avoid it .

public <name> = john | max;
public <age> = ten | nine ;
public <place> = France | Spain;
Spartan
  • 3,213
  • 6
  • 26
  • 31