简单响应在视觉上以聊天气泡的形式呈现,并使用文字转语音 (TTS) 或语音合成标记语言 (SSML) 发出声音。通过在对话中使用简短的简短回复,您可以为用户提供清晰明了的视觉和音频界面,并与其他对话元素搭配使用。
简单响应中的聊天气泡内容必须是 TTS/SSML 输出的语音子集或完整转录。这有助于用户描绘出您的 Action 所说的内容,并在各种条件下加深理解。
在提示中,您在 first_simple
和 last_simple
对象中提供的文本使用的是简单响应的属性。Google 助理会在提示中发送所有简单响应,然后在提示队列中发送最终的富响应。
属性
简单响应类型具有以下属性:
媒体资源 | 类型 | 要求 | 说明 |
---|---|---|---|
speech |
string | 可选 | 表示要以 SSML 或文字转语音的形式向用户说出的字词。
如果包含提示中的 override 字段为“true”,则此字段中定义的语音将替换上一个简单提示的语音。 |
text |
string | 可选 |
要在聊天气泡中显示的文本。长度超过 640 个字符的字符串在第一个单词换行处(或空格)处在 640 个字符之前,将被截断。我们建议长度不超过 300 个字符,以防止内容延伸到屏幕之外,尤其是在与卡片或其他视觉元素搭配使用时。 如果未提供,Google 助理会改为呈现 |
示例代码
YAML
candidates: - first_simple: variants: - speech: This is the first simple response. text: This is the 1st simple response. last_simple: variants: - speech: This is the last simple response. text: This is the last simple response.
JSON
{ "candidates": [ { "first_simple": { "variants": [ { "speech": "This is the first simple response.", "text": "This is the 1st simple response." } ] }, "last_simple": { "variants": [ { "speech": "This is the last simple response.", "text": "This is the last simple response." } ] } } ] }
Node.js
app.handle('Simple', conv => { conv.add(new Simple({ speech: 'This is the first simple response.', text: 'This is the 1st simple response.' })); conv.add(new Simple({ speech: 'This is the last simple response.', text: 'This is the last simple response.' })); });
JSON
{ "responseJson": { "session": { "id": "session_id", "params": {} }, "prompt": { "override": false, "firstSimple": { "speech": "This is the first simple response.", "text": "This is the 1st simple response." }, "lastSimple": { "speech": "This is the last simple response.", "text": "This is the last simple response." } } } }
SSML 和声音
在响应中使用 SSML 和声音,使响应更加完善并改善用户体验。如需了解详情,请参阅 SSML 文档。
音效库
我们的音效库中提供了各种免费的简短音效。这些声音是为您托管的,因此您只需将它们包含在 SSML 中即可。