Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java API
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Other JSE/JEE APIs
speech recognition
jaspreet manchinda
Ranch Hand
Posts: 67
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Need help while execution speech recognition program m gettin error : unreported exception javax.speech.EngineException
line number 19
import javax.speech.*; import javax.speech.recognition.*; import java.io.FileReader; import java.util.Locale; public class HelloWorldRec 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 rec.deallocate(); System.exit(0); } public static void main(String args[]) { try { // Create a recognizer that supports English. rec = Central.createRecognizer( new EngineModeDesc(Locale.ENGLISH)); // Start up the recognizer rec.allocate(); // Load the grammar from a file, and enable it FileReader reader = new FileReader("numbers.gram"); RuleGrammar gram = rec.loadJSGF(reader); gram.setEnabled(true); // Add the listener to get results rec.addResultListener(new HelloWorldRec()); // Commit the grammar rec.commitChanges(); // Request focus and start listening rec.requestFocus(); rec.resume(); } catch (Exception e) { e.printStackTrace(); } } }
Tim Moores
Saloon Keeper
Posts: 7582
176
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What do the javadocs say under which conditions that method can throw an exception?
What happens if you omit that method call? Since it's just before exiting the JVM, I could imagine that not much harm is possible.
jaspreet manchinda
Ranch Hand
Posts: 67
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
if we dont use deallocate , the after saying the
word
the engine does not get dellocated and the program does not exits the code runs properly without that method but it does not respond to any of the words in grammar file and exit the program
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Null pointer exception in code
Speech to text
Java IO Doubt
Java Slick + Marte Engine Networked Game - Windows Specific Lag
# of lines in a file?
More...