简体   繁体   English

带有音频的 Dialogflow V2 HTTP API detectIntent 返回无效响应(不完整的正文)

[英]Dialogflow V2 HTTP API detectIntent with audio returns invalid response (incomplete body)

I faced with next issue: some of Dialogflow V2 HTTP API requests response with incomplete body.我面临下一个问题:一些 Dialogflow V2 HTTP API 请求响应体不完整。 No regularity found, it can happen during random requests with different intent & session info.没有发现规律,它可能发生在具有不同意图和会话信息的随机请求期间。

Example:例子:

POST https://dialogflow.googleapis.com/v2/projects/{project-name}/agent/sessions/{session-uuid}:detectIntent

> Content-Type: application/json
> Authorization: Bearer {token}

REQUEST BODY:
{
    "queryInput": {
        "audioConfig": {
            "audioEncoding": "AUDIO_ENCODING_OGG_OPUS",
            "sampleRateHertz": 48000,
            "languageCode": "en-US",
            "model": "command_and_search"
        }
    },
    "inputAudio": "{base64-encoded-file}"
}

RESPONSE:
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=UTF-8

RESPONSE BODY:
{
  "queryResult": {
    "languageCode": "en-US"
  }
}

... and that's all. ... 就这样。 API returns body with languageCode field only in queryResult . API 仅在queryResult返回带有languageCode字段的正文。 All are missing except this one.除了这个,其他都不见了。

Issue happen only during requests with audio, all works fine for text input.问题仅在有音频的请求期间发生,对于文本输入一切正常。

Any help/tips how to avoid this issue?任何帮助/提示如何避免这个问题? I would be grateful for any help.我将不胜感激任何帮助。

I have checked out the documentation [1] and it seems to me you are using a sampling interval different than the sampling interval of the default format.我已经查看了文档 [1],在我看来,您使用的采样间隔与默认格式的采样间隔不同。

Particularly, as you can see "Opus encoded audio frames in Ogg container (OggOpus). sampleRateHertz must be 16000."特别是,如您所见“Ogg 容器 (OggOpus) 中的 Opus 编码音频帧。sampleRateHertz 必须为 16000。”

Meanwhile you specified "sampleRateHertz": 48000.同时,您指定了“sampleRateHertz”:48000。

This may be the reason of your unexpected results.这可能是您出现意外结果的原因。 If the sampling rate are different, then you may have a wrong identification of the signal.如果采样率不同,那么您可能会错误地识别信号。 I would suggest you to resample the audio in input to 16000 Hz or to change the encoding format, and perhaps opting for FLAC (Free Lossless Audio Codec) because is the recommended encoding because it is lossless (therefore recognition is not compromised)我建议您将输入中的音频重新采样为 16000 Hz 或更改编码格式,也许选择 FLAC(免费无损音频编解码器),因为这是推荐的编码,因为它是无损的(因此识别不会受到影响)

[1] https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/QueryInput#audioencoding [1] https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/QueryInput#audioencoding

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

相关问题 您无权执行此操作。 无效的访问令牌DialogFlow v2 - You are not authorized for this operation. Invalid access token DialogFlow v2 Dialogflow v2 - 无需任何库即可发出 REST API 请求 - Dialogflow v2 - Make REST API request without any library 使用 Dialogflow 和 C# 的音频响应 - Audio Response with Dialogflow and C# 如何使用简单的 ajax jQuery 对 DialogFlow V2 进行 http 调用? - How can I make http call to DialogFlow V2 using simple ajax jQuery? 生成令牌以调用 Dialogflow V2 - Generate Token to call Dialogflow V2 谷歌DialogFlow V2实现中的神秘错误(谷歌助手模拟器空响应,请求,错误选项卡) - Google DialogFlow V2 mysterious error in fulfillment (Google Assistant simulator empty response, request, error tab) 如何使用 Javascript ajax 调用在 DialogFlow v2 上进行 http 调用 - How to make http call on DialogFlow v2 using Javascript ajax call 尝试使用Dialogflow V2 API中的自定义事件更新intent参数,并且不传递给intent - Trying to update intent parameter using custom events in Dialogflow V2 API and its not passing through to the intent DialogFlow v2访问令牌无法生成 - DialogFlow v2 Access Token cannot generate 我可以在 Dialogflow V2 API 上发布代理版本和管理环境吗? - Can I publish an agent version and manage environments on Dialogflow V2 API?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM