当前位置: 首页>>代码示例>>Java>>正文


Java PlainTextOutputSpeech类代码示例

本文整理汇总了Java中com.amazon.speech.ui.PlainTextOutputSpeech的典型用法代码示例。如果您正苦于以下问题:Java PlainTextOutputSpeech类的具体用法?Java PlainTextOutputSpeech怎么用?Java PlainTextOutputSpeech使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PlainTextOutputSpeech类属于com.amazon.speech.ui包,在下文中一共展示了PlainTextOutputSpeech类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWelcomeResponse

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
/**
 * Creates and returns a {@code SpeechletResponse} with a welcome message.
 *
 * @return SpeechletResponse spoken and visual response for the given intent
 */
private SpeechletResponse getWelcomeResponse() {
    String speechText = "Welcome to the Alexa Skills Kit, you can say hello";

    // Create the Simple card content.
    SimpleCard card = new SimpleCard();
    card.setTitle("HelloWorld");
    card.setContent(speechText);

    // Create the plain text output.
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText(speechText);

    // Create reprompt
    Reprompt reprompt = new Reprompt();
    reprompt.setOutputSpeech(speech);

    return SpeechletResponse.newAskResponse(speech, reprompt, card);
}
 
开发者ID:arun-gupta,项目名称:alexa-skill-java,代码行数:24,代码来源:HelloWorldSpeechlet.java

示例2: getHelloResponse

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
/**
 * Creates a {@code SpeechletResponse} for the hello intent.
 *
 * @return SpeechletResponse spoken and visual response for the given intent
 */
private SpeechletResponse getHelloResponse(int times) {
    String speechText = "";
    for (int i=0; i<times; i++) {
        speechText += "Hello world " + (i+1) + " time. ";
    }
    
    // Create the Simple card content.
    SimpleCard card = new SimpleCard();
    card.setTitle("HelloWorld");
    card.setContent(speechText);

    // Create the plain text output.
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText(speechText);

    return SpeechletResponse.newTellResponse(speech, card);
}
 
开发者ID:arun-gupta,项目名称:alexa-skill-java,代码行数:23,代码来源:HelloWorldSpeechlet.java

示例3: getHelloDbResponse

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
private SpeechletResponse getHelloDbResponse(Person person, String id) {
    String speechText = "";
    
    if (person != null && person.getId() != null)
        speechText = "Name of the person with id " + person.getId() + " is " + person.getName();
    else
        speechText = "No person found with id " + id;

    // Create the Simple card content.
    SimpleCard card = new SimpleCard();
    card.setTitle("HelloDbWorld");
    card.setContent(speechText);

    // Create the plain text output.
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText(speechText);

    return SpeechletResponse.newTellResponse(speech, card);
}
 
开发者ID:arun-gupta,项目名称:alexa-skill-java,代码行数:20,代码来源:HelloWorldSpeechlet.java

示例4: getHelpResponse

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
/**
 * Creates a {@code SpeechletResponse} for the help intent.
 *
 * @return SpeechletResponse spoken and visual response for the given intent
 */
private SpeechletResponse getHelpResponse() {
    String speechText = "You can say hello to me!";

    // Create the Simple card content.
    SimpleCard card = new SimpleCard();
    card.setTitle("HelloWorld");
    card.setContent(speechText);

    // Create the plain text output.
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText(speechText);

    // Create reprompt
    Reprompt reprompt = new Reprompt();
    reprompt.setOutputSpeech(speech);

    return SpeechletResponse.newAskResponse(speech, reprompt, card);
}
 
开发者ID:arun-gupta,项目名称:alexa-skill-java,代码行数:24,代码来源:HelloWorldSpeechlet.java

示例5: buildCardSpeechletResponse

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
static public SpeechletResponse buildCardSpeechletResponse(final String output, final boolean shouldEndSession) {
    SimpleCard card = new SimpleCard();
    card.setTitle(AlexaSpeechlet.SKILLNAME);
    card.setContent(String.format("%s", output));

    // Create the plain text output.
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText(output);

    // Create the speechlet response.
    SpeechletResponse response = new SpeechletResponse();
    response.setShouldEndSession(shouldEndSession);
    response.setOutputSpeech(speech);
    response.setCard(card);
    return response;
}
 
开发者ID:hennroja,项目名称:rh-dropwizard-alexa,代码行数:17,代码来源:IntentHandler.java

示例6: nextEvents

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
@Test
public void nextEvents() throws CalendarReadException {
  //given
  final PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
  speech.setText("<event-listing>");
  List<Event> events = new ArrayList<>();

  doReturn(events).when(toTestQuery.calendarService).getNextEvents();
  doReturn(speech).when(toTestQuery.speechService).readEvents(any(), anyList());

  HttpEntity<String> request = buildRequest("NextEvents");

  //when
  final SpeechletResponseEnvelope response = perform(request);

  //then
  verify(toTestQuery.calendarService, times(1)).getNextEvents();
  assertNull(response.getResponse().getCard());
  assertTrue(response.getResponse().getOutputSpeech() instanceof PlainTextOutputSpeech);
  assertEquals(
      speech.getText(),
      ((PlainTextOutputSpeech)response.getResponse().getOutputSpeech()).getText());
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:24,代码来源:CalendarSpeechletIT.java

示例7: nextEvents_readError

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
@Test
public void nextEvents_readError() throws CalendarReadException {
  //given
  doThrow(new CalendarReadException("error")).when(toTestQuery.calendarService).getNextEvents();

  HttpEntity<String> request = buildRequest("NextEvents");

  //when
  final SpeechletResponseEnvelope response = perform(request);

  //then
  assertNull(response.getResponse().getCard());
  assertTrue(response.getResponse().getOutputSpeech() instanceof PlainTextOutputSpeech);
  assertEquals(
      msg.de("event.error.read"),
      ((PlainTextOutputSpeech)response.getResponse().getOutputSpeech()).getText());
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:18,代码来源:CalendarSpeechletIT.java

示例8: eventQuery

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
@Test
public void eventQuery() throws CalendarReadException {
  //given
  final PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
  speech.setText("<event-listing>");
  List<Event> events = new ArrayList<>();

  doReturn(events).when(toTestQuery.calendarService).getEvents(any(), any());
  doReturn(speech).when(toTestQuery.speechService).readEvents(any(), anyString(), anyList());

  //use cases
  testUseCase("diesen", "montag", Moment.MONDAY, speech);
  testUseCase("diesen", "dienstag", Moment.TUESDAY, speech);
  testUseCase("diesen", "mittwoch", Moment.WEDNESDAY, speech);
  testUseCase("diesen", "donnerstag", Moment.THURSDAY, speech);
  testUseCase("diesen", "freitag", Moment.FRIDAY, speech);
  testUseCase("diesen", "samstag", Moment.SATURDAY, speech);
  testUseCase("diesen", "sonntag", Moment.SUNDAY, speech);
  testUseCase("nächsten", "montag", Moment.MONDAY, speech);
  testUseCase("nächsten", "dienstag", Moment.TUESDAY, speech);
  testUseCase("nächsten", "mittwoch", Moment.WEDNESDAY, speech);
  testUseCase("nächsten", "donnerstag", Moment.THURSDAY, speech);
  testUseCase("nächsten", "freitag", Moment.FRIDAY, speech);
  testUseCase("nächsten", "samstag", Moment.SATURDAY, speech);
  testUseCase("nächsten", "sonntag", Moment.SUNDAY, speech);
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:27,代码来源:CalendarSpeechletIT.java

示例9: testUseCase

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
private void testUseCase(String precision, String day,
    Moment expectedMoment, OutputSpeech expectedSpeech) throws CalendarReadException {

  //when
  HttpEntity<String> request = buildRequest("EventQuery",
      "precision", precision, "day", day);

  final SpeechletResponseEnvelope response = perform(request);

  //then
  verify(toTestQuery.speechService, times(1)).readEvents(
      eq(Locale.GERMANY), eq(expectedMoment.getName(Locale.GERMANY)), anyList());

  assertNull(response.getResponse().getCard());
  assertTrue(response.getResponse().getOutputSpeech() instanceof PlainTextOutputSpeech);
  assertEquals(
      ((PlainTextOutputSpeech)expectedSpeech).getText(),
      ((PlainTextOutputSpeech)response.getResponse().getOutputSpeech()).getText());
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:20,代码来源:CalendarSpeechletIT.java

示例10: eventQuery_unknownDay

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
@Test
public void eventQuery_unknownDay() throws CalendarReadException {
  //given
  final PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
  speech.setText("<event-listing>");
  List<Event> events = new ArrayList<>();

  //when
  HttpEntity<String> request = buildRequest("EventQuery",
      "precision", "diesen", "day", "tag");

  final SpeechletResponseEnvelope response = perform(request);

  //then
  assertNull(response.getResponse().getCard());
  assertTrue(response.getResponse().getOutputSpeech() instanceof PlainTextOutputSpeech);
  assertEquals(
      msg.de("event.error.unknown.moment"),
      ((PlainTextOutputSpeech)response.getResponse().getOutputSpeech()).getText());
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:21,代码来源:CalendarSpeechletIT.java

示例11: eventQuery_unknownPrasicion

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
@Test
public void eventQuery_unknownPrasicion() throws CalendarReadException {
  //given
  final PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
  speech.setText("<event-listing>");
  List<Event> events = new ArrayList<>();

  doReturn(events).when(toTestQuery.calendarService).getEvents(any(), any());
  doReturn(speech).when(toTestQuery.speechService).readEvents(any(), anyString(), anyList());

  //when
  HttpEntity<String> request = buildRequest("EventQuery",
      "precision", "unbekannt", "day", "montag");

  final SpeechletResponseEnvelope response = perform(request);

  //then
  assertNull(response.getResponse().getCard());
  assertTrue(response.getResponse().getOutputSpeech() instanceof PlainTextOutputSpeech);
  assertEquals(
      msg.de("event.error.unknown.moment"),
      ((PlainTextOutputSpeech)response.getResponse().getOutputSpeech()).getText());
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:24,代码来源:CalendarSpeechletIT.java

示例12: nearEvents_unknown

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
@Test
public void nearEvents_unknown() throws CalendarReadException {
  //given
  final PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
  speech.setText("<event-listing>");
  List<Event> events = new ArrayList<>();

  doReturn(events).when(toTestQuery.calendarService).getEvents(any(), any());
  doReturn(speech).when(toTestQuery.speechService).readEvents(any(), anyString(), anyList());

  //when
  HttpEntity<String> request = buildRequest("EventQueryNear",
      "near", "unbekannt");

  final SpeechletResponseEnvelope response = perform(request);

  //then
  assertNull(response.getResponse().getCard());
  assertTrue(response.getResponse().getOutputSpeech() instanceof PlainTextOutputSpeech);
  assertEquals(
      msg.de("event.error.unknown.moment"),
      ((PlainTextOutputSpeech)response.getResponse().getOutputSpeech()).getText());
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:24,代码来源:CalendarSpeechletIT.java

示例13: thisWeek

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
@Test
public void thisWeek() throws CalendarReadException {
  //given
  final PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
  speech.setText("<event-listing>");
  List<Event> events = new ArrayList<>();

  doReturn(events).when(toTestQuery.calendarService).getEvents(any(), any());
  doReturn(speech).when(toTestQuery.speechService).readEvents(any(), anyString(), anyList());

  //when
  HttpEntity<String> request = buildRequest("EventQueryThisWeek");

  final SpeechletResponseEnvelope response = perform(request);

  //then
  verify(toTestQuery.speechService, times(1)).readEvents(
      eq(Locale.GERMANY), eq(Moment.THIS_WEEK.getName(Locale.GERMANY)), anyList());

  assertNull(response.getResponse().getCard());
  assertTrue(response.getResponse().getOutputSpeech() instanceof PlainTextOutputSpeech);
  assertEquals(
      speech.getText(),
      ((PlainTextOutputSpeech)response.getResponse().getOutputSpeech()).getText());
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:26,代码来源:CalendarSpeechletIT.java

示例14: nextWeek

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
@Test
public void nextWeek() throws CalendarReadException {
  //given
  final PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
  speech.setText("<event-listing>");
  List<Event> events = new ArrayList<>();

  doReturn(events).when(toTestQuery.calendarService).getEvents(any(), any());
  doReturn(speech).when(toTestQuery.speechService).readEvents(any(), anyString(), anyList());

  //when
  HttpEntity<String> request = buildRequest("EventQueryNextWeek");

  final SpeechletResponseEnvelope response = perform(request);

  //then
  verify(toTestQuery.speechService, times(1)).readEvents(
      eq(Locale.GERMANY), eq(Moment.NEXT_WEEK.getName(Locale.GERMANY)), anyList());

  assertNull(response.getResponse().getCard());
  assertTrue(response.getResponse().getOutputSpeech() instanceof PlainTextOutputSpeech);
  assertEquals(
      speech.getText(),
      ((PlainTextOutputSpeech)response.getResponse().getOutputSpeech()).getText());
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:26,代码来源:CalendarSpeechletIT.java

示例15: getWelcomeResponse

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入依赖的package包/类
/**
 * Creates and returns a {@code SpeechletResponse} with a welcome message.
 *
 * @return SpeechletResponse spoken and visual response for the given intent
 */
@OnLaunch
public SpeechletResponse getWelcomeResponse() {
  String speechText = "Welcome to the Alexa Skills Kit, you can say hello";

  // Create the Simple card content.
  SimpleCard card = new SimpleCard();
  card.setTitle("HelloWorld");
  card.setContent(speechText);

  // Create the plain text output.
  PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
  speech.setText(speechText);

  // Create reprompt
  Reprompt reprompt = new Reprompt();
  reprompt.setOutputSpeech(speech);

  return SpeechletResponse.newAskResponse(speech, reprompt, card);
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:25,代码来源:HelloWorldSpeechlet.java


注:本文中的com.amazon.speech.ui.PlainTextOutputSpeech类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。