return;
}
if(text==null) {
return;
}
Voice voice=null;
if (StringUtils.isBlank(voiceName)) {
logger.debug("Mary TTS: {} (Voice not set. Using default voice {}).", new String[] { text, defaultVoice.toString() });
voice = defaultVoice;
} else {
voice = Voice.getVoice(voiceName);
logger.debug("Mary TTS: {} (Voice: {})", new String[] { text, voiceName });
}
if (voice != null) {
// Workaround: we have to set the Locale first, because only in the LocalMaryInterface.setLocale() method the required private method
// LocalMaryInterface.setAudioFileFormatForVoice() method is called. After that we can set the voice, otherwise an NPE occurs
marytts.setLocale(voice.getLocale());
marytts.setVoice(voice.getName());
try {
AudioInputStream audio = marytts.generateAudio(text);
AudioPlayer player = new AudioPlayer(audio);
player.start();
player.join();