use of javazoom.jl.decoder.JavaLayerException in project openhab1-addons by openhab.
the class TTSServiceGoogleTTS method say.
/**
* {@inheritDoc}
*/
public void say(String text, String voiceName, String outputDevice) {
logger.info("Executing GoogleTTS for text '{}' in language {}", text, ttsLanguage);
BufferedInputStream stream = null;
try {
List<String> sentences = textProcessor.splitIntoChunks(text);
InputStream completeStream = getSpeechForText(sentences);
Player playMP3 = new Player(completeStream);
playMP3.play();
} catch (IOException e) {
logger.warn("Error while connecting to Google translate service", e);
if (e instanceof FileNotFoundException) {
logger.warn("Possibly unsupported language '{}'?", ttsLanguage);
}
} catch (JavaLayerException e) {
logger.warn("Unable to play InputStream for text " + text, e);
} finally {
IOUtils.closeQuietly(stream);
}
}
use of javazoom.jl.decoder.JavaLayerException in project sulky by huxi.
the class JLayerSounds method resolvePlayer.
private Player resolvePlayer(String soundName) {
String soundLocation = null;
if (soundLocations != null) {
soundLocation = soundLocations.get(soundName);
}
if (soundLocation == null) {
if (logger.isInfoEnabled())
logger.info("No sound location defined for sound {}.", soundName);
return null;
}
InputStream soundStream = JLayerSounds.class.getResourceAsStream(soundLocation);
if (soundStream == null) {
if (logger.isInfoEnabled())
logger.info("Couldn't retrieve {} as a resource...", soundLocation);
File file = new File(soundLocation);
if (file.isFile()) {
try {
soundStream = Files.newInputStream(file.toPath());
} catch (IOException e) {
if (logger.isInfoEnabled())
logger.info("Couldn't open {} as a file.", soundLocation);
}
}
if (soundStream == null) {
try {
URL url = new URL(soundLocation);
soundStream = url.openStream();
} catch (IOException e) {
if (logger.isInfoEnabled())
logger.info("Couldn't open {} as a URL.", soundLocation);
}
}
}
if (soundStream != null) {
try {
return new Player(soundStream);
} catch (JavaLayerException ex) {
if (logger.isWarnEnabled())
logger.warn("Exception while creating player for sound '{}'!", soundName, ex);
}
}
return null;
}
use of javazoom.jl.decoder.JavaLayerException in project JWildfire by thargor6.
the class JLayerInterface method play.
public void play(String pFilename) throws Exception {
stop();
FileInputStream fin = new FileInputStream(pFilename);
BufferedInputStream bin = new BufferedInputStream(fin);
processor = new PlayerAudioProcessor();
processor.setMuted(muted);
audioDevice = new JWFAudioDevice(processor);
audioDevice.close();
player = new Player(bin, audioDevice);
new Thread(new Runnable() {
@Override
public void run() {
try {
playing = true;
try {
player.play();
} finally {
processor.finish();
}
} catch (JavaLayerException e) {
e.printStackTrace();
playing = false;
}
}
}).start();
}
use of javazoom.jl.decoder.JavaLayerException in project JWildfire by thargor6.
the class JWFAudioDevice method createSource.
protected void createSource() throws JavaLayerException {
Throwable t = null;
try {
Line line = AudioSystem.getLine(getSourceLineInfo());
if (line instanceof SourceDataLine) {
source = (SourceDataLine) line;
source.open(audioFormat);
source.start();
}
} catch (Throwable ex) {
t = ex;
}
if (source == null)
throw new JavaLayerException("Cannot obtain source audio line", t);
}
Aggregations