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


Java PlainTextOutputSpeech.setText方法代码示例

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


在下文中一共展示了PlainTextOutputSpeech.setText方法的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: 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

示例5: 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
 */
@OnIntent({ "AMAZON.HelpIntent", "AMAZON.StopIntent", "AMAZON.CancelIntent" })
public 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:rainu,项目名称:alexa-skill,代码行数:25,代码来源:HelloWorldSpeechlet.java

示例6: 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
 */
@OnIntent("HelloWorldIntent")
public SpeechletResponse getHelloResponse() {
  String speechText = "Hello world";

  // 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:rainu,项目名称:alexa-skill,代码行数:21,代码来源:HelloWorldSpeechlet.java

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: onLaunch

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入方法依赖的package包/类
@Override
public SpeechletResponse onLaunch(LaunchRequest request, Session session) throws SpeechletException {
    String speechText = "Hello world, this is Snoolexa! Try asking for hot posts!";

    //TODO: Query the me endpoint and tell asker about currently signed in redditor and any notifications

    // Create the Simple card content.
    SimpleCard card = new SimpleCard();
    card.setTitle("Snoolexa");
    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:winterton,项目名称:snoolexa,代码行数:22,代码来源:SnoolexaSpeechlet.java

示例14: onIntent

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入方法依赖的package包/类
@Override
public SpeechletResponse onIntent(IntentRequest intentRequest, Session session) throws SpeechletException {
    if (intentRequest.getRequestId().equals("ExceptionID")) {
        throw new SpeechletException("What happened?");
    } else if (intentRequest.getRequestId().equals("ExceptionID2")) {
        throw new RuntimeException("What happened Still?");
    }

    SpeechletResponse response = new SpeechletResponse();
    PlainTextOutputSpeech outputSpeech = new PlainTextOutputSpeech();
    outputSpeech.setText("Test");
    response.setOutputSpeech(outputSpeech);
    System.out.println("SystemOutTest");
    System.err.println("SystemErrTest");
    return response;
}
 
开发者ID:bespoken,项目名称:bst4j,代码行数:17,代码来源:SpeechletWrapperTest.java

示例15: buildSpeechletResponse

import com.amazon.speech.ui.PlainTextOutputSpeech; //导入方法依赖的package包/类
private SpeechletResponse buildSpeechletResponse(AlexaResponse controllerResponse, String title) {
	// Create the Simple card content.
       SimpleCard card = new SimpleCard();
       card.setTitle(String.format("Response from Alexa Skill"));
       card.setContent(controllerResponse.getContent());

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

       // Create the speechlet response.
       SpeechletResponse response = new SpeechletResponse();
       response.setShouldEndSession(controllerResponse.getShouldEndInteraction());
       response.setOutputSpeech(speech);
       response.setCard(card);
       return response;
}
 
开发者ID:rs22,项目名称:alexa-routing,代码行数:18,代码来源:SpeechRouter.java


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