how to setup mbrola in UBUNTU for a simple java program

133 views Asked by At

I am trying to use mbrola voices in java program but the there is no specific way to include mbrola in my java program . It is working fine in the below code

import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
public class Mainn {
public static void main(String args[]) {
    final String VOICENAME_kevin = "kevin16";
    final String text; // string to speech
    //System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory");
     Voice voice;
    VoiceManager voiceManager = VoiceManager.getInstance();
    voice = voiceManager.getVoice(VOICENAME_kevin);
voice.allocate();
 String newText = "first name ";
   boolean status= voice.speak(newText);
   System.out.println("Status"+"  "+status);   
    }
}

But when I am trying to use mbrola base downloading the mbr301h.zip and voice zip files and trying run the program code below

public class Mainn {
public static void main(String args[]) {
    final String VOICENAME_mbrola="mbrola_us1";

    final String text; // string to speech
    
    System.setProperty("mbrola.base", "/home/tech/mbrola");

    Voice voice;
    VoiceManager voiceManager = VoiceManager.getInstance();

    voice = voiceManager.getVoice(VOICENAME_kevin);

    voice.allocate();
 
    String newText = "first name ";
   boolean status= voice.speak(newText);
   System.out.println("Status"+"  "+status);   
    }
}

I am facing error like

Exception in thread "main" java.lang.ClassCastException: class com.sun.speech.freetts.en.us.cmu_time_awb.AlanVoiceDirectory cannot be cast to class com.sun.speech.freetts.VoiceDirectory (com.sun.speech.freetts.en.us.cmu_time_awb.AlanVoiceDirectory is in unnamed module of loader com.sun.speech.freetts.DynamicClassLoader @51e2adc7; com.sun.speech.freetts.VoiceDirectory is in unnamed module of loader 'app')
    at com.sun.speech.freetts.VoiceManager.getVoices(VoiceManager.java:113)
    at com.sun.speech.freetts.VoiceManager.getVoice(VoiceManager.java:502)
    at voice.Mainn.main(Mainn.java:21)

Please help me setting up mbrola for a simple java program in ubuntu.

0

There are 0 answers