簡易回應會以視覺化的方式呈現聊天泡泡,並使用文字轉語音 (TTS) 或語音合成標記語言 (SSML) 來提供聲音。在對話中使用簡短的簡單回應,可以提供清楚的視覺介面和語音介面,方便使用者搭配其他對話元素使用,持續吸引使用者。
簡單回應中的即時通訊泡泡內容必須是語音的子集,或是 TTS/SSML 輸出內容的完整轉錄稿。這有助於使用者釐清動作的內容,並增加不同條件的理解。
在提示中,您在 first_simple
和 last_simple
物件中提供的文字會使用簡單的回應屬性。Google 助理會在提示中傳送所有簡單的回應,然後在提示佇列中傳送最終複合式回應。
屬性
簡單回應類型具有以下屬性:
屬性 | 類型 | 必要性 | 說明 |
---|---|---|---|
speech |
字串 | 選用 | 代表要在 SSML 或文字轉語音中向使用者顯示的字詞。如果內含提示中的 override 欄位為「true」,則這個欄位中定義的語音會取代之前的簡單提示語音。 |
text |
字串 | 選用 |
要在即時通訊泡泡中顯示的文字。超過 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 中加入這些音效即可。