Search in sources :

Example 1 with SpeechletResponse

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));
}
Also used : SpeechletResponse(com.amazon.speech.speechlet.SpeechletResponse)

Example 2 with SpeechletResponse

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
    "");
}
Also used : SpeechletResponse(com.amazon.speech.speechlet.SpeechletResponse)

Example 3 with SpeechletResponse

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;
}
Also used : SpeechletResponse(com.amazon.speech.speechlet.SpeechletResponse)

Example 4 with SpeechletResponse

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;
}
Also used : SpeechletResponse(com.amazon.speech.speechlet.SpeechletResponse)

Example 5 with SpeechletResponse

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;
}
Also used : SpeechletResponse(com.amazon.speech.speechlet.SpeechletResponse)

Aggregations

SpeechletResponse (com.amazon.speech.speechlet.SpeechletResponse)9 Intent (com.amazon.speech.slu.Intent)1 Directive (com.amazon.speech.speechlet.Directive)1 IntentRequest (com.amazon.speech.speechlet.IntentRequest)1 AudioItem (com.amazon.speech.speechlet.interfaces.audioplayer.AudioItem)1 Stream (com.amazon.speech.speechlet.interfaces.audioplayer.Stream)1 PlayDirective (com.amazon.speech.speechlet.interfaces.audioplayer.directive.PlayDirective)1 SimpleCard (com.amazon.speech.ui.SimpleCard)1