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


Java OutputSpeech类代码示例

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


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

示例1: handleProgress

import com.amazon.speech.ui.OutputSpeech; //导入依赖的package包/类
private SpeechletResponse handleProgress(IntentRequest request, Session session) {
  checkCalendarName(request, session);

  if(allSlotsFilled(request)) {
    final String title = collectSummary(request);
    final DateTime from = DateTime.parse(
        sv(request, SLOT_DATE_FROM) + "T" + sv(request, SLOT_TIME_FROM));
    final DateTime to = getTimeTo(request, from);

    final String dateFormat = messageService.de("event.new.card.content.time.format");
    session.setAttribute(SESSION_DATE_FORMAT, dateFormat);
    session.setAttribute(SESSION_FROM, from.toString(dateFormat));
    session.setAttribute(SESSION_TO, to.toString(dateFormat));

    final OutputSpeech speech = speechService.confirmNewEvent(title, from, to, request.getLocale());
    return SpeechletResponse.newDialogConfirmIntentResponse(speech);
  }

  //normally we want to delegate because we have defined the dialog into the model on alexa
  if( request.getDialogState() != DialogState.COMPLETED) {
    Intent updatedIntent = updateIntent(request.getIntent());
    return SpeechletResponse.newDialogDelegateResponse(updatedIntent);
  }

  return SpeechletResponse.newTellResponse(speechService.speechCancelNewEvent(request.getLocale()));
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:27,代码来源:NewEventSpeechlet.java

示例2: confirmNewEvent

import com.amazon.speech.ui.OutputSpeech; //导入依赖的package包/类
public OutputSpeech confirmNewEvent(String title, DateTime from, DateTime to, Locale locale) {
  final String speechText;
  if(from.getYear() == to.getYear() && from.getDayOfYear() == to.getDayOfYear()) {
    speechText = messageService.de("event.new.confirm.sameday",
        from.toString(DAY_FORMAT, locale),
        from.toString(DATE_YEAR_FORMAT),
        from.toString(TIME_FORMAT),
        to.toString(TIME_FORMAT),
        title);
  } else {
    speechText = messageService.de("event.new.confirm",
        from.toString(DAY_FORMAT, locale),
        from.toString(DATE_YEAR_FORMAT),
        from.toString(TIME_FORMAT),
        to.toString(DAY_FORMAT, locale),
        to.toString(DATE_YEAR_FORMAT),
        to.toString(TIME_FORMAT),
        title);
  }

  return speechMessage(speechText);
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:23,代码来源:SpeechService.java

示例3: testUseCase

import com.amazon.speech.ui.OutputSpeech; //导入依赖的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

示例4: getOutputSpeech

import com.amazon.speech.ui.OutputSpeech; //导入依赖的package包/类
/**
 * Gets the generated output speech.
 * @return the generated output speech.
 */
@Override
public OutputSpeech getOutputSpeech() {
    if (outputSpeech != null) {
        return outputSpeech;
    }

    final String utterance;

    try {
        utterance = yamlReader.getRandomUtterance(output).orElseThrow(IOException::new);
        LOG.debug("Random utterance read out from YAML file: " + utterance);
    } catch (IOException e) {
        LOG.error("Error while generating response utterance.", e);
        return null;
    }

    final String utteranceSsml = resolveSlotsInUtterance(utterance);

    final SsmlOutputSpeech ssmlOutputSpeech = new SsmlOutputSpeech();
    ssmlOutputSpeech.setSsml(utteranceSsml);
    return ssmlOutputSpeech;
}
 
开发者ID:KayLerch,项目名称:alexa-skills-kit-tellask-java,代码行数:27,代码来源:AlexaSpeechletResponse.java

示例5: testAllTypes

import com.amazon.speech.ui.OutputSpeech; //导入依赖的package包/类
@Test
public void testAllTypes(){
    List<String> response = Arrays.asList("This is a test of the emergency broadcast system",
            "The broadcasters in your area along with state, local, and federal authorities have" +
                    "developed this system to keep you informed in the event of an emergency",
            "If this had been an actual emergency, the attention signal you just heard would have been" +
                    "followed by news, weather, and traffic on the nines");
    MustacheBundle bundle = new MustacheBundle("/alltypes", "en");
    OutputSpeech speech = bundle.createOutputSpeech(response, mock(IntentRequest.class), SESSION);
    assertTrue(speech instanceof SsmlOutputSpeech);
    StringBuilder sb = new StringBuilder("<speak>");
    response.forEach(s-> sb.append("<s>").append(s).append("</s>"));
    sb.append("</speak>");
    assertEquals(sb.toString(), ((SsmlOutputSpeech) speech).getSsml().trim());


}
 
开发者ID:kebernet,项目名称:skillz,代码行数:18,代码来源:MustacheBundleTest.java

示例6: getCurse

import com.amazon.speech.ui.OutputSpeech; //导入依赖的package包/类
@OnIntent("BITCOINGetCurse")
public SpeechletResponse getCurse(final IntentRequest request, final Session session) {
  final BitcoinCurse currentCurse = bitcoinService.getCurrentCurse();
  final OutputSpeech speech = speechService.speechCurse(currentCurse, request.getLocale());

  return SpeechletResponse.newTellResponse(speech);
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:8,代码来源:BitcoinSpeechlet.java

示例7: getWelcomeResponse

import com.amazon.speech.ui.OutputSpeech; //导入依赖的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(final LaunchRequest request) {
  final OutputSpeech speech = speechService.speechWelcomeMessage(request.getLocale());

  return SpeechletResponse.newAskResponse(speech, new Reprompt());
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:12,代码来源:BasicSpeechlet.java

示例8: getHelpResponse

import com.amazon.speech.ui.OutputSpeech; //导入依赖的package包/类
/**
 * Creates a {@code SpeechletResponse} for the help intent.
 *
 * @return SpeechletResponse spoken and visual response for the given intent
 */
@OnIntent("AMAZON.HelpIntent")
public SpeechletResponse getHelpResponse(final IntentRequest request) {
  final OutputSpeech speech = speechService.speechHelpMessage(request.getLocale());

  return SpeechletResponse.newTellResponse(speech);
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:12,代码来源:BasicSpeechlet.java

示例9: cancelOrStop

import com.amazon.speech.ui.OutputSpeech; //导入依赖的package包/类
@OnIntent({"AMAZON.CancelIntent", "AMAZON.StopIntent"})
public SpeechletResponse cancelOrStop(final IntentRequest request, final Session session) {
  final OutputSpeech speech = speechService.speechBye(request.getLocale());

  final SpeechletResponse response = SpeechletResponse.newTellResponse(speech);
  return response;
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:8,代码来源:BasicSpeechlet.java

示例10: speechCurse

import com.amazon.speech.ui.OutputSpeech; //导入依赖的package包/类
public OutputSpeech speechCurse(BitcoinCurse bitcoinCurse, Locale locale) {
  final String speechText = messageService.de("bitcoin.curse.current",
      bitcoinCurse.getEuro()
  );

  return speechMessage(speechText);
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:8,代码来源:SpeechService.java

示例11: handleSetCalendarInSession

import com.amazon.speech.ui.OutputSpeech; //导入依赖的package包/类
@OnIntent("SetCalendarInSession")
public SpeechletResponse handleSetCalendarInSession(IntentRequest request, Session session){
  final String calendarName = checkCalendarName(request, session);
  final OutputSpeech answer = speechService.speechConnectWithCalendar(calendarName, request.getLocale());
  final SpeechletResponse response = SpeechletResponse.newTellResponse(answer);
  response.setShouldEndSession(false);

  return response;
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:10,代码来源:NewEventSpeechlet.java

示例12: readEvents

import com.amazon.speech.ui.OutputSpeech; //导入依赖的package包/类
public OutputSpeech readEvents(Locale locale, String moment, List<Event> events) {
  if (events.isEmpty()) {
    final String speechText = messageService.de("event.nothing", moment);
    return speechMessage(speechText);
  }

  StringBuilder sb = new StringBuilder(messageService.de("event.listing.start", moment));
  for (Event event : events) {
    sb.append("<break time=\"500ms\"/>");
    sb.append(generateSpeechText(locale, event));
  }

  return speechMessage(sb.toString());
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:15,代码来源:SpeechService.java

示例13: speechError

import com.amazon.speech.ui.OutputSpeech; //导入依赖的package包/类
public OutputSpeech speechError(Throwable t) {
  final String speechText;
  if (t instanceof AlexaExcpetion) {
    speechText = messageService.de(((AlexaExcpetion)t).getMessageKey());
  } else {
    speechText = messageService.de("event.error");
  }

  return speechMessage(speechText);
}
 
开发者ID:rainu,项目名称:alexa-skill,代码行数:11,代码来源:SpeechService.java

示例14: createOutputSpeech

import com.amazon.speech.ui.OutputSpeech; //导入依赖的package包/类
@Override
public OutputSpeech createOutputSpeech(Object response, SpeechletRequest request, Session session){
    boolean useSSML = ssmlTemplate != null;
    String formatted = format(useSSML ? ssmlTemplate : txtTemplate, response, request, session);
    return useSSML ? SsmlOutputBuilder.withSsml(formatted.replaceAll("\n", "").replaceAll("  +", "")).build() :
            PlainTextOutputBuilder.withText(formatted).build();
}
 
开发者ID:kebernet,项目名称:skillz,代码行数:8,代码来源:MustacheBundle.java

示例15: testSimpleText

import com.amazon.speech.ui.OutputSpeech; //导入依赖的package包/类
@Test
public void testSimpleText(){
    MustacheBundle bundle = new MustacheBundle("/simpletest", "en");
    OutputSpeech speech = bundle.createOutputSpeech(
            Arrays.asList("one", "two", "three"),
            mock(IntentRequest.class), SESSION);
    assertTrue(speech instanceof PlainTextOutputSpeech);
    assertEquals("List: one two three", ((PlainTextOutputSpeech) speech).getText().trim());
}
 
开发者ID:kebernet,项目名称:skillz,代码行数:10,代码来源:MustacheBundleTest.java


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