Cloudgarden's Discussion Board
Forums: Search: Several forums are available for people to post questions/comments about Java Speech or any of the CloudGarden products. As more messages are posted this discussion board should provide a useful, searchable, support database.
o AliceTalker (42)
o JSAPI Projects (69)
o Java Speech API (857)
o Jigloo GUI Builder for Eclipse (3322)
o SwingScroller (0)
o US Election 2004 (3)
Searches text and subject fields in all forums. The search matches as many words as possible. Don't use "AND" or "OR".
Latest "Java Speech API" Topics [ Start new "Java Speech API" Topic  ]

Cloudgarden Discussion Board  
This topic has 1 reply.       [ << Previous Topic | Start of Thread | >> Next Topic ]
jsapi speech recognizer :problem
Author: shakthydoss
12/26/09 23:30 Reply
java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
at java.util.Vector.elementAt(Vector.java:427)
at HelloWorld.main(HelloWorld.java:29)
i use netbeans

//samplle code
import javax.speech.*;
import javax.speech.recognition.*;
import java.io.FileReader;
import java.util.Locale;

public class HelloWorld extends ResultAdapter {
static Recognizer rec;

// Receives RESULT_ACCEPTED event: print it, clean up, exit
public void resultAccepted(ResultEvent e) {
Result r = (Result)(e.getSource());
ResultToken tokens[] = r.getBestTokens();

for (int i = 0; i < tokens.length; i++)
System.out.print(tokens[i].getSpokenText() + " ");
System.out.println();


// Deallocate the recognizer and exit

System.exit(0);

}

public static void main(String args[]) {
try {
// Create a recognizer that supports English.
EngineList list = Central.availableRecognizers(null);
rec = Central.createRecognizer((EngineModeDesc)list.elementAt(0));



// Start up the recognizer
rec.waitEngineState(Recognizer.ALLOCATED) ;

// Load the grammar from a file, and enable it

FileReader reader = new FileReader("hello.gram");
RuleGrammar gram = rec.loadJSGF(reader);
gram.setEnabled(true);

// Add the listener to get results
rec.addResultListener(new HelloWorld());

// Commit the grammar
rec.commitChanges();

// Request focus and start listening
rec.requestFocus();
rec.waitEngineState(Recognizer.DEALLOCATED) ;
rec.resume();
} catch (Exception e) {
e.printStackTrace();
}
}
}

Re: jsapi speech recognizer :problem
Author:Deepak
Reply 1 of 107/23/10 22:51Reply
Im also getting this error. Please help