diff --git a/bundles/core/org.openhab.core.compat1x/META-INF/MANIFEST.MF b/bundles/core/org.openhab.core.compat1x/META-INF/MANIFEST.MF index 2baaa40db92b1..5e98dcc29b1d1 100644 --- a/bundles/core/org.openhab.core.compat1x/META-INF/MANIFEST.MF +++ b/bundles/core/org.openhab.core.compat1x/META-INF/MANIFEST.MF @@ -60,6 +60,7 @@ Export-Package: org.openhab.core.autoupdate, org.openhab.core.types, org.openhab.io.console, org.openhab.io.multimedia.actions, + org.openhab.io.multimedia.tts, org.openhab.io.net.actions, org.openhab.io.net.exec, org.openhab.io.net.http, diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/OSGI-INF/tts_mary.xml b/bundles/core/org.openhab.core.compat1x/OSGI-INF/ttsservicefactory.xml similarity index 55% rename from bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/OSGI-INF/tts_mary.xml rename to bundles/core/org.openhab.core.compat1x/OSGI-INF/ttsservicefactory.xml index c439d8800e807..19d3b580796d0 100644 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/OSGI-INF/tts_mary.xml +++ b/bundles/core/org.openhab.core.compat1x/OSGI-INF/ttsservicefactory.xml @@ -2,16 +2,14 @@ - - - - - - + + + diff --git a/bundles/core/org.openhab.core.compat1x/build.properties b/bundles/core/org.openhab.core.compat1x/build.properties index 4a1f00dae8ebb..c8126bd3c21f3 100644 --- a/bundles/core/org.openhab.core.compat1x/build.properties +++ b/bundles/core/org.openhab.core.compat1x/build.properties @@ -9,5 +9,5 @@ bin.includes = META-INF/,\ OSGI-INF/bindingconfigreaderfactory.xml,\ OSGI-INF/actionservicefactory.xml,\ OSGI-INF/itemuiregistry.xml,\ - OSGI-INF/chartproviderfactory.xml -source.. = src/main/java/ + OSGI-INF/chartproviderfactory.xml,\ + OSGI-INF/ttsservicefactory.xmlsource.. = src/main/java/ diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/TTSService.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/TTSService.java new file mode 100644 index 0000000000000..04c518ce9414f --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/TTSService.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.io.multimedia.tts; + +/** + * This is the interface that a text-to-speech service has to implement. + * + * @author Kai Kreuzer - Initial contribution and API + * + */ +public interface TTSService { + + /** + * Speaks the text with a given voice + * + * @param text + * the text to speak + * @param voice + * the name of the voice to use or null, if the default voice + * should be used + * @param device + * the name of audio device to be used to play the audio or null, + * if the default output device should be used + */ + void say(String text, String voice, String outputDevice); + +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/internal/TTSServiceDelegate.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/internal/TTSServiceDelegate.java new file mode 100644 index 0000000000000..c94ef4cee2ae2 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/internal/TTSServiceDelegate.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.io.multimedia.tts.internal; + +import org.eclipse.smarthome.io.multimedia.tts.TTSService; + +/** + * This class serves as a mapping from the "old" org.openhab namespace to the + * new org.eclipse.smarthome namespace for the action service. It wraps an + * instance with the old interface into a class with the new interface. + * + * @author Tobias Bräutigam - Initial contribution and API + */ +public class TTSServiceDelegate implements TTSService { + + private org.openhab.io.multimedia.tts.TTSService service; + + public TTSServiceDelegate(org.openhab.io.multimedia.tts.TTSService service) { + this.service = service; + } + + @Override + public void say(String text, String voice, String outputDevice) { + service.say(text, voice, outputDevice); + } + +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/internal/TTSServiceFactory.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/internal/TTSServiceFactory.java new file mode 100644 index 0000000000000..62c5220239d5d --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/internal/TTSServiceFactory.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.io.multimedia.tts.internal; + +import java.net.URL; +import java.util.Collection; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Map; +import java.util.Set; + +import org.openhab.core.compat1x.internal.CompatibilityActivator; +import org.openhab.io.multimedia.tts.TTSService; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class listens for services that implement the old tts service interface + * and registers an according service for each under the new interface. + * + * @author Tobias Bräutigam - Initial contribution and API (copied from + * ActionServiceFactory) + */ +public class TTSServiceFactory { + private static final Logger logger = LoggerFactory + .getLogger(TTSServiceFactory.class); + + private Map> delegates = new HashMap<>(); + private BundleContext context; + + private Map ttsServices = new HashMap<>(); + + public void activate(BundleContext context) { + this.context = context; + for (TTSService service : ttsServices.keySet()) { + registerDelegateService(service,ttsServices.get(service)); + } + } + + public void deactivate() { + for (ServiceRegistration serviceReg : delegates + .values()) { + serviceReg.unregister(); + } + delegates.clear(); + this.context = null; + } + + public void addTTSService(TTSService service, Map prop) { + if (context != null) { + registerDelegateService(service,prop); + } else { + ttsServices.put(service,prop); + } + } + + public void removeTTSService(TTSService service) { + if (context != null) { + unregisterDelegateService(service); + } + } + + private void registerDelegateService(TTSService ttsService, Map properties) { + if (!delegates.containsKey(ttsService.getClass().getName())) { + TTSServiceDelegate service = new TTSServiceDelegate(ttsService); + Dictionary props = new Hashtable(); + if (properties != null && properties.containsKey("os")) + props.put("os", properties.get("os")); + ServiceRegistration serviceReg = context + .registerService( + org.eclipse.smarthome.io.multimedia.tts.TTSService.class, + service, props); + delegates.put(ttsService.getClass().getName(), serviceReg); + } + } + + private void unregisterDelegateService(TTSService service) { + if (delegates.containsKey(service.getClass().getName())) { + ServiceRegistration serviceReg = delegates + .get(service.getClass().getName()); + delegates.remove(service.getClass().getName()); + serviceReg.unregister(); + } + } +} diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.classpath b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.classpath deleted file mode 100644 index 8fded99aab140..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.project b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.project deleted file mode 100644 index 0e79cb6780cbe..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - org.eclipse.smarthome.io.multimedia.tts.marytts - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.pde.ds.core.builder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.settings/org.eclipse.jdt.core.prefs b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f42de363afaae..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.settings/org.eclipse.pde.core.prefs b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index e67024ad35216..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Mon Oct 11 21:08:09 CEST 2010 -eclipse.preferences.version=1 -pluginProject.extensions=false -resolve.requirebundle=false diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/META-INF/MANIFEST.MF b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/META-INF/MANIFEST.MF deleted file mode 100644 index c85662642de93..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/META-INF/MANIFEST.MF +++ /dev/null @@ -1,36 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Eclipse SmartHome Multimedia I/O MaryTTS Bundle -Bundle-SymbolicName: org.eclipse.smarthome.io.multimedia.tts.marytts -Bundle-Version: 0.8.0.qualifier -Bundle-Vendor: Eclipse.org/SmartHome -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Bundle-ClassPath: ., - lib/voice-cmu-slt-hsmm-5.0.jar, - lib/voice-bits1-hsmm-5.0-SNAPSHOT.jar, - lib/voice-bits3-hsmm-5.0-SNAPSHOT.jar, - lib/emotionml-checker-java-1.0-SNAPSHOT.jar, - lib/freetts-1.0.jar, - lib/freetts-de-1.0.jar, - lib/freetts-en_us-1.0.jar, - lib/jtok-core-1.9.1.jar, - lib/marytts-server-5.1-SNAPSHOT.jar, - lib/mwdumper-1.16.jar, - lib/sgt-3.0.jar, - lib/marytts-runtime-5.1-SNAPSHOT.jar, - lib/marytts-common-5.1-SNAPSHOT.jar, - lib/marytts-signalproc-5.1-SNAPSHOT.jar, - lib/marytts-lang-de-5.1-SNAPSHOT.jar, - lib/marytts-lang-en-5.1-SNAPSHOT.jar, - lib/opennlp-maxent-3.0.1-incubating.jar, - lib/opennlp-tools-1.5.1-incubating.jar -Import-Package: org.apache.commons.collections.map, - org.apache.commons.io, - org.apache.commons.lang, - org.eclipse.smarthome.core.library.types, - org.eclipse.smarthome.io.multimedia.tts, - org.osgi.framework, - org.slf4j -Service-Component: OSGI-INF/tts_mary.xml -Bundle-ActivationPolicy: lazy -Bundle-Activator: org.eclipse.smarthome.io.multimedia.tts.marytts.internal.MultimediaActivator diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/about.html b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/about.html deleted file mode 100644 index c258ef55d834c..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -About - - -

About This Content

- -

June 5, 2006

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - - \ No newline at end of file diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/build.properties b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/build.properties deleted file mode 100644 index 41d7510ccb735..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/build.properties +++ /dev/null @@ -1,24 +0,0 @@ -output.. = target/classes/ -bin.includes = META-INF/,\ - .,\ - OSGI-INF/,\ - about.html,\ - lib/voice-bits1-hsmm-5.0-SNAPSHOT.jar,\ - lib/voice-bits3-hsmm-5.0-SNAPSHOT.jar,\ - lib/voice-cmu-slt-hsmm-5.0.jar,\ - lib/emotionml-checker-java-1.0-SNAPSHOT.jar,\ - lib/freetts-1.0.jar,\ - lib/freetts-de-1.0.jar,\ - lib/freetts-en_us-1.0.jar,\ - lib/jtok-core-1.9.1.jar,\ - lib/marytts-server-5.1-SNAPSHOT.jar,\ - lib/mwdumper-1.16.jar,\ - lib/sgt-3.0.jar,\ - lib/marytts-runtime-5.1-SNAPSHOT.jar,\ - lib/marytts-common-5.1-SNAPSHOT.jar,\ - lib/marytts-signalproc-5.1-SNAPSHOT.jar,\ - lib/marytts-lang-de-5.1-SNAPSHOT.jar,\ - lib/marytts-lang-en-5.1-SNAPSHOT.jar,\ - lib/opennlp-maxent-3.0.1-incubating.jar,\ - lib/opennlp-tools-1.5.1-incubating.jar -source.. = src/main/java/ diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-common-5.1-SNAPSHOT.jar b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-common-5.1-SNAPSHOT.jar deleted file mode 100644 index ec28b9956562d..0000000000000 Binary files a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-common-5.1-SNAPSHOT.jar and /dev/null differ diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-runtime-5.1-SNAPSHOT.jar b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-runtime-5.1-SNAPSHOT.jar deleted file mode 100644 index de055708a2ece..0000000000000 Binary files a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-runtime-5.1-SNAPSHOT.jar and /dev/null differ diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-server-5.1-SNAPSHOT.jar b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-server-5.1-SNAPSHOT.jar deleted file mode 100644 index 5a5797e907dbf..0000000000000 Binary files a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-server-5.1-SNAPSHOT.jar and /dev/null differ diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-signalproc-5.1-SNAPSHOT.jar b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-signalproc-5.1-SNAPSHOT.jar deleted file mode 100644 index 2d58c4378a25d..0000000000000 Binary files a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-signalproc-5.1-SNAPSHOT.jar and /dev/null differ diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/pom.xml b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/pom.xml deleted file mode 100644 index 23ad6f18cb6f5..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/pom.xml +++ /dev/null @@ -1,219 +0,0 @@ - - - - - org.eclipse.smarthome.bundles - io - 0.8.0-SNAPSHOT - - - - org.eclipse.smarthome.io.multimedia.tts.marytts - org.eclipse.smarthome.io.multimedia.tts.marytts - ${basedir}/resources - - - 4.0.0 - org.eclipse.smarthome.io - org.eclipse.smarthome.io.multimedia.tts.marytts - - Eclipse SmartHome Multimedia I/O MaryTTS - - eclipse-plugin - - - - - com.savage7.maven.plugins - maven-external-dependency-plugin - - - ${basedir}/lib - - - - - com.sun.speech.freetts - freetts - 1.0 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/freetts-1.0.jar - - true - - - - com.sun.speech.freetts - freetts-de - 1.0 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/freetts-de-1.0.jar - - true - - - - com.sun.speech.freetts - freetts-en_us - 1.0 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/freetts-en_us-1.0.jar - - true - - - - gov.noaa.pmel.sgt - sgt - 3.0 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/sgt-3.0.jar - - true - - - - de.dfki.lt.jtok - jtok-core - 1.9.1 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/jtok-core-1.9.1.jar - - true - - - - org.wikimedia - mwdumper - 1.16 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/mwdumper-1.16.jar - - true - - - - emotionml-checker-java - emotionml-checker-java - 1.0-SNAPSHOT - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/emotionml-checker-java-1.0-SNAPSHOT.jar - - true - - - - opennlp-maxent - opennlp-maxent - 3.0.1-incubating - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/opennlp-maxent-3.0.1-incubating.jar - - true - - - - opennlp-tools - opennlp-tools - 1.5.1-incubating - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/opennlp-tools-1.5.1-incubating.jar - - true - - - - marytts-lang-de - marytts-lang-de - 5.1-SNAPSHOT - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/marytts-lang-de-5.1-SNAPSHOT.jar - - true - - - - marytts-lang-en - marytts-lang-en - 5.1-SNAPSHOT - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/marytts-lang-en-5.1-SNAPSHOT.jar - - true - - - - voice-bits1-hsmm - voice-bits1-hsmm - 5.0-SNAPSHOT - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/voice-bits1-hsmm-5.0-SNAPSHOT.jar - - true - - - - voice-bits3-hsmm - voice-bits3-hsmm - 5.0-SNAPSHOT - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/voice-bits3-hsmm-5.0-SNAPSHOT.jar - - true - - - - voice-cmu-slt-hsmm - voice-cmu-slt-hsmm - 5.0 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/voice-cmu-slt-hsmm-5.0.jar - - true - - - - - - - resolve-install-external-dependencies - process-resources - - - resolve-external - - - - - - org.vafer - jdeb - - - - - - - com.savage7.maven.plugins - maven-external-dependency-plugin - 0.4 - - - - - - diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/src/main/java/org/eclipse/smarthome/io/multimedia/tts/marytts/internal/MultimediaActivator.java b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/src/main/java/org/eclipse/smarthome/io/multimedia/tts/marytts/internal/MultimediaActivator.java deleted file mode 100644 index 467ab4404815a..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/src/main/java/org/eclipse/smarthome/io/multimedia/tts/marytts/internal/MultimediaActivator.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.smarthome.io.multimedia.tts.marytts.internal; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Extension of the default OSGi bundle activator - * - * @author Kai Kreuzer - Initial contribution and API - */ -public class MultimediaActivator implements BundleActivator { - - private final Logger logger = LoggerFactory.getLogger(MultimediaActivator.class); - - private static BundleContext context; - - /** - * Called whenever the OSGi framework starts our bundle - */ - public void start(BundleContext bc) throws Exception { - context = bc; - logger.debug("Multimedia I/O MaryTTS bundle has been started."); - } - - /** - * Called whenever the OSGi framework stops our bundle - */ - public void stop(BundleContext bc) throws Exception { - context = null; - logger.debug("Multimedia I/O MaryTTS bundle has been stopped."); - } - - /** - * Returns the bundle context of this bundle - * @return the bundle context - */ - public static BundleContext getContext() { - return context; - } -} diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/src/main/java/org/eclipse/smarthome/io/multimedia/tts/marytts/internal/tts/TTSServiceMaryTTS.java b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/src/main/java/org/eclipse/smarthome/io/multimedia/tts/marytts/internal/tts/TTSServiceMaryTTS.java deleted file mode 100644 index 035c051b75ad5..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/src/main/java/org/eclipse/smarthome/io/multimedia/tts/marytts/internal/tts/TTSServiceMaryTTS.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) 2010-2015, openHAB.org and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.smarthome.io.multimedia.tts.marytts.internal.tts; - -import java.util.Locale; - -import javax.sound.sampled.AudioInputStream; - -import marytts.LocalMaryInterface; -import marytts.MaryInterface; -import marytts.exceptions.MaryConfigurationException; -import marytts.exceptions.SynthesisException; -import marytts.modules.synthesis.Voice; -import marytts.util.data.audio.AudioPlayer; - -import org.apache.commons.lang.StringUtils; -import org.eclipse.smarthome.io.multimedia.tts.TTSService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This is a pure Java TTS service implementation, based on MaryTTS. - * - * @author Tobias Bräutigam - * @since 0.8.0 - * - */ -public class TTSServiceMaryTTS implements TTSService { - private static final Logger logger = LoggerFactory - .getLogger(TTSServiceMaryTTS.class); - - private static MaryInterface marytts; - private Voice defaultVoice; - - public void activate() { - try { - marytts = new LocalMaryInterface(); - Locale systemLocale = Locale.getDefault(); - if (marytts.getAvailableLocales().contains(systemLocale)) { - defaultVoice = Voice.getDefaultVoice(systemLocale); - } - if (defaultVoice == null) { - // Fallback - defaultVoice = Voice.getVoice(marytts.getAvailableVoices() - .iterator().next()); - } - } catch (MaryConfigurationException e) { - logger.error( - "Error connecting to Mary TTS: " + e.getLocalizedMessage(), - e); - } - } - - public void deactivate() { - marytts = null; - } - - /** - * {@inheritDoc} - */ - public synchronized void say(String text, String voiceName, String outputDevice) { - if (marytts == null) { - logger.error("Mary TTS is not available"); - 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(); - - } catch (SynthesisException e) { - logger.error("Error during tts generation: {}", - e.getLocalizedMessage(), e); - } catch (InterruptedException e) { - logger.error("Error during tts playback: {}", - e.getLocalizedMessage(), e); - } - } else { - logger.error("Could not find voice: {}", voiceName); - logger.info("Available Voices are {} ", - StringUtils.join(marytts.getAvailableVoices(), ", ")); - } - } - -} diff --git a/bundles/io/pom.xml b/bundles/io/pom.xml index f69f55d18783e..94fca29250b26 100644 --- a/bundles/io/pom.xml +++ b/bundles/io/pom.xml @@ -19,7 +19,6 @@ org.openhab.io.transport.serial org.openhab.io.jetty org.openhab.io.rest.docs - org.openhab.io.multimedia.tts.marytts