Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Refactored audio and voice support:
Browse files Browse the repository at this point in the history
- Created audio API in smarthome.core
- Introduced smarthome.core.voice for TTS, STT and HLI APIs
- Introduced smarthome.io.javasound for audio implementations based on Java Sound API
- Introduced smarthome.voice.mactts as a Mac specific TTS implementation

Also-By: Harald Kuhn <harald.kuhn@gmail.com>
Also-By: Kelly Davis <kdavis@mozilla.com>
Also-By: Tilman Kamp <tilmankamp@posteo.de>
Signed-off-by: Kai Kreuzer <kai@openhab.org>
  • Loading branch information
kaikreuzer committed Jul 19, 2016
1 parent 3a7999e commit 0204136
Show file tree
Hide file tree
Showing 114 changed files with 5,894 additions and 142 deletions.
8 changes: 8 additions & 0 deletions bundles/core/org.eclipse.smarthome.core.voice.test/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.smarthome.core.voice"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions bundles/core/org.eclipse.smarthome.core.voice.test/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.smarthome.core.voice.test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source.. = src/test/java/
output.. = target/test-classes/
bin.includes = META-INF/,\
.,\
about.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@

<parent>
<groupId>org.eclipse.smarthome.bundles</groupId>
<artifactId>io</artifactId>
<artifactId>core</artifactId>
<version>0.9.0-SNAPSHOT</version>
</parent>

<properties>
<bundle.symbolicName>org.eclipse.smarthome.io.audio</bundle.symbolicName>
<bundle.namespace>org.eclipse.smarthome.io.audio</bundle.namespace>
<bundle.symbolicName>org.eclipse.smarthome.core.voice.test</bundle.symbolicName>
<bundle.namespace>org.eclipse.smarthome.core.voice.test</bundle.namespace>
</properties>

<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.smarthome.io</groupId>
<artifactId>org.eclipse.smarthome.io.audio</artifactId>
<name>Eclipse SmartHome Audio I/O</name>
<packaging>eclipse-plugin</packaging>
<artifactId>org.eclipse.smarthome.core.voice.test</artifactId>

<name>Eclipse SmartHome Core Voice Test</name>

<packaging>eclipse-test-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2014-2016 by the respective copyright holders.
* 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.core.voice;

import org.junit.Assert;
import org.junit.Test;

