javafreetts

text to speech in java using freetts


I am using freetts jar file for text to speech. But I need much more voices like Indian English.

There my code is:

  import com.sun.speech.freetts.Voice;
  import com.sun.speech.freetts.VoiceManager;

 class s
 {

     VoiceManager freettsVM;
     Voice freettsVoice;
     private Voice voice;
     public s(String voiceName) 
     {
          VoiceManager voiceManager = VoiceManager.getInstance();
           voice = voiceManager.getVoice(voiceName);
      }
      public void speak(String msg) {
          freettsVoice.allocate();
          freettsVoice.speak(msg);
          freettsVoice.deallocate();
      }
 }
 public class Main {
    public static void main(String[] args) {
    String speekstring = txtmassage.getText();
            s t = new s("kevin16");
            t.speak(speekstring);}
 }

It’s work correctly, but I need more voices.

now i changed my code into enter image description here

then there error is

 Could not validate any MBROLA voices at

  C:/Users/anand/Documents/NetBeansProjects/mbrola

  Make sure you FULLY specify the path to
  the MBROLA directory using the mbrola.base
  system property.

  Exception in thread "main" java.lang.NullPointerException
          at newpro.TestTTS.<init>(TestTTS.java:20)
         at newpro.TestTTS.main(TestTTS.java:29)
  Java Result: 1
  BUILD SUCCESSFUL (total time: 0 seconds)

Solution

  • You could use the MBROLA - Project. It's free and offers several languages.

    You will need to download the project-package itself and the voices.

    For a step-by-step guide on how to install and use MBROLA you can go to here:

    https://stackoverflow.com/a/26236563/1368690

    Or go to the project page itself:

    http://tcts.fpms.ac.be/synthesis/mbrola.html

    When you scroll down a bit, there a lots of voice you can test and see, if they will be usefull for you.