How to make Text to Speech in Java ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Atul Goyal
    New Member
    • Aug 2010
    • 12

    #1

    How to make Text to Speech in Java ?

    Hello Friends,

    I want to make a java file for Text to Speech purpose.

    Means user enter his name and my .class will make sound of user entered text.

    Can you help me for this ?
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    If I were you I'd look for software that already does this and that provides an API or Software Developer Kit (SDK) that allows your Java program to utilize.

    Please take the time to research the problem before you post your question. The experts here are more than willing to help you with a specific problem but you have to do your part to learn the basics.

    Comment

    • Atul Goyal
      New Member
      • Aug 2010
      • 12

      #3
      I am using following example but it give me null pointer exception. It is not created the object of synthesis .


      Code:
      import javax.speech.*;
      import javax.speech.synthesis.*;
      import java.util.Locale;
      
      public class HelloWorld {
      	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();
      		}
      	}
      }
      Can u help me to solve this ?
      Last edited by Frinavale; Aug 13 '10, 01:02 PM. Reason: Please post code in [code] ... [/code] tags.

      Comment

      • Dheeraj Joshi
        Recognized Expert Top Contributor
        • Jul 2009
        • 1129

        #4
        Where it is throwing the null pointer exception? Please see the stack trace. And use try catch to isolate the problem.

        Since i am not sure about these api i can not comment much. But look at the Java doc for corresponding api's and check the signatures etc.

        Regards
        Dheeraj Joshi

        Comment

        Working...