/**
* Test general purpose STT exception
*
* @author Kelly Davis - Initial contribution and API
*/
public class STTExceptionTest {

/**
* Test STTException() constructor
*/
@Test
public void testConstructor0() {
STTException ttsException = new STTException();
Assert.assertNotNull("STTException() constructor failed", ttsException);
}

/**
* Test STTException(String message, Throwable cause) constructor
*/
@Test
public void testConstructor1() {
STTException ttsException = new STTException("Message", new Throwable());
Assert.assertNotNull("STTException(String, Throwable) constructor failed", ttsException);
}

/**
* Test STTException(String message) constructor
*/
@Test
public void testConstructor2() {
STTException ttsException = new STTException("Message");
Assert.assertNotNull("STTException(String) constructor failed", ttsException);
}

/**
* Test STTException(Throwable cause) constructor
*/
@Test
public void testConstructor3() {
STTException ttsException = new STTException(new Throwable());
Assert.assertNotNull("STTException(Throwable) constructor failed", ttsException);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (c) 2014-2016 by the respective copyright holders.
* 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.core.voice;

import org.junit.Assert;
import org.junit.Test;

/**
* Test SpeechRecognitionErrorEvent event
*
* @author Kelly Davis - Initial contribution and API
*/
public class SpeechRecognitionErrorEventTest {

/**
* Test SpeechRecognitionErrorEvent(String) constructor
*/
@Test
public void testConstructor() {
SpeechRecognitionErrorEvent sRE = new SpeechRecognitionErrorEvent("Message");
Assert.assertNotNull("SpeechRecognitionErrorEvent(String) constructor failed", sRE);
}

/**
* Test SpeechRecognitionErrorEvent.getMessage() method
*/
@Test
public void getMessageTest() {
SpeechRecognitionErrorEvent sRE = new SpeechRecognitionErrorEvent("Message");
Assert.assertEquals("SpeechRecognitionErrorEvent.getMessage() method failed", "Message", sRE.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright (c) 2014-2016 by the respective copyright holders.
* 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.core.voice;

import org.junit.Assert;
import org.junit.Test;

/**
* Test SpeechRecognitionEvent event
*
* @author Kelly Davis - Initial contribution and API
*/
public class SpeechRecognitionEventTest {

/**
* Test SpeechRecognitionEvent(String, float) constructor
*/
@Test
public void testConstructor() {
SpeechRecognitionEvent sRE = new SpeechRecognitionEvent("Message", 0.5f);
Assert.assertNotNull("SpeechRecognitionEvent(String, float) constructor failed", sRE);
}

/**
* Test SpeechRecognitionEvent.getTranscript() method
*/
@Test
public void getTranscriptTest() {
SpeechRecognitionEvent sRE = new SpeechRecognitionEvent("Message", 0.5f);
Assert.assertEquals("SpeechRecognitionEvent.getTranscript() method failed", "Message", sRE.getTranscript());
}

/**
* Test SpeechRecognitionEvent.getConfidence() method
*/
@Test
public void getConfidenceTest() {
SpeechRecognitionEvent sRE = new SpeechRecognitionEvent("Message", 0.5f);
Assert.assertEquals("SpeechRecognitionEvent.getConfidence() method failed", (double) 0.5f,
(double) sRE.getConfidence(), (double) 0.001f);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2014-2016 by the respective copyright holders.
* 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.core.voice;

import org.junit.Assert;
import org.junit.Test;

/**
* Test general purpose TTS exception
*
* @author Kelly Davis - Initial contribution and API
*/
public class TTSExceptionTest {

/**
* Test TTSException() constructor
*/
@Test
public void testConstructor0() {
TTSException ttsException = new TTSException();
Assert.assertNotNull("TTSException() constructor failed", ttsException);
}

/**
* Test TTSException(String message, Throwable cause) constructor
*/
@Test
public void testConstructor1() {
TTSException ttsException = new TTSException("Message", new Throwable());
Assert.assertNotNull("TTSException(String, Throwable) constructor failed", ttsException);
}

/**
* Test TTSException(String message) constructor
*/
@Test
public void testConstructor2() {
TTSException ttsException = new TTSException("Message");
Assert.assertNotNull("TTSException(String) constructor failed", ttsException);
}

/**
* Test TTSException(Throwable cause) constructor
*/
@Test
public void testConstructor3() {
TTSException ttsException = new TTSException(new Throwable());
Assert.assertNotNull("TTSException(Throwable) constructor failed", ttsException);
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.smarthome.io.voice</name>
<name>org.eclipse.smarthome.core.voice</name>
<comment></comment>
<projects>
</projects>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Mon Oct 11 21:08:09 CEST 2010
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
http://www.eclipse.org/legal/epl-v10.html
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.eclipse.smarthome.io.voice.text.stdinterpreter">
<implementation class="org.eclipse.smarthome.io.voice.internal.text.StandardHumanLanguageInterpreter"/>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.eclipse.smarthome.core.voice.text.stdinterpreter">
<implementation class="org.eclipse.smarthome.core.voice.internal.text.StandardInterpreter"/>
<service>
<provide interface="org.eclipse.smarthome.io.voice.text.HumanLanguageInterpreter"/>
<provide interface="org.eclipse.smarthome.core.voice.text.HumanLanguageInterpreter"/>
</service>
<reference bind="setItemRegistry" cardinality="1..1" interface="org.eclipse.smarthome.core.items.ItemRegistry" name="ItemRegistry" policy="static" unbind="unsetItemRegistry"/>
<reference bind="setEventPublisher" cardinality="1..1" interface="org.eclipse.smarthome.core.events.EventPublisher" name="EventPublisher" policy="static" unbind="unsetEventPublisher"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
http://www.eclipse.org/legal/epl-v10.html
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.eclipse.smarthome.io.voice.extensions.say">
<implementation class="org.eclipse.smarthome.io.voice.internal.extensions.SayConsoleCommandExtension"/>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.eclipse.smarthome.core.voice.extensions">
<implementation class="org.eclipse.smarthome.core.voice.internal.VoiceConsoleCommandExtension"/>
<service>
<provide interface="org.eclipse.smarthome.io.console.extensions.ConsoleCommandExtension"/>
</service>
<reference bind="setItemRegistry" cardinality="1..1" interface="org.eclipse.smarthome.core.items.ItemRegistry" name="ItemRegistry" policy="static" unbind="unsetItemRegistry"/>
<reference bind="setVoiceManager" cardinality="1..1" interface="org.eclipse.smarthome.core.voice.VoiceManager" name="VoiceManager" policy="static" unbind="unsetVoiceManager"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2014-2016 by the respective copyright holders.
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
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" configuration-policy="optional" immediate="true" modified="modified" name="org.eclipse.smarthome.voice">
<implementation class="org.eclipse.smarthome.core.voice.VoiceManager"/>
<reference bind="addKSService" cardinality="0..n" interface="org.eclipse.smarthome.core.voice.KSService" name="KSService" policy="dynamic" unbind="removeKSService"/>
<reference bind="addSTTService" cardinality="0..n" interface="org.eclipse.smarthome.core.voice.STTService" name="STTService" policy="dynamic" unbind="removeSTTService"/>
<reference bind="addTTSService" cardinality="0..n" interface="org.eclipse.smarthome.core.voice.TTSService" name="TTSService" policy="dynamic" unbind="removeTTSService"/>
<reference bind="addHumanLanguageInterpreter" cardinality="0..n" interface="org.eclipse.smarthome.core.voice.text.HumanLanguageInterpreter" name="HumanLanguageInterpreter" policy="dynamic" unbind="removeHumanLanguageInterpreter"/>
<reference bind="addAudioSource" cardinality="0..n" interface="org.eclipse.smarthome.core.audio.AudioSource" name="AudioSource" policy="dynamic" unbind="removeAudioSource"/>
<reference bind="addAudioSink" cardinality="0..n" interface="org.eclipse.smarthome.core.audio.AudioSink" name="AudioSink" policy="dynamic" unbind="removeAudioSink"/>
<reference bind="setLocaleProvider" cardinality="1..1" interface="org.eclipse.smarthome.core.i18n.LocaleProvider" name="LocaleProvider" policy="static" unbind="unsetLocaleProvider"/>

<service>
<provide interface="org.eclipse.smarthome.core.voice.VoiceManager"/>
</service></scr:component>
28 changes: 28 additions & 0 deletions bundles/core/org.eclipse.smarthome.core.voice/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>

<p>June 5, 2006</p>
<h3>License</h3>

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

<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
being redistributed by another party (&quot;Redistributor&quot;) 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 <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output.. = target/classes/
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
about.html
source.. = src/main/java/,\
src/main/resources/
Loading

0 comments on commit 0204136

Please sign in to comment.