کاوش در Dialogflow
برای وارد کردن نمونه «پاسخهای» ما در Dialogflow، روی ادامه کلیک کنید. سپس، مراحل زیر را برای استقرار و آزمایش نمونه دنبال کنید:
- نام عاملی را وارد کنید و عامل Dialogflow جدیدی برای نمونه ایجاد کنید.
- پساز اینکه وارد کردن عامل تمام شد، روی رفتن به عامل کلیک کنید.
- از منو پیمایش اصلی، به انجام سفارش بروید.
- ویرایشگر درونخطی را فعال کنید، سپس روی استقرار کلیک کنید. ویرایشگر حاوی کد نمونه است.
- از منو پیمایش اصلی، به ادغامها بروید، سپس روی دستیار Google کلیک کنید.
- در پنجره مقیدی که ظاهر میشود، پیشنمایش خودکار تغییرات را فعال کنید و روی آزمایش کلیک کنید تا شبیهساز «کنشها» باز شود.
- در شبیهساز،
Talk to my test appرا برای آزمایش نمونه وارد کنید!
پاسخهای ساده بهصورت حبابک گپ نمایش داده میشوند و از نوشتار به گفتار (TTS) یا «زبان نشانهگذاری ترکیب گفتار» (SSML) برای صدا استفاده میکنند.
نوشتار «نوشتار به گفتار» بهطور پیشفرض بهعنوان محتوای حبابک گپ استفاده میشود. اگر جنبه بصری آن نوشتار نیازهایتان را برآورده میکند، لازم نیست هیچ نوشتار نمایشی برای حبابک گپ مشخص کنید.
همچنین میتوانید رهنمودهای طراحی مکالمه ما را مرور کنید تا با نحوه گنجاندن این عناصر دیداری در «کنش» خود آشنا شوید.
مشخصات
پاسخهای ساده الزامات و ویژگیهای اختیاری زیر را دارند که میتوانید پیکربندی کنید:
- در سطوح دارای قابلیتهای
actions.capability.AUDIO_OUTPUTیاactions.capability.SCREEN_OUTPUTپشتیبانی میشود. حد نویسه برای هر حبابک گپ ۶۴۰ است. رشتههای طولانیتر از حد مجاز در اولین شکست کلمه (یا فضای خالی) قبلاز ۶۴۰ نویسه کوتاه میشوند.
محتوای حبابک گپ باید زیرمجموعه آوایی یا ترانویسی کامل خروجی TTS/SSML باشد. این کار به کاربران کمک میکند آنچه را میگویید ترسیم کنند و درک مطلب را در شرایط مختلف افزایش میدهد.
حداکثر دو حبابک گپ در هر نوبت.
سر گپ (نشانواره) که به Google ارسال میکنید باید ۱۹۲×۱۹۲ پیکسل باشد و نمیتواند پویانماییشده باشد.
کدگذاری نمونه
Node.js
app.intent('Simple Response', (conv) => { conv.ask(new SimpleResponse({ speech: `Here's an example of a simple response. ` + `Which type of response would you like to see next?`, text: `Here's a simple response. ` + `Which response would you like to see next?`, })); });
جاوا
@ForIntent("Simple Response") public ActionResponse welcome(ActionRequest request) { ResponseBuilder responseBuilder = getResponseBuilder(request); responseBuilder.add( new SimpleResponse() .setTextToSpeech( "Here's an example of a simple response. " + "Which type of response would you like to see next?") .setDisplayText( "Here's a simple response. Which response would you like to see next?")); return responseBuilder.build(); }
Node.js
conv.ask(new SimpleResponse({ speech: `Here's an example of a simple response. ` + `Which type of response would you like to see next?`, text: `Here's a simple response. ` + `Which response would you like to see next?`, }));
جاوا
ResponseBuilder responseBuilder = getResponseBuilder(request); responseBuilder.add( new SimpleResponse() .setTextToSpeech( "Here's an example of a simple response. " + "Which type of response would you like to see next?") .setDisplayText( "Here's a simple response. Which response would you like to see next?")); return responseBuilder.build();
JSON
توجه داشته باشید که JSON زیر پاسخ وبقلاب را شرح میدهد.
{ "payload": { "google": { "expectUserResponse": true, "richResponse": { "items": [ { "simpleResponse": { "textToSpeech": "Here's an example of a simple response. Which type of response would you like to see next?", "displayText": "Here's a simple response. Which response would you like to see next?" } } ] } } } }
JSON
توجه داشته باشید که JSON زیر پاسخ وبقلاب را شرح میدهد.
{ "expectUserResponse": true, "expectedInputs": [ { "possibleIntents": [ { "intent": "actions.intent.TEXT" } ], "inputPrompt": { "richInitialPrompt": { "items": [ { "simpleResponse": { "textToSpeech": "Here's an example of a simple response. Which type of response would you like to see next?", "displayText": "Here's a simple response. Which response would you like to see next?" } } ] } } } ] }
SSML و صداها
استفاده از SSML و صداها در پاسخهایتان باعث میشود پاسخها صیقلخوردهتر شوند و تجربه کاربری را بهبود میبخشد. تکهکدهای زیر نحوه ایجاد پاسخی را که از SSML استفاده میکند نشان میدهد:
Node.js
app.intent('SSML', (conv) => { conv.ask(`<speak>` + `Here are <say-as interpet-as="characters">SSML</say-as> examples.` + `Here is a buzzing fly ` + `<audio src="https://actions.google.com/sounds/v1/animals/buzzing_fly.ogg"></audio>` + `and here's a short pause <break time="800ms"/>` + `</speak>`); conv.ask('Which response would you like to see next?'); });
جاوا
@ForIntent("SSML") public ActionResponse ssml(ActionRequest request) { ResponseBuilder responseBuilder = getResponseBuilder(request); responseBuilder.add( "<speak>" + "Here are <say-as interpet-as=\"characters\">SSML</say-as> examples." + "Here is a buzzing fly " + "<audio src=\"https://actions.google.com/sounds/v1/animals/buzzing_fly.ogg\"></audio>" + "and here's a short pause <break time=\"800ms\"/>" + "</speak>"); return responseBuilder.build(); }
Node.js
conv.ask(`<speak>` + `Here are <say-as interpet-as="characters">SSML</say-as> examples.` + `Here is a buzzing fly ` + `<audio src="https://actions.google.com/sounds/v1/animals/buzzing_fly.ogg"></audio>` + `and here's a short pause <break time="800ms"/>` + `</speak>`); conv.ask('Which response would you like to see next?');
جاوا
ResponseBuilder responseBuilder = getResponseBuilder(request); responseBuilder.add( "<speak>" + "Here are <say-as interpet-as=\"characters\">SSML</say-as> examples." + "Here is a buzzing fly " + "<audio src=\"https://actions.google.com/sounds/v1/animals/buzzing_fly.ogg\"></audio>" + "and here's a short pause <break time=\"800ms\"/>" + "</speak>"); return responseBuilder.build();
JSON
توجه داشته باشید که JSON زیر پاسخ وبقلاب را شرح میدهد.
{ "payload": { "google": { "expectUserResponse": true, "richResponse": { "items": [ { "simpleResponse": { "textToSpeech": "<speak>Here are <say-as interpet-as=\"characters\">SSML</say-as> examples.Here is a buzzing fly <audio src=\"https://actions.google.com/sounds/v1/animals/buzzing_fly.ogg\"></audio>and here's a short pause <break time=\"800ms\"/></speak>" } }, { "simpleResponse": { "textToSpeech": "Which response would you like to see next?" } } ] } } } }
JSON
توجه داشته باشید که JSON زیر پاسخ وبقلاب را شرح میدهد.
{ "expectUserResponse": true, "expectedInputs": [ { "possibleIntents": [ { "intent": "actions.intent.TEXT" } ], "inputPrompt": { "richInitialPrompt": { "items": [ { "simpleResponse": { "textToSpeech": "<speak>Here are <say-as interpet-as=\"characters\">SSML</say-as> examples.Here is a buzzing fly <audio src=\"https://actions.google.com/sounds/v1/animals/buzzing_fly.ogg\"></audio>and here's a short pause <break time=\"800ms\"/></speak>" } }, { "simpleResponse": { "textToSpeech": "Which response would you like to see next?" } } ] } } } ] }
برای اطلاعات بیشتر، به اسناد مرجع SSML مراجعه کنید.
کتابخانه صدا
ما انواع صداهای کوتاه و رایگان را در کتابخانه صدا خود ارائه میدهیم. این صداها برای شما میزبانی میشوند، بنابراین تنها کاری که باید انجام دهید این است که آنها را در SSML خود بگنجانید.