Solved

Speech Recognition

Posted on 2001-06-05
6
938 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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…

749 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