Bing语音识别API返回408“请求超时(> 14000 ms)”

时间:2017-06-26 10:48:46

标签: microsoft-cognitive

我正在尝试在我正在处理的项目中使用Bing语音识别API。

我已创建a small file来测试API:

$ file test5.wav
test5.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 16000 Hz
$ ls -lah test5.wav
-rw-r--r-- 1 bauer 1049089 288K Jun 26 12:38 test5.wav

要排除我的应用程序中的任何错误,我使用Get Started with Speech REST API in cURL article中的cURL命令:

curl -v -X POST "https://speech.platform.bing.com/speech/recognition/interactive/cognitiveservices/v1?language=de-DE" -H "Authorization: $ACCESS_TOKEN" -H 'Content-type: audio/wav; codec="audio/pcm"; samplerate=16000' --data-binary @test5.wav

这是我得到的回复:

Note: Unnecessary use of -X or --request, POST is already inferred.
* timeout on name lookup is not supported
*   Trying 204.79.197.200...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to speech.platform.bing.com (204.79.197.200) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: C:/Users/bauer/AppData/Local/Programs/Git/mingw64/ssl/certs/ca-bundle.crt
  CApath: none
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
} [5 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [81 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [4514 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [365 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [102 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
{ [1 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*        subject: CN=www.bing.com
*        start date: Nov  4 17:10:22 2016 GMT
*        expire date: May  4 17:10:22 2018 GMT
*        subjectAltName: speech.platform.bing.com matched
*        issuer: C=US; ST=Washington; L=Redmond; O=Microsoft Corporation; OU=Microsoft IT; CN=Microsoft IT SSL SHA2
*        SSL certificate verify ok.
} [5 bytes data]
> POST /speech/recognition/interactive/cognitiveservices/v1?language=de-DE HTTP/1.1
> Host: speech.platform.bing.com
> User-Agent: curl/7.47.1
> Accept: */*
> Authorization: ***
> Content-type: audio/wav; codec="audio/pcm"; samplerate=44100
> Content-Length: 294666
> Expect: 100-continue
>
{ [5 bytes data]
< HTTP/1.1 100 Continue
} [5 bytes data]
* We are completely uploaded and fine
100  287k    0     0  100  287k      0  20521  0:00:14  0:00:14 --:--:--     0{ [5 bytes data]
< HTTP/1.1 408 Request timed out (> 14000 ms)
< Transfer-Encoding: chunked
< Content-Type: text/plain
< Server: Microsoft-IIS/10.0
< X-MSEdge-Ref: Ref A: B46AA40C68BF4806B277B7D97D5CC386 Ref B: BER30EDGE0215 Ref C: Mon Jun 26 03:39:09 2017 PST
< Date: Mon, 26 Jun 2017 10:39:08 GMT
<
{ [36 bytes data]
100  287k    0    30  100  287k      2  20454  0:00:14  0:00:14 --:--:--     0Request timed out (> 14000 ms)
* Connection #0 to host speech.platform.bing.com left intact

为什么API调用失败?测试文件有问题吗?我错过了必要的参数吗?

1 个答案:

答案 0 :(得分:1)

尝试通过添加--header "Transfer-Encoding: chunked"来强制进行分块传输。因此,完整的命令将是:

curl -v -X POST "https://speech.platform.bing.com/speech/recognition/interactive/cognitiveservices/v1?language=de-DE" -H "Authorization: $ACCESS_TOKEN"  -H 'Transfer-Encoding: chunked' -H 'Content-type: audio/wav; codec="audio/pcm"; samplerate=16000' --data-binary @test5.wav