Results 1 to 4 of 4
  1. #1
    yonas is offline Newbies
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Default text to speech conversioin using freeTTs

    package ourproject;

    import javax.speech.Central;
    import javax.speech.synthesis.*;
    import java.util.Locale;

    public class SPeech {
    public static void main(String args[]) {
    try {
    // Create a synthesizer for English
    Synthesizer synth = Central.createSynthesizer(
    new SynthesizerModeDesc(Locale.ENGLISH));

    // Get it ready to speak
    synth.allocate();
    synth.resume();

    // Speak the "Hello world" string
    synth.speakPlainText("Hello, world!", null);

    // Wait till speaking is done
    synth.waitEngineState(Synthesizer.QUEUE_EMPTY);

    // Clean up
    synth.deallocate();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by yonas View Post
    Java Code:
    package ourproject;
    
    import javax.speech.Central;
    import javax.speech.synthesis.*;
    import java.util.Locale;
    
    public class SPeech {
        public static void main(String args[]) {
    		try {
    			// Create a synthesizer for English
    			Synthesizer synth = Central.createSynthesizer(
    				new SynthesizerModeDesc(Locale.ENGLISH));
    
    			// Get it ready to speak
    			synth.allocate();
    			synth.resume();
    
    			// Speak the "Hello world" string
    			synth.speakPlainText("Hello, world!", null);
    
    			// Wait till speaking is done
    			synth.waitEngineState(Synthesizer.QUEUE_EMPTY);
    
    			// Clean up
    			synth.deallocate();
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}    
    }
    Do you have a question?

  3. #3
    yonas is offline Newbies
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Default

    I've got a very annoying problem. Basically whenever I compile the above code using javac and then try to run the CLASS file it generates, it tells me there's a null pointer exception on line 9 Synth.Allocate. I've searched all over the internet to no avail. The program is meant to speak Hello World to me. I've got Jsapi, all the jar files are in \jre6\lib\ext.

    I've got speech.properties in both these locations, C:\Users\Myusername : C:\Program Files\Java\jre6\lib

    I've searched the internet for hours and there are loads of posts about it, but none of them explain how to fix it. Please if you know how to fix it and get rid of this null pointer exception at line 9 could you tell me I would be so grateful!

    Oh ye by the way I purposely put the spaces in the code to make it easier to read

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,304
    Rep Power
    20

    Default

    it tells me there's a null pointer exception on line 9 Synth.Allocate.
    The API for Central says
    Returns:
    a Synthesizer matching the required properties or null if none is available
    Evidently synth is null.

    I've searched the internet for hours and there are loads of posts about it, but none of them explain how to fix it.
    This page has a step-by-step:
    Setup java speech jsapi using FreeTTS | Ryan-H.com

    db

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
    By jyothi.priyanka in forum Advanced Java
    Replies: 0
    Last Post: 02-24-2011, 05:00 PM
  3. FreeTTS / speech.. only rendering Numbers??
    By SM2010 in forum New To Java
    Replies: 8
    Last Post: 09-23-2010, 02:55 PM
  4. speech to text concersion
    By ak88 in forum Advanced Java
    Replies: 1
    Last Post: 03-09-2010, 08:57 AM
  5. how to play text using freetts
    By kattavijay in forum Java Servlet
    Replies: 1
    Last Post: 03-19-2009, 08:49 AM

Posting Permissions

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