use of com.amazon.speech.speechlet.SpeechletResponse in project amos-ss17-alexa by c-i-ber.
the class AmosAlexaSpeechletTest method testIntent.
private void testIntent(String intent, String... params) throws IOException, NoSuchFieldException, IllegalAccessException {
String[] slots = new String[params.length - 1];
String expectedOutput = null;
int i = 0;
for (String param : params) {
if (i == params.length - 1) {
expectedOutput = param;
} else {
slots[i] = param;
i++;
}
}
AmosAlexaSpeechlet amosAlexaSpeechlet = AmosAlexaSpeechlet.getInstance();
SpeechletResponse response = amosAlexaSpeechlet.onIntent(getEnvelope(intent, slots));
assertEquals(expectedOutput, performIntent(intent, slots));
}
use of com.amazon.speech.speechlet.SpeechletResponse in project amos-ss17-alexa by c-i-ber.
the class AbstractAmosAlexaSpeechletTest method performIntent.
protected String performIntent(String intent, String... params) throws IOException, NoSuchFieldException, IllegalAccessException {
String[] slots = new String[params.length];
timer.add(System.currentTimeMillis());
intents.add(intent);
if (timer.size() == 2) {
long elapsedTime = timer.get(1) - timer.get(0);
if (elapsedTime > 5000) {
System.err.println("Elapsed Time: " + elapsedTime + "ms Intent: " + intents.get(0) + " may take too long");
}
intents.clear();
timer.clear();
}
int i = 0;
for (String param : params) {
slots[i] = param;
i++;
}
AmosAlexaSpeechlet amosAlexaSpeechlet = AmosAlexaSpeechlet.getInstance();
SpeechletResponse response = amosAlexaSpeechlet.onIntent(getEnvelope(intent, slots));
return getOutputSpeechText(response.getOutputSpeech()).replaceAll("\\<.*?>", // Remove all markup since it is not really relevant for our tests
"");
}
use of com.amazon.speech.speechlet.SpeechletResponse in project amos-ss17-alexa by c-i-ber.
the class AbstractSpeechService method getSSMLAskResponse.
/**
* Helper method for retrieving an Ask response with a simple card and a speech text included.
*
* @param cardTitle Title of the card that you want displayed.
* @param speechText speech text that will be spoken to the user (and also be used as reprompt)
* @return the resulting card and speech text.
*/
protected SpeechletResponse getSSMLAskResponse(String cardTitle, String speechText) {
SimpleCard card = getSimpleCard(cardTitle, speechText);
SsmlOutputSpeech ssmlOutputSpeech = getSSMLOutputSpeech(speechText);
Reprompt reprompt = getReprompt(ssmlOutputSpeech);
SpeechletResponse response = SpeechletResponse.newAskResponse(ssmlOutputSpeech, reprompt, card);
response.setShouldEndSession(false);
return response;
}
use of com.amazon.speech.speechlet.SpeechletResponse in project amos-ss17-alexa by c-i-ber.
the class AbstractSpeechService method getSSMLResponse.
/**
* response a ssml speech text (further information:
* https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference)
*
* @param cardTitle card title
* @param ssmlText string in ssml format
* @return SpeechletResponse
*/
protected SpeechletResponse getSSMLResponse(String cardTitle, String ssmlText) {
SimpleCard card = getSimpleCard(cardTitle, ssmlText);
SsmlOutputSpeech ssmlOutputSpeech = getSSMLOutputSpeech(ssmlText);
SpeechletResponse response = SpeechletResponse.newTellResponse(ssmlOutputSpeech, card);
response.setShouldEndSession(true);
return response;
}
use of com.amazon.speech.speechlet.SpeechletResponse in project amos-ss17-alexa by c-i-ber.
the class AbstractSpeechService method getResponse.
/**
* Helper method for retrieving an response with a simple card and reprompt included.
*
* @param cardTitle Title of the card that you want displayed.
* @param speechText speech text that will be spoken to the user.
* @return the resulting card and speech text.
*/
protected SpeechletResponse getResponse(String cardTitle, String speechText) {
SimpleCard card = getSimpleCard(cardTitle, speechText);
PlainTextOutputSpeech speech = getPlainTextOutputSpeech(speechText);
SpeechletResponse response = SpeechletResponse.newTellResponse(speech, card);
response.setShouldEndSession(true);
return response;
}
Aggregations