Friday, March 4, 2011

Speech Recognition By Java - Simplified



Speech recognition is one of the challenging areas in computer science, a lot of pattern recognition methodology tried to resolve a good way and higher percentage of recognition.

One of the best ways to be use is Hidden Markov Model :



"The process of speech recognition is to find the best possible sequence of words (or units) that will fit the given input speech. It is a search problem, and in the case of HMM-based recognizers, a graph search problem. The graph represents all possible sequences of phonemes in the entire language of the task under consideration. The graph is typically composed of the HMMs of sound units concatenated in a guided manner, as specified by the grammar of the task."

There are a lot of Java Based Speech Recognition Engines, you can find them here:

http://ocvolume.sourceforge.net/links.php.

In this post we will select one of the famous open source Java speech recognition software and identify simple steps to use it.

Sphinx-4

Sphinx-4 is a state-of-the-art speech recognition system written entirely in the JavaTM programming language. It was created via a joint collaboration between the Sphinx group at Carnegie Mellon University, Sun Microsystems Laboratories, Mitsubishi Electric Research Labs (MERL), and Hewlett Packard (HP), with contributions from the University of California at Santa Cruz (UCSC) and the Massachusetts Institute of Technology (MIT).

Sphinx-4 started out as a port of Sphinx-3 to the Java programming language, but evolved into a recognizer designed to be much more flexible than Sphinx-3, thus becoming an excellent platform for speech research.


1) Download the software:

Here is the download link:

http://sourceforge.net/projects/cmusphinx/files/sphinx4/1.0%20beta6/sphinx4-1.0beta6-bin.zip/download.

2) Create new Java project:

Add to class-path 3 jars from the lib folder:
jsapi.jar (if not exist jsapi.exe will extract it on windows or jsapi.sh will extract it)
sphinx4.jar (APIs Jar)
WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar (this is the jar containing the speech)


3) Create a new class to write the logic on it: e.g. ListenToMe.java
Let the package name osa.ora

4) Add the file dict.gram to the same package: osa.ora
It should looks like:
#JSGF V1.0;
grammar hello;
public <greet>= (Good morning | Hello | Hi | Welcome) ( Osama | Paul | Philip | Rita | Will );

The structure is to write the alternative words between () and separated by | and give them tag name to describe these words (greet here).

The grammar specs in this URL:
http://www.w3.org/TR/jsgf/
A quick tutorial in this URL:
http://puneetk.com/basics-of-java-speech-grammar-format-jsgf


5) Add the config file myconfig.xml to the same package: osa.ora
You can get the file structure from the jar in bin folder HelloWorld.jar
in the location "HelloWorld.jar\edu\cmu\sphinx\demo\helloworld\helloworld.config.xml"

You need to edit the following entry:
<component name="jsgfGrammar" type="edu.cmu.sphinx.jsgf.JSGFGrammar">
<property name="dictionary" value="dictionary"/>
<property name="grammarLocation"
value="resource:/osa/ora/"/>
<property name="grammarName" value="dict"/>
<property name="logMath" value="logMath"/>
</component>

6) Write the following code in the created class:

import edu.cmu.sphinx.frontend.util.Microphone;
import edu.cmu.sphinx.recognizer.Recognizer;
import edu.cmu.sphinx.result.Result;
import edu.cmu.sphinx.util.props.ConfigurationManager;

public static void main(String args[]){
ConfigurationManager cm = new ConfigurationManager(ListenToMe.class.getResource("myconfig.xml"));
Recognizer recognizer = (Recognizer)cm.lookup("recognizer");
recognizer.allocate();
Microphone microphone = (Microphone)cm.lookup("microphone");
if(!microphone.startRecording()){
System.out.println("Cannot start microphone.");
recognizer.deallocate();
System.exit(1);
}
System.out.println("Say: (Good morning | Hello | Hi | Welcome) ( Osama | Paul | Philip | Rita | Will )");
do {
System.out.println("Start speaking. Press Ctrl-C to quit.\n");
Result result = recognizer.recognize();
if(result != null) {
String resultText = result.getBestFinalResultNoFiller();
System.out.println((new StringBuilder()).append("You said: ").append(resultText).append('\n').toString());
} else {
System.out.println("I can't hear what you said.\n");
}
} while(true);
}


As you can see you can use ConfigurationManager to re-set the grammarName to dict1 , dict2 ,..etc, you can also have multiple configurations.

For more details about the usage you can refer to this URL:

http://cmusphinx.sourceforge.net/sphinx4/

You may use Interactive4J implementation direct to achieve dynamic voice recognition.. Find more details here.

142 comments:

  1. Hi,

    I followed your instructions, but I have an exception:

    class not found !java.lang.ClassNotFoundException: edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.Model
    Exception in thread "main" Property exception component:'flatLinguist' property:'acousticModel' - component 'wsj' is missing

    How to solve it?

    Nice tutorial

    Cheers

    bren [at] juanantonio.info

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. You must add this jar to the classpath:

    WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar

    Thanks

    ReplyDelete
  4. I added but I continue with problems.
    is it possible to change that value or replace?

    http://img217.imageshack.us/f/sphinx4.png/

    Cheers

    ReplyDelete
  5. Could you send me your configuration files or project, seems there is something with configuration...

    ReplyDelete
  6. <property name="dictionaryPath"
    value="resource:/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz/dict/cmudict.0.6d"/>
    <property name="fillerPath"
    value="resource:/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz/dict/fillerdict"/>

    ReplyDelete
  7. Hi Osama, I solved my problem with your help. My problem was located in configuration file.

    Cheers

    ReplyDelete
    Replies
    1. We are facing same problem . Could you plz mention what changes you did in config file ?

      Delete
    2. Hello Sir, i got the same error with edu.I checked the config file.Everything is fine but error is not getting rectified.

      Thanks

      Delete
  8. Dear Osama,

    i tried every thing but it did not work and i think the problem in fillerdict as it is not there in the jar file, can you tell me what to do?

    ReplyDelete
  9. What is the issue or the exception?

    ReplyDelete
  10. hi ossama:
    i have problem in configuration manager please send this file to me
    thanks

    ReplyDelete
  11. what do you mean by configuration manager ? you mean configuration file ?

    ReplyDelete
  12. yes osama but this problem have been solved thanks for you

    can you tell me how can i changes words in grammer if i need this

    thanks

    ReplyDelete
  13. Just edit the file using notepad or similar apps and add whatever you want , if any word is unsupported you will see warning.

    ReplyDelete
  14. sorry i can't understand what do you mean i change words in grammer file and in java class but the output is the same words in helloworld example

    ReplyDelete
  15. In configuration file, you must point to this new file location.

    ReplyDelete
  16. <property name="grammarLocation"
    value="resource:/osa/ora/"/>
    <property name="grammarName" value="dict"/>

    ReplyDelete
  17. or use the following location (outside your jar) :
    <property name="grammarLocation"
    value="file:///C:/config/"/>

    ReplyDelete
  18. osama i need to add this words to my app(category-next-previous-select- sub category- product-go category-feature product-go first category)
    please did you send to me your mail in<azza_az20@yahoo.com)to send to you my application to edit this words
    i need this quickly because it is part of graduation project and it will deliver in 21/7 pleas osama help me quickly\
    thanks for you

    ReplyDelete
  19. My advice is to keep 1 word for each command : remove "go" for example also remove category so your dictionary looks like : First, Feature, Category, Product, Sub, Select, Next, Previous

    Try the application and remove the dominant words and replace them with alternatives with the same meaning. like Previous --> Back , Next -->Move ,...etc.. until you get the best results possible.

    ReplyDelete
  20. Hi Osama,

    This is a good post.

    I have followed all the steps
    1. I created a eclipse project
    2. Copied the jar files/class files.
    3. Execute the project

    i get the following error

    Exception in thread "main" java.lang.NullPointerException
    at osa.ora.ListenToMe.main(ListenToMe.java:12)


    For the line number 12, which is

    Recognizer recognizer = (Recognizer)cm.lookup("recognizer");
    recognizer.allocate();

    Could you please help me with this ..
    What is ur email id ???

    ReplyDelete
  21. thanks ossama the program is running but what i have to achieve the accuracy

    thanks

    ReplyDelete
  22. Ensure the configurations are correctly in the class-path and all needed jars exist in the class path.

    ReplyDelete
  23. What if I want to use Arabic words in the grammar
    Thanks

    ReplyDelete
  24. The correct way is to have a new language that support this implementation for Arabic because this current implementation for English, so i advice you to search for another way if you need it quickly as this need a lot of time and effort plus a big team work to develop it.

    ReplyDelete
  25. hello Mr Osama
    You have wrote a great article...
    thanks for this
    i am trying to run a simple application using sphinx as guided by you in this article and am not able to run the application but got the exception
    D:\Sound>java -mx256m osa.ora.ListenToMe
    Exception in thread "main" java.lang.RuntimeException: searchManager: allocation
    of search manager resources failed
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.allocat
    e(SimpleBreadthFirstSearchManager.java:643)
    at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:
    87)
    at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:168)
    at osa.ora.ListenToMe.main(ListenToMe.java:13)
    Caused by: java.io.FileNotFoundException: JAR entry WSJ_8gau_13dCep_16k_40mel_13
    0Hz_6800Hz//means not found in D:\API's & Look and Feels\speech data\sphinx4-1.0
    beta4-bin\sphinx4-1.0beta4\lib\WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar
    at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.ja
    va:122)

    please help...
    or send me a simple ListenToMe project
    Thanx.....

    ReplyDelete
  26. The exception said file not found , so either file is not found in the mentioned location or corrupted , you need to include it in your class path , this jar is part of Sphinx4 library:
    java.io.FileNotFoundException: JAR entry WSJ_8gau_13dCep_16k_40mel_13
    0Hz_6800Hz//means not found in D:\API's & Look and Feels\speech data\sphinx4-1.0
    beta4-bin\sphinx4-1.0beta4\lib\WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar

    ReplyDelete
  27. Hello Mr Osama..
    Thank you for reverting back
    I have tried that again but getting the same exception
    even i tried to compile and run the Helloworld example provided with sphinx, the file compiles with but fails to run with same exception
    the strange thing is that the compile jar(i.e Helloworld.jar) provided with sphinx runs well,
    is there any way to get help or running example
    Thanks

    ReplyDelete
  28. I guess this is because the Jar exist in the same folder with HelloWorld jar file so it run without any issues.

    ReplyDelete
  29. hi,
    i have followed all the steps mentioned above.but i'm getting the following error..plz help me
    Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Error while parsing line 1 of file:/C:/Program%20Files/Java/speechtotext/sphinx/bin/osa/ora/myconfig.xml: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    at edu.cmu.sphinx.util.props.ConfigurationManager.(ConfigurationManager.java:61)
    at osa.ora.helloworld.main(helloworld.java:10)
    Caused by: java.io.IOException: Error while parsing line 1 of file:/C:/Program%20Files/Java/speechtotext/sphinx/bin/osa/ora/myconfig.xml: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    atedu.cmu.sphinx.util.props.SaxLoader.load(SaxLoader.java:77)
    at edu.cmu.sphinx.util.props.ConfigurationManager.(ConfigurationManager.java:59)
    ... 1 more

    ReplyDelete
  30. The exception is clear , your configuration file: myconfig.xml is not valid, please revisit it and if you failed send to me to fix it.

    ReplyDelete
  31. Hello sir I am getting the following Exceptions:

    Exception in thread "main" java.lang.NoSuchFieldError: engineListeners
    at com.sun.speech.engine.recognition.BaseRecognizer.fireRecognizerSuspended(BaseRecognizer.java:979)
    at com.sun.speech.engine.recognition.BaseRecognizer.dispatchSpeechEvent(BaseRecognizer.java:1272)
    at com.sun.speech.engine.SpeechEventUtilities.postSpeechEvent(SpeechEventUtilities.java:201)
    at com.sun.speech.engine.SpeechEventUtilities.postSpeechEvent(SpeechEventUtilities.java:132)
    at com.sun.speech.engine.recognition.BaseRecognizer.postRecognizerSuspended(BaseRecognizer.java:967)
    at com.sun.speech.engine.recognition.BaseRecognizer.commitChanges(BaseRecognizer.java:377)
    at edu.cmu.sphinx.jsapi.JSGFGrammar.commitChanges(JSGFGrammar.java:620)
    at edu.cmu.sphinx.jsapi.JSGFGrammar.createGrammar(JSGFGrammar.java:318)
    at edu.cmu.sphinx.linguist.language.grammar.Grammar.allocate(Grammar.java:163)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.allocate(FlatLinguist.java:319)
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.allocate(SimpleBreadthFirstSearchManager.java:602)
    at edu.cmu.sphinx.decoder.Decoder.allocate(Decoder.java:109)
    at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:182)
    at com.speech.Speech2Text.main(Speech2Text.java:14)

    please help me.

    ReplyDelete
  32. Exception in thread "main" "Exception: Allocation of search manager resources failed..."

    Please Tell me that how to solve it..I have waste two days to solve..but I cannot go forward..My e-mail is iro.amila@gmail.com

    ReplyDelete
  33. This exception "Exception in thread "main" java.lang.NoSuchFieldError: engineListeners" seems to be related to incorrect version used or conflict in your jars... you may use my follow the steps and re-test..

    ReplyDelete
  34. hello Mr Osama,
    I checked all configurations, but I'm still getting the following Exceptions:

    Exception in thread "main" java.lang.RuntimeException: Allocation of search manager resources failed
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.allocate(SimpleBreadthFirstSearchManager.java:650)
    at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:87)
    at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:168)
    at test.helloWorld.main(helloWorld.java:14)
    Caused by: java.io.IOException: edu.cmu.sphinx.jsgf.JSGFGrammarParseException
    at edu.cmu.sphinx.jsgf.JSGFGrammar.createGrammar(JSGFGrammar.java:304)
    at edu.cmu.sphinx.linguist.language.grammar.Grammar.allocate(Grammar.java:116)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.allocate(FlatLinguist.java:300)
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.allocate(SimpleBreadthFirstSearchManager.java:646)
    ... 3 more
    Caused by: edu.cmu.sphinx.jsgf.JSGFGrammarParseException
    at edu.cmu.sphinx.jsgf.parser.JSGFParser.newGrammarFromJSGF(JSGFParser.java:132)
    at edu.cmu.sphinx.jsgf.parser.JSGFParser.newGrammarFromJSGF(JSGFParser.java:241)
    at edu.cmu.sphinx.jsgf.JSGFGrammar.loadNamedGrammar(JSGFGrammar.java:697)
    at edu.cmu.sphinx.jsgf.JSGFGrammar.commitChanges(JSGFGrammar.java:613)
    at edu.cmu.sphinx.jsgf.JSGFGrammar.createGrammar(JSGFGrammar.java:300)
    ... 6 more

    Thanks a lot.

    ReplyDelete
  35. This seems related to your grammer file, please try to validate its syntax again.

    ReplyDelete
  36. You were right, instead of:
    "public = (Good morning | Hello | Hi | Welcome) ( Osama | Paul | Philip | Rita | Will );"
    I used:
    "public = (Good morning | Hello | Hi | Welcome) ( Osama | Paul | Philip | Rita | Will );" as in examples.

    Thanks a lot.

    ReplyDelete
    Replies
    1. Same problem :(

      Please tell more how did you solve this one >> thanks

      Delete
    2. Ok thanks now it is running correctly ..

      Delete
  37. hello
    this site is vv v useful
    m not finding dict.gram file
    wer is it located?
    waiting for reply
    thanks

    ReplyDelete
  38. You need to create this file yourself using any text editor and locate it in your class package : Here is the sample of this file content:
    #JSGF V1.0;
    grammar hello;
    public = (Good morning | Hello | Hi | Welcome) ( Osama | Paul | Philip | Rita | Will );

    ReplyDelete
    Replies
    1. hi i worked this project in netbeans but this error appear :
      Exception in thread "main" java.lang.NullPointerException
      at edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.ModelLoader.loadProperties(ModelLoader.java:372)
      at edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.ModelLoader.getIsBinaryDefault(ModelLoader.java:386)
      at edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.ModelLoader.newProperties(ModelLoader.java:346)
      at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:214)
      at edu.cmu.sphinx.util.props.ValidatingPropertySheet.getComponent(ValidatingPropertySheet.java:403)
      at edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.Model.newProperties(Model.java:159)
      at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:214)
      at edu.cmu.sphinx.util.props.ValidatingPropertySheet.getComponent(ValidatingPropertySheet.java:403)
      at edu.cmu.sphinx.linguist.flat.FlatLinguist.setupAcousticModel(FlatLinguist.java:299)
      at edu.cmu.sphinx.linguist.flat.FlatLinguist.newProperties(FlatLinguist.java:246)
      at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:214)
      at edu.cmu.sphinx.util.props.ValidatingPropertySheet.getComponent(ValidatingPropertySheet.java:403)
      at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.newProperties(SimpleBreadthFirstSearchManager.java:180)
      at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:214)
      at edu.cmu.sphinx.util.props.ValidatingPropertySheet.getComponent(ValidatingPropertySheet.java:403)
      at edu.cmu.sphinx.decoder.Decoder.newProperties(Decoder.java:71)
      at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:214)
      at edu.cmu.sphinx.util.props.ValidatingPropertySheet.getComponent(ValidatingPropertySheet.java:403)
      at edu.cmu.sphinx.recognizer.Recognizer.newProperties(Recognizer.java:93)
      at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:214)
      at HelloWorld.main(HelloWorld.java:37)



      this is line 37:



      Recognizer recognizer = (Recognizer) cm.lookup("recognizer");

      Delete
    2. You need to add the WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar file as a project dependency.
      In Eclipse, in the pom.xml file, I added:

      cmu.sphinx
      WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz
      4.0

      Then, I did a local Maven install from Git Bash command line:
      mvn install:install-file -Dfile="/Users/sizu/Desktop/sphinx4-1.0beta6-bin/sphinx4-1.0beta6/lib/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar" -DgroupId="cmu.sphinx" -DartifactId="WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz" -Dversion="4.0" -Dpackaging="jar"

      Delete
  39. hi Osama
    I worked on the project in netbeans but always error appear on this line :
    Recognizer recognizer = (Recognizer) cm.lookup("recognizer");
    how I fix that ?

    ReplyDelete
    Replies
    1. But I add the xml file to the same path of the java file
      !!!
      and i adjust the path in the project :

      url = new File("C:\\Users\\pc2020\\Desktop\\New folder\\sphinx4-1.0beta\\bin\\HelloWorld.jar\\edu\\cmu\\sphinx\\demo\\helloworld\\helloworld.config.xml").toURI().toURL();

      Delete
    2. but i add the xml file into the same path into the path of java file :

      url = new File("C:\\Users\\pc2020\\JavaApplication10\\src\\e.xml").toURI().toURL();

      Delete
  40. Just add the file to the same location of your path, and do the needed modifications :
    <property name="grammarLocation"
    value="resource:/osa/ora/"/>
    <property name="grammarName" value="dict"/>

    ReplyDelete
  41. sorry can you write the modification according to my location
    Did you mean:




    or what !!!

    ReplyDelete
  42. hi again
    I've done all the steps again as it is written, but still error is???
    please help me this is important step in my project?

    ReplyDelete
    Replies
    1. send me your eamil / or your Netbeans project to fix the issue.

      Delete
    2. I examined your work , the issue is that you have named the grammer as hello.gram , while in configuration file it is dict.gram:

      <property name="grammarName" value="dict"/>
      change this into:
      <property name="grammarName" value="hello"/>

      Delete
  43. xception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.lang.String.toLowerCase(String.java:2474)
    at java.lang.String.toLowerCase(String.java:2497)
    at edu.cmu.sphinx.linguist.dictionary.FastDictionary.loadDictionary(FastDictionary.java:259)
    at edu.cmu.sphinx.linguist.dictionary.FastDictionary.allocate(FastDictionary.java:198)
    at edu.cmu.sphinx.linguist.language.grammar.Grammar.allocate(Grammar.java:112)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.allocate(FlatLinguist.java:300)
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.allocate(SimpleBreadthFirstSearchManager.java:646)
    at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:87)
    at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:168)
    at speechrecog.ListenToMe.main(ListenToMe.java:20)

    ReplyDelete
    Replies
    1. Seems memeory issue, can you try again and take memory dump and analyze it... can u send me ur project?

      Delete
  44. hello Osama,

    Can I use Sphinx engine for languages with non latin alphabets like Arabic? Thanks

    ReplyDelete
  45. hello Osama i am actually working over a project "voice controlled desktop " which involves speech recognition but i am facing this very strange problem : "Can't open microphone line with format PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, big-endian not supported."
    this error appears when i navigate from one page to another in my project . Could u help me to solve this problem

    ReplyDelete
    Replies
    1. Seems you need to close it before navigating to the other pages then re-open it again.

      Delete
    2. Thanx for ur reply . but i am already doing this by using command Recognizer.deallocate() but still this error is appearing. may be i m missing some steps
      could u explain me in steps using sphinx commands how should i navigate from one page to another it will be great help to me.

      Delete
    3. Can you have a look on my interactive4J application, i did use it without any issues, you may download the code and see my wrapper and the demo?

      Delete
  46. Thanx a lot ! this project of urs will be great help to me. I must say u are truly genius i just went through all ur projects they are so much authentic and full of innovation & intelligence .

    ReplyDelete
  47. Hello Osama!! i m being able to run in netbeans bt the output is running in the console as its a .java file...how can i mk it run in the browser?

    ReplyDelete
    Replies
    1. what browser ? you can check interactive browser one of my open source projects to see how you can do this ...

      Delete
    2. Thnx 4 the reply...wl check out ur open source projct...n i m talking abt browsers like internet explorer,google chrome,firefox etc...actually i m working on a project that will conduct examination 4 da blind people...sphinx-4 helped me in the conversion from speech 2 text.bt at times it cudn't recognise correctly(like 'four' s recognised as 'two').cn u gv me any suggestions to rectify dt? n also i hv 2 mk it work in da browser.

      Delete
  48. Hello, Can you help me fix the config file(Netbean project)

    thank you for your reply.

    http://www.mediafire.com/?evq06u94j5qafq1

    ReplyDelete
    Replies
    1. Maybe I know what is the problems about the .xml file ?

      If I follow your example above, it should be the path location causes the null pointer exception. thanks in advance.

      Delete
    2. May I know what is the problem for the netbean project? I'm think it's the .xml file can't find the location path. If I follow the example above, it causes null pointer exception, I'm think the problems occurred in .xml file because the path is not defined correctly. thanks in advance.

      Delete
    3. I checked your file, the path is invalid and the filename as well ..
      resource:file:C\\Users\\User\\Documents\\NetBeansProjects\\osa.ora\\

      the prefix resource: means it is a resource inside the jar so use relative path as in my example, in your project you didn't define a package for your java classes (this is not good) any way the value should be in that case resource:/

      the filename in your example is : hello.gram so the other value:
      <property name="grammarName" value="hello"/>

      Delete
    4. Hello Osama Oransa, thank for your help and explaination, now I can run my sample program.

      Delete
  49. Hi Osama,
    its an amazing example to start with.
    can you please mail or post an example of dictation grammar.
    please it will be of great help

    ReplyDelete
    Replies
    1. Please clarify what you mean ? an example of grammer file is already in the post.

      Delete
  50. Hi osama!great tutorial!
    I have a problem: I followed all the steps of the tutorial and I have no errors in compilation, but the program remains on after being launched Say: (Good morning | Hello | Hi | Welcome) (Usama | Paul | Philip | Rita | Will)
    Start speaking. Press Ctrl-C to quit.

    and then nothing happens .. why?

    ReplyDelete
    Replies
    1. I guess this is a mic problem, try to speek these words until it recognizes any of them..

      Delete
  51. Hi osama, i have this problem

    Exception in thread "main" java.lang.RuntimeException: Allocation of search manager resources failed
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.allocate(SimpleBreadthFirstSearchManager.java:650)
    at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:87)
    at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:168)
    at osa.ora.ListenToMe.main(ListenToMe.java:13)
    Caused by: java.io.IOException: edu.cmu.sphinx.jsgf.JSGFGrammarParseException
    at edu.cmu.sphinx.jsgf.JSGFGrammar.createGrammar(JSGFGrammar.java:304)
    at edu.cmu.sphinx.linguist.language.grammar.Grammar.allocate(Grammar.java:116)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.allocate(FlatLinguist.java:300)
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.allocate(SimpleBreadthFirstSearchManager.java:646)
    ... 3 more
    Caused by: edu.cmu.sphinx.jsgf.JSGFGrammarParseException
    at edu.cmu.sphinx.jsgf.parser.JSGFParser.newGrammarFromJSGF(JSGFParser.java:132)
    at edu.cmu.sphinx.jsgf.parser.JSGFParser.newGrammarFromJSGF(JSGFParser.java:241)
    at edu.cmu.sphinx.jsgf.JSGFGrammar.loadNamedGrammar(JSGFGrammar.java:697)
    at edu.cmu.sphinx.jsgf.JSGFGrammar.commitChanges(JSGFGrammar.java:613)
    at edu.cmu.sphinx.jsgf.JSGFGrammar.createGrammar(JSGFGrammar.java:300)
    ... 6 more



    i checked grammar, ctrl c + ctr v in your sample, checked config.xml

    thanks for your help!

    ReplyDelete
  52. This is grammar syntax error , try to fix your grammar , may be special character exist.

    ReplyDelete
  53. hi osama i got the following error:

    Syntax error on token "void", @ expected
    Syntax error on token "String", instanceof expected after this token
    Syntax error, insert "enum Identifier" to complete EnumHeader

    at osa.ora.ListenToMe.main(ListenToMe.java:11)

    here is what i tried:

    package osa.ora;


    public class ListenToMe
    {
    import edu.cmu.sphinx.frontend.util.Microphone;
    import edu.cmu.sphinx.recognizer.Recognizer;
    import edu.cmu.sphinx.result.Result;
    import edu.cmu.sphinx.util.props.ConfigurationManager;


    public static void main(String args[]){

    ConfigurationManager cm = new ConfigurationManager(ListenToMe.class.getResource("myconfig.xml"));
    Recognizer recognizer = (Recognizer)cm.lookup("recognizer");
    recognizer.allocate();
    Microphone microphone = (Microphone)cm.lookup("microphone");
    if(!microphone.startRecording()){
    System.out.println("Cannot start microphone.");
    recognizer.deallocate();
    System.exit(1);
    }
    System.out.println("Say: (Good morning | Hello | Hi | Welcome) ( Osama | Paul | Philip | Rita | Will )");
    do {
    System.out.println("Start speaking. Press Ctrl-C to quit.\n");
    Result result = recognizer.recognize();
    if(result != null) {
    String resultText = result.getBestFinalResultNoFiller();
    System.out.println((new StringBuilder()).append("You said: ").append(resultText).append('\n').toString());
    } else {
    System.out.println("I can't hear what you said.\n");
    }
    } while(true);
    }

    }

    plz help me

    ReplyDelete
    Replies
    1. Ensure your imports are complete , here is mine for example:
      import edu.cmu.sphinx.frontend.util.Microphone;
      import edu.cmu.sphinx.recognizer.Recognizer;
      import edu.cmu.sphinx.result.Result;
      import edu.cmu.sphinx.util.props.ConfigurationManager;
      import java.io.BufferedWriter;
      import java.io.File;
      import java.io.FileOutputStream;
      import java.io.OutputStreamWriter;
      import java.util.Enumeration;
      import java.util.Hashtable;

      Delete
  54. i added all the imports you mentioned still got the same error
    what could i do?

    ReplyDelete
    Replies
    1. Syntax error on token "void", @ expected
      Syntax error on token "String", instanceof expected after this token
      Syntax error, insert "enum Identifier" to complete EnumHeader

      at osa.ora.ListenToMe.main(ListenToMe.java:11)

      Delete
    2. It seems you are new to Java ?
      This is a compilation errors i can't help with , you need to fix them.

      Delete
  55. Hi osama i want to create a voice recognizer by import javax.speech.recognition package. will you help me on this. i have only ive days..... please help me. thanks in advence.....

    ReplyDelete
    Replies
    1. Ok, what you want exactly ? you may follow the post steps or other open source projects?

      Delete
  56. Hello osama... i am a java beginner.... thanks for your article... it was a lot helpful... i started working on it.... but now i am facing a problem...
    Exception in thread "main" java.lang.NullPointerException
    //at : recognizer.allocate();
    can u plz help me

    ReplyDelete
    Replies
    1. Actually i remember null pointer could means the WebCam USB is not connected or not working properly (may be the driver is not installed)..Otherwise please post the whole exception stacktrack or look in the previous comments for a resolution.

      Delete
  57. yes my microphone is properly inserted...
    myconfig.xml file is


    //package name is helloworld




    shall i need to write anything in the ListenToMe() ???
    if yes give me a sample......

    thanks in advance

    ReplyDelete
  58. is it mandatory to connect the mic on frontend???

    ReplyDelete
  59. hi Osama .. first thanks for this good job
    so .. i did exactly the way to told us to do .. but i got some errors .. can i send you my work to see it

    ReplyDelete
  60. hello Osama
    i followed all the steps but i have a exception

    Exception in thread "main" java.lang.NullPointerException
    at edu.cmu.sphinx.util.props.SaxLoader.load(SaxLoader.java:74)
    at edu.cmu.sphinx.util.props.ConfigurationManager.(ConfigurationManager.java:58)
    at ListenToMe.main(ListenToMe.java:10)

    and i read all the comment but i can't fix my problem voice recognition is a part of my project so please help me

    ReplyDelete
    Replies
    1. The configuration file is not configured correctly, please ensure to place it in the correct path.

      Delete
  61. dear osama
    i m confused with myconfig.xml file so can tell editing again clearly
    thanxx

    ReplyDelete
  62. dear osama
    i m confused with myconfig.xml file so can tell editing again clearly
    thanxx

    ReplyDelete
  63. dear osama
    i am confused with myconfig.xml as where to edit so can u please help me out

    ReplyDelete
  64. hiii these are my errorat console
    i m using eclipse and have added all jars ,dict,myconfig file
    plz help me out

    Exception in thread "main" java.lang.RuntimeException: Allocation of search manager resources failed
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.allocate(SimpleBreadthFirstSearchManager.java:650)
    at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:87)
    at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:168)
    at pkg.ListenToMe.main(ListenToMe.java:17)
    Caused by: java.io.IOException: edu.cmu.sphinx.jsgf.JSGFGrammarParseException
    at edu.cmu.sphinx.jsgf.JSGFGrammar.createGrammar(JSGFGrammar.java:304)
    at edu.cmu.sphinx.linguist.language.grammar.Grammar.allocate(Grammar.java:116)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.allocate(FlatLinguist.java:300)
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.allocate(SimpleBreadthFirstSearchManager.java:646)
    ... 3 more
    Caused by: edu.cmu.sphinx.jsgf.JSGFGrammarParseException
    at edu.cmu.sphinx.jsgf.parser.JSGFParser.newGrammarFromJSGF(JSGFParser.java:132)
    at edu.cmu.sphinx.jsgf.parser.JSGFParser.newGrammarFromJSGF(JSGFParser.java:241)
    at edu.cmu.sphinx.jsgf.JSGFGrammar.loadNamedGrammar(JSGFGrammar.java:697)
    at edu.cmu.sphinx.jsgf.JSGFGrammar.commitChanges(JSGFGrammar.java:613)
    at edu.cmu.sphinx.jsgf.JSGFGrammar.createGrammar(JSGFGrammar.java:300)
    ... 6 more

    ReplyDelete
    Replies
    1. The grammer file is invalid or not available at the specified path.

      Delete
  65. hi i have followed all the steps but i have following error

    12:11:17.689 SEVERE wsj Can't find HMM for EI
    Exception in thread "main" java.lang.NullPointerException
    at edu.cmu.sphinx.linguist.flat.FlatLinguist$GState.getHMMStates(FlatLinguist.java:1216)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist$GState.expandUnit(FlatLinguist.java:1193)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist$GState.attachUnit(FlatLinguist.java:1041)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist$GState.expandPronunciation(FlatLinguist.java:992)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist$GState.expandWord(FlatLinguist.java:912)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist$GState.expand(FlatLinguist.java:825)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.compileGrammar(FlatLinguist.java:420)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.allocate(FlatLinguist.java:304)
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.allocate(SimpleBreadthFirstSearchManager.java:646)
    at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:87)
    at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:168)
    at Experiment.Speech.ListenToMe.main(ListenToMe.java:14)

    Line no. 14 is recognizer.allocate();

    Plz help

    ReplyDelete
    Replies
    1. Seems there is an issue with your grammer file, can you re-check it again.

      Delete
  66. Salam Osama!
    i need ur help in my final year project which is based on speech recognition. i didn't get ur step num 2 and 4 kindly help me how to add jar files in class path? If possible so plz send me ur id actually we r making virtual Agent plz help us

    ReplyDelete
    Replies
    1. Can you download interactive4J and u will find all the needed configurations, please let me know if you still need any help.

      Delete
    2. Download the source code to see how you need to write this, currently you have downloaded the jar file.

      Delete
  67. i have downloaded interactive4j. it is a jar file now plz tell me how to use this file in IDE (Eclipse).

    ReplyDelete
  68. Hello Sir

    I am getting the following Exception


    run:
    Loading...
    Problem configuring HelloWorld: Property exception component:'jsgfGrammar' property:'grammarLocation' - Can't locate resource:C:\\Users\\vaibhav\\Documents\\NetBeansProjects\\sphinxdemo\\src
    edu.cmu.sphinx.util.props.InternalConfigurationException: Can't locate resource:C:\\Users\\vaibhav\\Documents\\NetBeansProjects\\sphinxdemo\\src
    Property exception component:'jsgfGrammar' property:'grammarLocation' - Can't locate resource:C:\\Users\\vaibhav\\Documents\\NetBeansProjects\\sphinxdemo\\src
    edu.cmu.sphinx.util.props.InternalConfigurationException: Can't locate resource:C:\\Users\\vaibhav\\Documents\\NetBeansProjects\\sphinxdemo\\src
    at edu.cmu.sphinx.util.props.ConfigurationManagerUtils.getResource(ConfigurationManagerUtils.java:483)
    at edu.cmu.sphinx.jsgf.JSGFGrammar.newProperties(JSGFGrammar.java:232)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.newProperties(FlatLinguist.java:246)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.newProperties(SimpleBreadthFirstSearchManager.java:182)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
    at edu.cmu.sphinx.decoder.AbstractDecoder.newProperties(AbstractDecoder.java:65)
    at edu.cmu.sphinx.decoder.Decoder.newProperties(Decoder.java:37)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
    at edu.cmu.sphinx.recognizer.Recognizer.newProperties(Recognizer.java:90)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:161)
    at HelloWorld.main(HelloWorld.java:50)
    BUILD SUCCESSFUL (total time: 3 seconds)


    Please sir i am in great need of help of your's. How could i deal with this ?

    ReplyDelete
  69. component:'jsgfGrammar' property:'grammarLocation' - Can't locate resource:C:\\Users\\vaibhav\\Documents\\NetBeansProjects\\sphinxdemo\\src

    This is from the exception , you should see what is wrong in grammer location config file.

    ReplyDelete
  70. SOLUTION:
    The problem here for most of you is the grammar line:
    public = (...

    You think it's "public = (...". It's not.

    There is a "greet" element after the word public.
    It can't be seen (on Firefox, at least).
    However, you can see it if you right click on the browser and view the page source.

    This is the actual code: public <greet> = (...

    ReplyDelete
  71. I have fixed it...thanks for nice article.
    Regards-
    Vikalp Sharma.

    ReplyDelete
  72. I have fixed it...thanks for nice article.
    Regards-
    Vikalp Sharma.

    ReplyDelete
  73. Hi,
    I want sphinx to be executed again and again.if i put in loop with
    reinitialising recogniser and microphone...,it works....But wen i try to reinitialise the Configuration Manager again,it gives the following exception

    09:45:32.124 SEVERE microphone Can't open microphone mummy line with format PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, big-endian not supported.

    could u help me with clearing this pls?

    ReplyDelete
  74. Hi,
    after following above 6 steps I got error

    Exception in thread "main" java.lang.NullPointerException
    at edu.cmu.sphinx.util.props.SaxLoader.load(SaxLoader.java:74)
    at edu.cmu.sphinx.util.props.ConfigurationManager.(ConfigurationManager.java:58)
    at osa.ora.ListenToMe.main(ListenToMe.java:17)

    ReplyDelete
  75. Suresh :
    Hi,
    after following above 6 steps I got error

    Exception in thread "main" java.lang.NullPointerException
    at edu.cmu.sphinx.util.props.SaxLoader.load(SaxLoader.java:74)
    at edu.cmu.sphinx.util.props.ConfigurationManager.(ConfigurationManager.java:58)
    at osa.ora.ListenToMe.main(ListenToMe.java:17)


    Osama: This is configuration file issue, fix it ...

    ReplyDelete
  76. hai,
    i followed the steps what u have listed.
    still i need to know to change grammar location.
    And when i run i have some errors.

    Exception in thread "main" Property exception component:'jsgfGrammar' property:'grammarLocation' - Can't locate resource:C:/Documents and Settings/user/My Documents/NetBeansProjects/osp/src/osp/
    edu.cmu.sphinx.util.props.InternalConfigurationException: Can't locate resource:C:/Documents and Settings/user/My Documents/NetBeansProjects/osp/src/osp/
    at edu.cmu.sphinx.util.props.ConfigurationManagerUtils.getResource(ConfigurationManagerUtils.java:483)
    at edu.cmu.sphinx.jsgf.JSGFGrammar.newProperties(JSGFGrammar.java:232)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.newProperties(FlatLinguist.java:246)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.newProperties(SimpleBreadthFirstSearchManager.java:182)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
    at edu.cmu.sphinx.decoder.AbstractDecoder.newProperties(AbstractDecoder.java:65)
    at edu.cmu.sphinx.decoder.Decoder.newProperties(Decoder.java:37)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
    at edu.cmu.sphinx.recognizer.Recognizer.newProperties(Recognizer.java:90)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:161)
    at osp.Main.main(Main.java:33)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)


    in some cases i get this type of errors
    class not found !java.lang.ClassNotFoundException: edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.Model
    Exception in thread "main" Property exception component:'flatLinguist' property:'acousticModel' - component 'wsj' is missing
    edu.cmu.sphinx.util.props.InternalConfigurationException: component 'wsj' is missing
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:289)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.setupAcousticModel(FlatLinguist.java:278)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.newProperties(FlatLinguist.java:244)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.newProperties(SimpleBreadthFirstSearchManager.java:182)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
    at edu.cmu.sphinx.decoder.AbstractDecoder.newProperties(AbstractDecoder.java:65)
    at edu.cmu.sphinx.decoder.Decoder.newProperties(Decoder.java:37)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
    at edu.cmu.sphinx.recognizer.Recognizer.newProperties(Recognizer.java:90)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
    at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:161)
    at sphinxttest.Main.main(Main.java:34)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)

    can u explain me what may be the mistakes to be corrected

    ReplyDelete
  77. Please use Interactive4J as a ready example for such functionality with source code available ....

    ReplyDelete
  78. salam Alekom
    does this method guranteed for arabic language ???
    what about using audio fingerprinting??

    ReplyDelete
    Replies
    1. Wa 3alekom el salam,
      You need to implement the Arabic language recognition...
      It is not supporting audio fingerprinting....

      Delete
  79. where can i find out "HelloWorld.jar\edu\cmu\sphinx\demo\helloworld\helloworld.config.xml"?
    is by sphinx4-1.0beta6->bin->helloworld? but that jar is not showing any thing. how can i clarify this problem?

    ReplyDelete
  80. Hi Osama,
    I am working on voice recognition. I got this error:

    Exception in thread "AWT-EventQueue-0" java.lang.Error: Error loading word: About.class
    at edu.cmu.sphinx.linguist.dictionary.FastDictionary.loadDictionary(FastDictionary.java:278)
    at edu.cmu.sphinx.linguist.dictionary.FastDictionary.allocate(FastDictionary.java:220)
    at edu.cmu.sphinx.linguist.lextree.LexTreeLinguist.allocate(LexTreeLinguist.java:340)
    at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstSearchManager.allocate(WordPruningBreadthFirstSearchManager.java:238)
    at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:87)
    at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:168)
    at osa.ora.SimpleBrowser.enableVoiceStart(SimpleBrowser.java:351)
    at osa.ora.SimpleBrowser.enableVoiceActionPerformed(SimpleBrowser.java:324)
    at osa.ora.SimpleBrowser.(SimpleBrowser.java:70)
    at osa.ora.SimpleBrowser$11.run(SimpleBrowser.java:376)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    BUILD STOPPED (total time: 22 seconds)

    ReplyDelete
  81. I followed your instructions and have do finish with all the things,,, programe is running successfully but further there no progress.

    ReplyDelete
    Replies
    1. You can download Interactive4J which do the steps in simple way or Interactive Browser app.

      Delete
  82. debug:
    Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Error while parsing line 14 of file:/C:/Users/User/Documents/NetBeansProjects/GodHelpMe/build/classes/godhelpme/myconfig.xml: The markup in the document following the root element must be well-formed.
    at edu.cmu.sphinx.util.props.ConfigurationManager.(ConfigurationManager.java:60)
    at godhelpme.GodHelpMe.main(GodHelpMe.java:21)
    Caused by: java.io.IOException: Error while parsing line 14 of file:/C:/Users/User/Documents/NetBeansProjects/GodHelpMe/build/classes/godhelpme/myconfig.xml: The markup in the document following the root element must be well-formed.
    at edu.cmu.sphinx.util.props.SaxLoader.load(SaxLoader.java:79)
    at edu.cmu.sphinx.util.props.ConfigurationManager.(ConfigurationManager.java:58)
    ... 1 more
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)

    ReplyDelete
    Replies
    1. The xml file "godhelpme/myconfig.xml" is not correct, re-create it or open it using IE and see if it open well or not.

      Delete
  83. hi Osama, i am working on sphinx4 i was completed the first program working on MFCC feature vector with help of helloworld.java and WaveFile.java.
    now i want to do the same program with other feature vector like PLP, LPC or ENH-MFCC).
    plz is the change in confi.xml file is enough or i need something else

    ReplyDelete
    Replies
    1. Sorry Hussein but I have no idea if you can do this..

      Delete
  84. aoa sir i m new in java and my project is voice recognition email system in java.i found sphinx4 but it only works on predefined words i have searched enough but i could not find more.i m stuck at that point.if you can help then plz do.i require an API that convert whole english language to text.we are working in java.

    ReplyDelete
  85. Yes, it need a dictionary for that (predefined word file) ...
    You can find other tools here :
    http://ocvolume.sourceforge.net/links.php

    ReplyDelete
  86. hello sir will you like to help me in this area??

    i got this error.

    09:50.450 WARNING dictionary Missing word: username
    in edu.cmu.sphinx.linguist.dictionary.FastDictionary:getWord-dictionary
    09:50.450 WARNING jsgfGrammar Can't find pronunciation for username
    in edu.cmu.sphinx.linguist.language.grammar.Grammar:createGrammarNode-jsgfGrammar
    09:50.450 WARNING dictionary Missing word: login
    in edu.cmu.sphinx.linguist.dictionary.FastDictionary:getWord-dictionary
    09:50.450 WARNING jsgfGrammar Can't find pronunciation for login
    in edu.cmu.sphinx.linguist.language.grammar.Grammar:createGrammarNode-jsgfGrammar
    (help | username | password | login | compose | to | subject | body | send | read );
    Start speaking. Press Ctrl-C to quit.

    ReplyDelete
    Replies
    1. Please use "user name" instead of "username" in your dictionary.

      Delete
    2. sir can i use speech recognizer and synthesizer both in one application?

      Delete
    3. If you mean text to speech, yes you can find a library to do that.

      Delete
    4. thank you sir..!

      and can i recognize every word which are spoken??
      bcz i need this operation for my application.

      Delete
    5. Speech recognition will remain area for research for a while, now Google and others have very mature engines for that.

      Delete
  87. Hello Osama
    my project depends on the dialog demo that's found in sphinx4-1.0beta6 and am trying to improve the accuracy in recognizing words by loading a new acoustic model that is available :
    cmusphinx-en-us-5.2.tar.gz
    but failed to load it and I discovered that the new acoustic model has different parameters from the original one with sphinx4-1.0beta6 , Is there a way to load it as I need to improve the accuracy and work on this same version of sphinx4 ??
    I appreciate your help.

    ReplyDelete
  88. Hi Osama,
    I using Netbean IDE and i have a error: Can't located resource: /WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz
    I add .jar to library. This is classpath ?
    Please guide me add WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar to classpath if you know.
    Thank you very much!

    ReplyDelete
    Replies
    1. Please use Interactive4J as a ready example for such functionality with source code available ....

      Delete
  89. Exception in thread "main" java.lang.NoSuchFieldError: engineListeners
    i'm getting this exception when i'm trying to run sphinx4 project using netbeans can you please help me out

    ReplyDelete
    Replies
    1. Not sure what is the issue, but review the configurations again and check the library is the one of the system.

      Delete