Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Program to convert Speech to Text..pls getting error @ rec.allocate(NULL POINTER EXC)

    Java 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
    try {
    	rec.deallocate();
    } catch (EngineException e1) {
    	// TODO Auto-generated catch block
    	e1.printStackTrace();
    } catch (EngineStateError e1) {
    	// TODO Auto-generated catch block
    	e1.printStackTrace();
    }
    System.exit(0);
    }
    public static void main(String args[]) {
    	Recognizer rec;
    	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();
    	}
    	}
    }
    Last edited by Norm; 12-04-2011 at 02:30 PM. Reason: added code tags

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default Re: Program to convert Speech to Text..pls getting error @ rec.allocate(NULL POINTER

    Is there a question here?

  3. #3
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Re: Program to convert Speech to Text..pls getting error @ rec.allocate(NULL POINTER

    Ya i am getting an error saying "rec.allocate(NULL POINTER Exception)" Can u pls say me how to resolve it.....

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default Re: Program to convert Speech to Text..pls getting error @ rec.allocate(NULL POINTER

    What variable is null on the line where the error occurs? Check your code to see why that variable does not have a valid value.

    Did you post the full text of the error message? Or did you leave some of it off?

Similar Threads

  1. Speech To Text
    By jyothi.priyanka in forum Advanced Java
    Replies: 1
    Last Post: 12-04-2011, 11:44 AM
  2. text to speech conversioin using freeTTs
    By yonas in forum New To Java
    Replies: 3
    Last Post: 05-24-2011, 04:58 PM
  3. Text To Speech
    By jyothi.priyanka in forum Advanced Java
    Replies: 0
    Last Post: 02-24-2011, 05:00 PM
  4. speech to text concersion
    By ak88 in forum Advanced Java
    Replies: 1
    Last Post: 03-09-2010, 08:57 AM
  5. Capture speech and convert it to text in a textbox
    By Cyber Dragon in forum Advanced Java
    Replies: 1
    Last Post: 04-25-2009, 04:55 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •