0

I am new to both java and sphinx4 Here i have downloaded sphinx and i am using eclipse editor so i added the jar files and my set up is ready Infact i also run the demo hello world example which was giving the output as expected .

But enter image description here Here in hello.gram we have given some input and only those words we could able to capture

    #JSGF V1.0;

/**
 * JSGF Grammar for Hello World example
 */

grammar hello;

public <greet> = (Good morning | Hello) ( Bhiksha | Evandro | Paul | Philip | Rita | Will );

what if i want to use other english words how do i need to do it

Any help would be highly appreciated.

barryhunter
  • 20,886
  • 3
  • 30
  • 43
Shikha thakur
  • 1,269
  • 13
  • 34
  • Possible duplicate of [Large vocabulary speech recognition in sphinx4](http://stackoverflow.com/questions/26023864/large-vocabulary-speech-recognition-in-sphinx4) – Nikolay Shmyrev Oct 27 '16 at 15:35

1 Answers1

2

If you want to keep using a grammar file, you can use "new" words by adding those words to the grammar file. As long as the dictionary contains the words you'd like to use, you're ready to go. If the dictionary does not contain the words you'd like to use, you would have to add them yourself.

Take a look at this page: http://cmusphinx.sourceforge.net/doc/sphinx4/edu/cmu/sphinx/jsgf/JSGFGrammar.html it shows you how to set up a different grammar file.

Hespen
  • 1,384
  • 2
  • 17
  • 27
  • If am not using grammar file and if there is any library that can be added to resolve this please let me know – Shikha thakur Nov 05 '16 at 14:15
  • I don't fully understand what you're trying to say. If you don't want to use a grammar, and have full recognition without presets. You should use a Language Model (.lm) – Hespen Nov 05 '16 at 18:39
  • Could you please send me the link where i could refer Language Model – Shikha thakur Nov 07 '16 at 09:44
  • http://cmusphinx.sourceforge.net/wiki/tutoriallm here you can see how to make them yourself. It's pretty easy to do. But you can download them too from SourceForge: https://sourceforge.net/projects/cmusphinx/files/Acoustic%20and%20Language%20Models/US%20English/ It's the lm.gz files. Language Models are like big grammar files, so British English, and US English will be the same – Hespen Nov 07 '16 at 11:41
  • so after downloding how to include it in java file? – Shikha thakur Nov 07 '16 at 11:47
  • `Configuration c = new Configuration(); c.setLanguageModel("path/to/lm/file.lm");` But you can find all those examples in the demo projects of Sphinx. – Hespen Nov 07 '16 at 12:55
  • Yes,I could see so many jar files in demo sphinx. But is there any way to include all those in my main.java file? – Shikha thakur Nov 07 '16 at 16:24
  • You don't need all those jars. For your main project you can use the Core jar. The demo's can be found inside the Sphinx 4 archive: https://sourceforge.net/projects/cmusphinx/files/sphinx4/5prealpha/ Inside the samples folder. The Transcriber Demo uses the language model. – Hespen Nov 07 '16 at 18:46
  • I have transcriber.jar and when i run that i get to see "one zero zero zero one nine oh two one oh zero one eight zero three" which i didnot understand – Shikha thakur Nov 13 '16 at 09:32
  • That's because it uses an audio file containing that sentence. You could use a different audio file to get a different response! The file is also named: `TranscriberDemo.class.getResourceAsStream("/edu/cmu/sphinx/demo/aligner/10001-90210-01803.wav");` which is the same as your response string – Hespen Nov 14 '16 at 08:50
  • What if i dont need any audio file and it need to print what i say through microphone – Shikha thakur Nov 14 '16 at 12:07
  • There are no samples of that available. But I guess that it is possible. You should record the audio to a stream, and attach that stream to sphinx. That way you can read the stream as you are creating it. But if a small delay isn't an issue, you could also just record the audio first to a .wav file or as a byte array. And attach it to sphinx when you're done talking. The inputstream in the transcriber class is what you should change. How you get that stream is up to you – Hespen Nov 14 '16 at 19:01