google actions sdk:如何在显示基本卡片响应时包含音频
google actions sdk: how to include an audio when displaying a basic card response
当使用 actions sdk 响应用户查询时,我可以使用以下方法创建基本卡片:
conv.ask(new BasicCard({
text: 'Text with card display',
title: 'Title:',
display: 'CROPPED',
}));
但是,如果我想为用户提供一些音频(不同于显示文本),我该怎么做?
我尝试添加 conv.ask('<speak>' + 'Hello' + '</speak>');
但它抛出错误
MalformedResponse
expected_inputs[0].input_prompt.rich_initial_prompt.items[0].simple_response: 'display_text' must be set or 'ssml' must have a valid display rendering.
在 google 动作项目中包含音频的最佳方式是什么?谢谢
如果你想在后台播放音频,我建议使用SSML, but if your actual goal is to just deliver the audio to the user (like if it's a podcast or something) you can use a Media Response。
但是,如果您希望带屏幕的设备上显示的文本与所说的文本不同,您可以添加 Simple Response(可以选择添加不同的文本和语音)。
基本卡没有附加音频。顾名思义,它是一种视觉提示,而不是听觉提示。它旨在补充说出和显示的文本 - 而不是取代它。
虽然您可以创建一个 SimpleResponse,它具有不同的语音文本和显示文本,但您应该确保两种响应基本相同。您可以将 SimpleResponse 与这样的东西一起使用:
conv.ask(new SimpleResponse({
speech: '<speak>Here are the results, showing our sunny recreational facilities. <audio src="https://actions.google.com/sounds/v1/animals/cicada_chirp.ogg">And the sounds of nature.</audio></speak>',
text: 'Here is the result',
}));
当使用 actions sdk 响应用户查询时,我可以使用以下方法创建基本卡片:
conv.ask(new BasicCard({
text: 'Text with card display',
title: 'Title:',
display: 'CROPPED',
}));
但是,如果我想为用户提供一些音频(不同于显示文本),我该怎么做?
我尝试添加 conv.ask('<speak>' + 'Hello' + '</speak>');
但它抛出错误
MalformedResponse
expected_inputs[0].input_prompt.rich_initial_prompt.items[0].simple_response: 'display_text' must be set or 'ssml' must have a valid display rendering.
在 google 动作项目中包含音频的最佳方式是什么?谢谢
如果你想在后台播放音频,我建议使用SSML, but if your actual goal is to just deliver the audio to the user (like if it's a podcast or something) you can use a Media Response。
但是,如果您希望带屏幕的设备上显示的文本与所说的文本不同,您可以添加 Simple Response(可以选择添加不同的文本和语音)。
基本卡没有附加音频。顾名思义,它是一种视觉提示,而不是听觉提示。它旨在补充说出和显示的文本 - 而不是取代它。
虽然您可以创建一个 SimpleResponse,它具有不同的语音文本和显示文本,但您应该确保两种响应基本相同。您可以将 SimpleResponse 与这样的东西一起使用:
conv.ask(new SimpleResponse({
speech: '<speak>Here are the results, showing our sunny recreational facilities. <audio src="https://actions.google.com/sounds/v1/animals/cicada_chirp.ogg">And the sounds of nature.</audio></speak>',
text: 'Here is the result',
}));