[英]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.