本文整理汇总了Java中com.amazon.speech.slu.Slot.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Slot.getValue方法的具体用法?Java Slot.getValue怎么用?Java Slot.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazon.speech.slu.Slot
的用法示例。
在下文中一共展示了Slot.getValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDevice
import com.amazon.speech.slu.Slot; //导入方法依赖的package包/类
private SpeechletResponse setDevice(final Intent intent, boolean enable) {
Slot deviceSlot = intent.getSlot(DEVICE_SLOT);
if (deviceSlot == null || deviceSlot.getValue() == null) {
return newResponse("Gerät nicht erkannt");
}
try {
Optional<SwitchDevice> dev = findDevice(deviceSlot.getValue());
if (!dev.isPresent()) {
return newResponse(String.format("Das Gerät %s ist mir nicht bekannt", deviceSlot.getValue()));
}
SwitchDevice device = dev.get();
if (!device.isSwitch()) {
return newResponse(String.format("%s %s ist kein Schaltgerät", toGroupName(device), deviceSlot.getValue()));
}
if (!device.isPresent()) {
return newResponse(String.format("%s %s ist nicht verbunden", toGroupName(device), deviceSlot.getValue()));
}
service.setDeviceState(device, enable);
boolean succeed = device.getState() == (enable ? State.ON : State.OFF);
return newResponse("Fritz Home Switch", succeed ? "Ok" : String.format("Das Gerät %s konnte nicht geschaltet werden", deviceSlot.getValue()));
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return newResponse("Es ist ein Fehler beim Schalten des Gerätes aufgetreten");
}
示例2: getDeviceTemp
import com.amazon.speech.slu.Slot; //导入方法依赖的package包/类
private SpeechletResponse getDeviceTemp(final Intent intent, final Locale locale) {
Slot deviceSlot = intent.getSlot(DEVICE_SLOT);
if (deviceSlot == null || deviceSlot.getValue() == null) {
return newResponse("Gerät nicht erkannt");
}
try {
Optional<SwitchDevice> dev = findDevice(deviceSlot.getValue());
if (!dev.isPresent()) {
return newResponse(String.format("Das Gerät %s ist mir nicht bekannt", deviceSlot.getValue()));
}
SwitchDevice device = dev.get();
if (!device.isPresent()) {
return newResponse(String.format("%s %s ist aktuell nicht verfügbar", toGroupName(device), deviceSlot.getValue()));
}
if (!device.isTemperature()) {
return newResponse(String.format("%s %s hat keinen Temperatursensor", toGroupName(device), deviceSlot.getValue()));
}
return newResponse("Fritz Home Temperatur",
String.format("Die Temperatur an Gerät %s beträgt %s", deviceSlot.getValue(), FritzUtils.getTemperature(locale, device.getTemperature())));
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return newResponse("Es ist ein Fehler beim Lesen der Gerätetemperatur aufgetreten");
}
示例3: getSafeValue
import com.amazon.speech.slu.Slot; //导入方法依赖的package包/类
private static String getSafeValue(Slot slot) {
try {
return slot.getValue();
} catch (Exception e) {
return null;
}
}
示例4: getDeviceEnergy
import com.amazon.speech.slu.Slot; //导入方法依赖的package包/类
private SpeechletResponse getDeviceEnergy(final Intent intent, final Locale locale) {
Slot deviceSlot = intent.getSlot(DEVICE_SLOT);
if (deviceSlot == null || deviceSlot.getValue() == null) {
return newResponse("Gerät nicht erkannt");
}
try {
Optional<SwitchDevice> dev = findDevice(deviceSlot.getValue());
if (!dev.isPresent()) {
return newResponse(String.format("Das Gerät %s ist mir nicht bekannt", deviceSlot.getValue()));
}
SwitchDevice device = dev.get();
if (!device.isPresent()) {
return newResponse(String.format("%s %s ist aktuell nicht verfügbar", toGroupName(device), deviceSlot.getValue()));
}
if (!device.isPowermeter()) {
return newResponse(String.format("%s %s hat keine Energieverbauchswerte", toGroupName(device), deviceSlot.getValue()));
}
StringBuilder sb = new StringBuilder();
sb.append("Der aktuelle Energie Verbrauch von ").append(deviceSlot.getValue()).append(" ist ")
.append(FritzUtils.getPower(locale, device.getPower()));
if (device.getEnergy() > 0) {
sb.append(" mit einem Gesamtverbrauch von ").append(FritzUtils.getEnergy(locale, device.getEnergy()));
}
return newResponse("Fritz Home Energie", sb.toString());
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return newResponse("Es ist ein Fehler beim Lesen des Energie Verbrauches aufgetreten");
}
示例5: createNlpNamedEntity
import com.amazon.speech.slu.Slot; //导入方法依赖的package包/类
protected NlpNamedEntity createNlpNamedEntity(final Entry<String, Slot> entry) {
final Slot value = entry.getValue();
final String type = entry.getKey();
final String entity = value.getValue();
final NlpNamedEntity result = new NlpNamedEntity();
result.setType(type.toLowerCase());
result.setEntity(entity);
result.setConfidence(1.0);
return result;
}
示例6: getFastForwardResponse
import com.amazon.speech.slu.Slot; //导入方法依赖的package包/类
private SpeechletResponse getFastForwardResponse(Intent intent) {
String speechText;
// create the card
SimpleCard card = new SimpleCard();
card.setTitle("Fast Forward");
// create the plain text output
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
try {
Slot speedSlot = intent.getSlot("Speed");
if (speedSlot != null) {
String speed = speedSlot.getValue();
changeRecordingSpeed(speed);
speechText = "Fast forward at " + speed + " times";
}
else {
speechText = "No speed was heard";
}
setFeedback(speechText, speech, card);
}
catch (Exception e) {
reportException(e, speech, card);
speech.setText("Failed to fast forward");
}
return SpeechletResponse.newTellResponse(speech, card);
}
示例7: getRewindResponse
import com.amazon.speech.slu.Slot; //导入方法依赖的package包/类
private SpeechletResponse getRewindResponse(Intent intent) {
String speechText;
// create the card
SimpleCard card = new SimpleCard();
card.setTitle("Rewind");
// create the plain text output
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
try {
Slot speedSlot = intent.getSlot("Speed");
if (speedSlot != null) {
String speed = speedSlot.getValue();
changeRecordingSpeed("-" + speed);
speechText = "Rewind at " + speed + " times";
}
else {
speechText = "No speed was heard";
}
setFeedback(speechText, speech, card);
}
catch (Exception e) {
reportException(e, speech, card);
speech.setText("Failed to rewind");
}
return SpeechletResponse.newTellResponse(speech, card);
}
示例8: handleIntent
import com.amazon.speech.slu.Slot; //导入方法依赖的package包/类
@Override
public SpeechletResponse handleIntent(IntentRequest request, Intent intent) {
final Map<String, Slot> slots = intent.getSlots();
LOG.info("tookMedicine: slots={}", slots);
PlainTextOutputSpeech outputSpeech = SpeechletUtils.createTextOutputSpeech("Got it");
SimpleCard card = new SimpleCard();
card.setTitle("Took Medicine");
Slot defaultName = Slot.builder()
.withName("name").withValue("Someone")
.build();
Slot defaultType = Slot.builder()
.withName("typeOfMedicine")
.withValue("some")
.build();
Slot defaultWhen = Slot.builder()
.withName("timeWhen")
.withValue("the current time")
.build();
final String leadingLine = String.format("%s took %s medicine at %s.",
slots.getOrDefault("name", defaultName).getValue(),
slots.getOrDefault("typeOfMedicine", defaultType).getValue(),
slots.getOrDefault("timeWhen", defaultWhen).getValue());
StringBuilder sb = new StringBuilder(leadingLine);
final Slot takeNextIn = slots.get("takeNextIn");
if (takeNextIn.getValue() != null) {
sb.append("\n");
sb.append("Next dose due in ");
sb.append(takeNextIn.getValue());
}
card.setContent(sb.toString());
return SpeechletResponse.newTellResponse(outputSpeech, card);
}