internal AlexaResponse ToAlexaResponse(IMediaLinkProcessor linkProcessor, string voiceId) { AlexaResponse resp = new AlexaResponse() { Version = "1.0", Response = new AlexaResponseAttributes() { OutputSpeech = new OutputSpeechAttributes() } }; resp.Response.OutputSpeech = OutputSpeechBuilder.GetSsmlSpeech(GetSpeechText(this.OutputSpeech, linkProcessor, voiceId)); string repromptText = GetSpeechText(this.Reprompt, linkProcessor, voiceId); if (!string.IsNullOrWhiteSpace(repromptText)) { resp.Response.Reprompt = new RepromptAttributes() { OutputSpeech = OutputSpeechBuilder.GetSsmlSpeech(repromptText) }; } if (this.Card != null) { if (!string.IsNullOrWhiteSpace(this.Card.LargeImage) || !string.IsNullOrWhiteSpace(this.Card.SmallImage)) { resp.Response.Card = CardBuilder.GetStandardCardResponse(this.Card.Title, this.Card.Text, linkProcessor.GetImageUrl(this.Card.SmallImage), linkProcessor.GetImageUrl(this.Card.LargeImage)); } else { resp.Response.Card = CardBuilder.GetSimpleCardResponse(this.Card.Title, this.Card.Text); } } if ((NodeRoutes?.Any()).GetValueOrDefault(false)) { resp.Response.ShouldEndSession = false; } else { // there are no choices available. End the session. resp.Response.ShouldEndSession = true; } return(resp); }
public void SimpleResponse() { string textResp = "You are following a path in forest and have come to a fork. Would you like to go left or right?"; StringBuilder ssmlSample = new StringBuilder(); ssmlSample.Append("<speak><audio src='https://dev-sbsstoryengine.s3.amazonaws.com/stories/animalfarmpi/audio/Act1-OpeningMusic-alexa.mp3'/> "); ssmlSample.Append("It was a dark and stormy night. <break time='500ms'/>"); ssmlSample.Append("<say-as interpret-as='interjection'>no way!</say-as> "); ssmlSample.Append("I'm not doing this. That doesn’t make any sense! That music didn’t sound dark and stormy at "); ssmlSample.Append("<prosody volume='x-loud' pitch='+10%'>all!</prosody>"); ssmlSample.Append(" It sounds to me more like a bright and chipper morning! Should we go with dark and stormy, or bright and chipper?"); ssmlSample.Append("</speak>"); StringBuilder librarySample = new StringBuilder(); librarySample.Append("<speak>"); librarySample.Append(Office.ELEVATOR_BELL_1X_01); librarySample.Append("Your hotel is booked!"); librarySample.Append("</speak>"); AlexaResponse resp = new AlexaResponse { Version = "1.0", Response = new AlexaResponseAttributes { // OutputSpeech = OutputSpeechBuilder.GetPlainTextSpeech(textResp), OutputSpeech = OutputSpeechBuilder.GetSsmlSpeech(ssmlSample.ToString()), Card = CardBuilder.GetStandardCardResponse("Fork in the Road", textResp, "https://dev-custom.s3.amazonaws.com/adventuregame/images/forkintheroad_1200x600.png", "https://dev-custom.s3.amazonaws.com/adventuregame/images/forkintheroad_1200x600.png" ), Reprompt = new RepromptAttributes { OutputSpeech = OutputSpeechBuilder.GetPlainTextSpeech("Left or right?"), }, ShouldEndSession = false }, }; string textSer = JsonConvert.SerializeObject(resp, Formatting.Indented); // The text should serialize to empty brackets. }