import org.openhab.core.audio.AudioStream;
import org.openhab.core.audio.FixedLengthAudioStream;
import org.openhab.core.voice.Voice;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Implementation of the {@link AudioStream} interface for the {@link MacTTSService}
*/
class MacTTSAudioStream extends FixedLengthAudioStream {
+ private final Logger logger = LoggerFactory.getLogger(MacTTSAudioStream.class);
+
/**
* {@link Voice} this {@link AudioStream} speaks in
*/
private InputStream createInputStream() throws AudioException {
String outputFile = generateOutputFilename();
String command = getCommand(outputFile);
+ logger.debug("Executing on command line: {}", command);
try {
Process process = Runtime.getRuntime().exec(command);
process.waitFor();
file = new File(outputFile);
+ if (!file.exists()) {
+ throw new AudioException("Generated file '" + outputFile + "' does not exist.'");
+ }
this.length = file.length();
+ if (this.length == 0) {
+ throw new AudioException("Generated file '" + outputFile + "' has no content.'");
+ }
return getFileInputStream(file);
} catch (IOException e) {
throw new AudioException("Error while executing '" + command + "'", e);
stringBuffer.append("say");
- stringBuffer.append(" --voice=\"" + this.voice.getLabel() + "\"");
+ stringBuffer.append(" --voice=" + this.voice.getLabel());
stringBuffer.append(" --output-file=" + outputFile);
stringBuffer.append(" --file-format=" + this.audioFormat.getContainer());
stringBuffer.append(" --data-format=LEI" + audioFormat.getBitDepth() + "@" + audioFormat.getFrequency());