简体   繁体   English

DialogFlow更改识别语言

[英]DialogFlow change recognition language

I'm building a multi-language-educational app on DialogFlow. 我正在使用DialogFlow构建一个多语言教育应用程序。 and i hit a big problem : Switch recognition language. 我遇到了一个大问题:切换识别语言。 Any suggestions how could i achieve that or any other approaches? 任何建议我怎么能实现这个或任何其他方法?

I have added to DialogFlow web-interface secondary language. 我已经添加到DialogFlow Web界面的第二语言。

I'm using action-on-google sdk with node.js webhook. 我正在使用node.js webhook上的action-on-google sdk。

UPDATE : 更新

 let responseToUser = {
    //fulfillmentMessages: richResponsesV2, // Optional, uncomment to enable
    //outputContexts: [{ 'name': `${session}/contexts/weather`, 'lifespanCount': 2, 'parameters': {'city': 'Rome'} }], // Optional, uncomment to enable
    fulfillmentText: 'This is from Dialogflow\'s Cloud Functions for Firebase editor! :-)', // displayed response
    payload: {
       audioConfig : {
        "audioEncoding": 'AUDIO_ENCODING_FLAC',
        "sampleRateHertz": 16000,
        "languageCode": 'de',
        "phraseHints": ["gutten tag"]
       }
    },
      function sendResponse (responseToUser) {
// if the response is a string send it as a response to the user
if (typeof responseToUser === 'string') {
  let responseJson = {fulfillmentText: responseToUser}; // displayed response
  response.json(responseJson); // Send response to Dialogflow
} else {
  // If the response to the user includes rich responses or contexts send them to Dialogflow
  let responseJson = {};
  // Define the text response
  responseJson.fulfillmentText = responseToUser.fulfillmentText;
  responseJson.payload = responseToUser.payload;

     // Send the response to Dialogflow
  console.log('Response to Dialogflow: ' + JSON.stringify(responseJson));
  response.json(responseJson);

The request json : 请求json:

{
  "responseId": "c4ea35d3-1455-4142-b7d2-22417c5880ae",
  "queryResult": {
"queryText": "hi",
"action": "default",
"parameters": {},
"allRequiredParamsPresent": true,
"fulfillmentText": "This is from Dialogflow's Cloud Functions for Firebase editor! :-)",
"fulfillmentMessages": [
  {
    "text": {
      "text": [
        "This is from Dialogflow's Cloud Functions for Firebase editor! :-)"
      ]
    }
  }
],
"webhookPayload": {
  "sampleRateHertz": 16000,
  "languageCode": "de",
  "phraseHints": [
    "gutten tag"
  ],
  "audioEncoding": "AUDIO_ENCODING_FLAC"
},
"outputContexts": [
  {
    "name": "projects/homehf-master/agent/sessions/824b34b9-45f8-4c65-9377-a31242d3414b/contexts/test_context",
    "lifespanCount": 5
  }
],
"intent": {
  "name": "projects/homehf-master/agent/intents/0259f134-6d4d-4aed-920d-9240adbe38fe",
  "displayName": "starter_intent"
},
"intentDetectionConfidence": 0.75,
"diagnosticInfo": {
  "webhook_latency_ms": 44
},
"languageCode": "en"
 },
    "webhookStatus": {
     "message": "Webhook execution successful"
  }
 }

Dialogflow requires a language with the audio request , if you'd like to change that language you'll need to issue a new request. Dialogflow需要一种带有音频请求的语言,如果您想更改该语言,则需要发出新请求。 You can implement some logic in your webhook and frontend to try the request again with a different language. 您可以在webhook和frontend中实现一些逻辑,以使用不同的语言再次尝试请求。

To do this add some data in the payload field of your webhook response response indicating that you'd like to issues a new request with the a different language specified. 为此,请在webhook响应响应的有效内容字段中添加一些数据,表明您希望使用指定的其他语言发出新请求。 In your client, check the data in the response payload and if the data indicates retrying with another language, send another request with a different language specified in the input audio config with the same audio. 在您的客户端中,检查响应有效负载中的数据,如果数据指示使用其他语言重试,则使用相同的音频发送另一个在输入音频配置中指定的其他语言的请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Dialogflow-如何在数字识别中处理空格 - Dialogflow - How to handle blanks in number recognition 如何制作多语言Dialogflow Webhook /实现? - How to make a multiple language Dialogflow webhook/fulfillment? 如何在 Dialogflow 中为多语言代理实现语言切换? - How to implement a language switch for a multilingual agent in Dialogflow? 将语音更改为女声 Twilio Dialogflow - Change voice to female voice Twilio Dialogflow 语言检测和使用 Node.js 中的车把更改电子邮件内容的语言 - Language detection and change language of Email content with handlebar in Node.js 后端内部化更改语言会话 vs 系统 - backend internalization change language session vs system 在 generateEmailVerificationLink() FirebaseAdmin SDK 上更改 URL 的语言 - Change language of URL on generateEmailVerificationLink() FirebaseAdmin SDK 无法更改Firefox的Selenium-Webdriver语言 - Cannot change language of selenium-webdriver for firefox 在URL javascript / nodejs中更改语言代码 - Change language code within URL javascript/nodejs 如何更改谷歌 lightouse 报告的语言 - How to change language of google lightouse report
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM