本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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());
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}