private string GetSsmlResponse(Platform targetPlatform) { return($@"<speak>{ string.Concat(OutputObjects .Where(output => output.TargetPlatform == Platform.All || output.TargetPlatform == targetPlatform) .Select(output => output.Type switch { OutputType.Text => output.Value, OutputType.Url => $"<audio src=\"{output.Value}\" />", OutputType.Break => $"<break time=\"{output.BreakTime}s\" />", _ => string.Empty }))
public CEKResponse ToClovaResponse() { var response = new CEKResponse(); // normal foreach (var output in OutputObjects .Where(output => output.TargetPlatform == Platform.All || output.TargetPlatform == Platform.Clova)) { if (output.Type == OutputType.Text) { response.AddText(output.Value); } else if (output.Type == OutputType.Url) { response.AddUrl(output.Value); } else if (output.Type == OutputType.Break) { if (output.BreakTime <= 5) { response.AddUrl($"https://himanago.github.io/silent-mp3/silent_{output.BreakTime}s.mp3"); } else { response.AddUrl($"https://himanago.github.io/silent-mp3/silent_5s.mp3"); response.AddUrl($"https://himanago.github.io/silent-mp3/silent_{output.BreakTime - 5}s.mp3"); } } } // AudioPlayer foreach (var audio in AudioItemObjects .Where(audio => audio.TargetPlatform == Platform.All || audio.TargetPlatform == Platform.Clova)) { response.Response.Directives.Add(new Directive() { Header = new DirectiveHeader() { Namespace = DirectiveHeaderNamespace.AudioPlayer, Name = DirectiveHeaderName.Play }, Payload = new AudioPlayPayload { AudioItem = new LineDC.CEK.Models.AudioItem { AudioItemId = audio.AudioItemId, HeaderText = audio.Title, TitleText = audio.Title, TitleSubText1 = audio.SubTitle, ArtImageUrl = audio.ImageUrl, Stream = new AudioStreamInfoObject { BeginAtInMilliseconds = 0, Url = audio.Url, UrlPlayable = true } }, PlayBehavior = audio.AudioPlayBehavior == AudioPlayBehavior.Enqueue ? LineDC.CEK.Models.AudioPlayBehavior.ENQUEUE : LineDC.CEK.Models.AudioPlayBehavior.REPLACE_ALL, Source = new Source { Name = audio.Title } } }); } if (!ShouldEndSession) { response.KeepListening(); } return(response); }