Parse speech output to a JSON to call Application API

半世苍凉 提交于 2019-12-02 02:08:55

问题


Here is an idea:

We have web applications with exposed restful APIs which accepts json. Now how about using google speech APIs to take user voice input convert it to text then somehow translate that text to JSONs required by APIs and then call those application APIe with JSON? Is there any. Library to translate text to a specified JSon format? Has anybody used this approach?


回答1:


This is called "intent analysis". There are such libraries, for example RASA

For example you input is "show me chinese restaurants". The output would be

{
  "text": "show me chinese restaurants",
  "intent": "restaurant_search",
  "entities": [
    {
      "start": 8,
      "end": 15,
      "value": "chinese",
      "entity": "cuisine"
    }
  ]
}

Overall it is pretty advanced NLU.




回答2:


According to the Google Speech API the result set is already returned in JSON:

{
  "results": [
    {
      "alternatives": [
        {
          "transcript": "how old is the Brooklyn Bridge",
          "confidence": 0.98267895
        }
      ]
    }
  ]
}

All you would have to do is use JSON.parse and then select whatever you wanted out of the object to put into your specific json format.

I would suggest reading through the Google Speech Documentation



来源:https://stackoverflow.com/questions/44253194/parse-speech-output-to-a-json-to-call-application-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!