dialogflow intent detection response slow with curl library

Viewed 278

I have implemented my client code using libcurl for a basic dialogflow scenario. It works as expected but with some delay. I want to know whether any body has got any experience as such w.r.t. performance discussed below and if you can help?

I am showing the curl command output here that has starttransfer_time(2.4 s) and total time(3.5) which are for receiving the first byte from the remote and the total completion time respectively. (I see similar timing with the code using libcurl)

here i am sending the base64 encoded audio captured in a json file as mentioned in the dialogflow docs.

my question is why does google dialogflow API takes almost a second to just send the response with the following text and how to make it better w.r.t time. is there any options that we can set in curl( i have tried setting CURLOPT_BUFFERSIZE to 240k which is more than enough i think) or at dialogflow agent to get the response quickly?

bash-4.2$ curl -X POST -H "Content-Type: application/json; charset=utf-8"  -H "Authorization: Bearer xxx"  -d @req.json "https://dialogflow.googleapis.com/v2beta1/projects/project1/agent/sessions/e9a70529-bee2-bac4-6b08-4b22e221fc59:detectIntent" -w "\n%{time_connect}:%{time_starttransfer}:%{time_total}\n"
{
  "responseId": "9ead1d09-3276-4238-a42b-b9f12e6faa34-d5ae01f3",
  "queryResult": {
    "queryText": "hello",
    "speechRecognitionConfidence": 0.7617957,
    "action": "input.unknown",
    "parameters": {},
    "allRequiredParamsPresent": true,
    "fulfillmentText": "Can you say that again?",
    "fulfillmentMessages": [
      {
        "text": {
          "text": [
            "Can you say that again?"
          ]
        }
      }
    ],
    "intent": {
      "name": "projects/project1/agent/intents/d30bb8cc-0dd4-4d60-9511-d3ce387f2c22",
      "displayName": "Default Fallback Intent",
      "isFallback": true
    },
    "intentDetectionConfidence": 1,
    "languageCode": "en"
  }
}
0.101:2.488:3.351
0 Answers
Related