//Create a class for speech synthesis package SpeechSynthesis import SmartThing.SmartThing //Importing mutable integer class import MutableInteger.MutableInteger public class SpeechSynthesis extends SmartThing { // id, label, and display name of the device StringBuilder id = new StringBuilder() StringBuilder label = new StringBuilder() StringBuilder displayName = new StringBuilder() // Features with numberical values MutableInteger currentLevel = new MutableInteger() // Maps from features to values HashMap deviceIntValuesMap = new HashMap() SpeechSynthesis(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentLevel) { deviceIntValuesMap = deviceIntValueSmartThing idSmartThing = id labelSmartThing = label displayNameSmartThing = displayName sendEventSmartThings = sendEvent // Initialization this.id = id this.label = label this.displayName = displayName this.currentLevel = currentLevel deviceIntValuesMap.put("level", currentLevel) } // Methods to set values def setLevel(int newValue) { if (!currentLevel.getValue().equals(newValue)) { String tmpID = id.toString() currentLevel.setValue(newValue) println("The level of speech synthesis with id:$tmpID is changed to $currentLevel") } } def speak(String message) { String tmpID = id.toString() println("Speech synthesis with id:$tmpID, SPEAKING:\"$message\"!") } // Methods to return values def getCurrentLevel() { return currentLevel.getValue() } }