Solved

Speech Recognition

Posted on 2001-06-05
6
936 Views
Last Modified: 2012-06-27
Hello Guys and Gals

I am trying to create a vary very basic speech recognition application in Java.  Has anyone got any tips, tricks or know of any useful resources that will help me in this area.

I would be grateful for any help.  

Cheers

Rainbow*
0
Comment
Question by:RainbowStar
6 Comments
 
LVL 2

Accepted Solution

by:
mariuso earned 50 total points
ID: 6155549
YOU HAVE TO USE JSAPI.

The following code shows how to create a recognizer, load the grammar, and then wait for the user to say something that matches the grammar. When it gets a match, it deallocates the engine and exits.

--------------------------------------------------------------------------------
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
          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(args[0]);
               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.resume();
          } catch (Exception e) {
               e.printStackTrace();
          }
     }
}


You can try

http://java.sun.com/products/java-media/speech/forDevelopers/jsapi-guide/Recognition.html

or you can try IBM's ViaVoice:
http://www-4.ibm.com/software/speech/dev/hltwp.html
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6155558
Pa unde esti bai sica? Merge sursa aia ?
0
 

Author Comment

by:RainbowStar
ID: 6155590
Cheers thanks for the tips

Would you know how to simply view an applet using a browser.  I have complied the applet using JDK but when I open the applet using browser it shows "class not found"
Can you help ???

Thanks again mariuso
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 2

Expert Comment

by:mariuso
ID: 6156645
Can be a problem with the case letter of the class. The samples from jdk are working for u ?
0
 

Author Comment

by:RainbowStar
ID: 6156681
The applet works fine using JDK, its just I want to open it using a browser.  I simply open the html code and its not there. I have checked the case letter of the class.
Do you think that it is the classpath ???
0
 

Expert Comment

by:thinkdifferent
ID: 7495116
From where can i dowload javax.speech as this code gives the error package not founf javax.speech
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question