我是VUI和Alexa的新手。我为Alexa语音服务开发了一个很好的工作技能。现在我想添加第二种语言。我在 the develop documation中找到了一个教程,但我使用Eclipse和Java创建了我的Lambda函数,如walkthrough。 问题是,我不知道如何在Lambda函数中启用第二种语言选项。我必须为两种语言使用相同的Lambda函数。如何使用Java创建多语言Alexa技巧?
我StreamRequestHandler:
public class ApiOmatBlogSpeechletStreamRequestHandler extends SpeechletRequestStreamHandler {
private static final Set<String> supportedApplicationIds = new HashSet<String>();
static {
/*
* This Id can be found on https://developer.amazon.com/edw/home.html#/ "Edit" the relevant
* Alexa Skill and put the relevant Application Ids in this Set.
*/
supportedApplicationIds.add("amzn1.ask.skill.xxxxxxxx");
}
public ApiOmatBlogSpeechletStreamRequestHandler() {
super(new ApiOmatBlogSkillSpeechlet(), supportedApplicationIds);
System.out.println("Super ApiOmatBlogSpeechletStreamRequestHandler");
}
}
我Spechlet:
public SpeechletResponse onIntent(IntentRequest intentRequest, Session session) {
Intent intent = intentRequest.getIntent();
String intentName = (intent != null) ? intent.getName() : null;
System.out.println("onIntent requestId={ " + intentRequest.getRequestId() + " }, sessionId={ "
+ session.getSessionId() + " } ");
Integer step = (Integer) session.getAttribute("step");
System.out.println("IntentName= " + intentName + " | step = " + step);
if ("AMAZON.HelpIntent".equals(intentName)) {
return getHelpResponse();
} else if ("AMAZON.StopIntent".equals(intentName)) {
return getStopResponse();
} else if (step != null) {
return testing(intent, session, step);
} else {
if ("TestIntent".equals(intentName)) {
step = 1;
session.setAttribute("step", step);
return testing(intent, session, step);
} else {
SsmlOutputSpeech speechText = new SsmlOutputSpeech();
speechText.setSsml("<speak> " + "The intent is invalid." + "Please repeat your demand. "
+ "<break time='0.5s'/> " + " </speak>");
// Create reprompt
PlainTextOutputSpeech speech2 = new PlainTextOutputSpeech();
speech2.setText("I'm sorry. Please repeat your statement.");
Reprompt reprompt = new Reprompt();
reprompt.setOutputSpeech(speech2);
return SpeechletResponse.newAskResponse(speechText, reprompt);
}
}
}
/**
* This function will be called if you say 'start'
*/
public SpeechletResponse onLaunch(final LaunchRequest request, final Session session) throws SpeechletException {
System.out.println(
"onLaunch requestId={ " + request.getRequestId() + " }, sessionId={ " + session.getSessionId() + " } ");
return getHelpResponse();
}
谢谢
这是不对的,因为我创建了一个英文语言技能,其中的答案文本也是英文。现在我已经添加了第二种语言,德语。开发者门户网站不允许我发布第二个lambda函数。我必须为英语和德语使用相同的功能。因为我不想在德语模式下获得英语答案,所以我必须决定是以德语还是英语来称呼技能。 –
如果您阅读我提供的文档链接,您可能已经注意到了一行'代码必须处理您支持的所有语言' –
这就是要点!但是只有Javascript的文档,没有Java的文档,所以我如何在我的Lambda函数中划分语言,正如我在问题中提出的那样:“问题是,我不知道如何启用第二种语言选项Lambda函数...“ –