Solved

Speech Recognition

Posted on 2001-06-05
6
927 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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 had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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 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 …

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now