Skip to content

Instantly share code, notes, and snippets.

@ghys
Created October 24, 2017 07:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghys/a55555481e22bd705cdba7742ae99373 to your computer and use it in GitHub Desktop.
Save ghys/a55555481e22bd705cdba7742ae99373 to your computer and use it in GitHub Desktop.
Smart Home Day talk configuration (22.10.2017)
# The installation package of this openHAB instance
# Note: This is only regarded at the VERY FIRST START of openHAB
# Note: If you want to specify your add-ons yourself through entries below, set the package to "minimal"
# as otherwise your definition might be in conflict with what the installation package defines.
#
# Optional. If not set, the dashboard (https://<yourserver>:8080/) will ask you to choose a package.
#
# Valid options:
# - minimal : Installation only with dashboard, but no UIs or other add-ons. Use this for custom setups.
# - simple : Setup for using openHAB purely through UIs - you need to expect MANY constraints in functionality!
# - standard : Default setup for normal users, best for textual setup
# - expert : Setup for expert users, especially for people migrating from openHAB 1.x
# - demo : A demo setup which includes UIs, a few bindings, config files etc.
#
# See http://docs.openhab.org/configuration/packages.html for a detailed explanation of these packages.
#
package = simple
# Access Remote Add-on Repository
# Defines whether the remote openHAB add-on repository should be used for browsing and installing add-ons.
# This not only makes latest snapshots of add-ons available, it is also required for the installation of
# any legacy 1.x add-on. (default is true)
#
remote = true
# Include legacy 1.x bindings. If set to true, it also allows the installation of 1.x bindings for which there is
# already a 2.x version available (requires remote repo access, see above). (default is false)
#
legacy = true
# A comma-separated list of bindings to install (e.g. "sonos,knx,zwave")
binding = mqtt1
# A comma-separated list of UIs to install (e.g. "basic,paper")
#ui =
# A comma-separated list of persistence services to install (e.g. "rrd4j,jpa")
#persistence =
# A comma-separated list of actions to install (e.g. "mail,pushover")
#action =
# A comma-separated list of transformation services to install (e.g. "map,jsonpath")
#transformation =
# A comma-separated list of voice services to install (e.g. "marytts,freetts")
voice = marytts
# A comma-separated list of miscellaneous services to install (e.g. "myopenhab")
#misc =
#JSGF 1.0
grammar commands;
<location> = küche | wohnzimmer | schlafzimmer | büro;
public <action> = openhab | <location> licht (einschalten | ausschalten);
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import edu.cmu.sphinx.api.Configuration;
import edu.cmu.sphinx.api.SpeechResult;
import edu.cmu.sphinx.api.StreamSpeechRecognizer;
import edu.cmu.sphinx.api.LiveSpeechRecognizer;
public class LiveDE {
public LiveDE() throws Exception {
System.out.println("Hello! Initializing Sphinx...");
Configuration configuration = new Configuration();
configuration.setAcousticModelPath("file:/opt/stt/de/cmusphinx-de-ptm-voxforge-5.2");
configuration.setDictionaryPath("file:/opt/stt/de/de.dic");
configuration.setGrammarPath("file:/opt/stt/de/grammar/");
configuration.setGrammarName("commands");
configuration.setUseGrammar(true);
LiveSpeechRecognizer recognizer = new LiveSpeechRecognizer(configuration);
recognizer.startRecognition(true);
System.out.println("Ready!");
SpeechResult result;
while ((result = recognizer.getResult()) != null) {
System.out.format("Hypothesis: %s\n", result.getHypothesis());
}
recognizer.stopRecognition();
}
}
#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#
# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
#<broker>.url=tcp://<host>:1883
snips.url=tcp://localhost:9898
# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
#<broker>.clientId=<clientId>
# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#<broker>.allowLongerClientIds=false
# Optional. User id to authenticate with the broker.
#<broker>.user=<user>
# Optional. Password to authenticate with the broker.
#<broker>.pwd=<password>
# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
#<broker>.qos=<qos>
# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#<broker>.retain=<retain>
# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>
# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>
#JSGF V1.0;
grammar openhab;
<thing> = erste licht | zweite licht;
<color> = blau | rot | grün | gelb;
<keyword> = openhab;
<action> = schalte | mach;
public <command> = <keyword> | <action> (den|die|das) <thing> (ein | aus | <color>);
Color Light1 "Erste Licht" <light>
Color Light2 "Zweite Licht" <light>
String Snips_Intent { mqtt="<[snips:hermes/nlu/intentParsed:state:default]" }
Switch Snips_Listening { mqtt="<[snips:hermes/asr/toggleOn:state:ON],<[snips:hermes/asr/toggleOff:state:OFF]" }
Switch Sphinx_Listening
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment