一次神奇的Azure speech to text rest api之旅

错误Max retries exceeded with url:

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='%20eastasia.stt.speech.microsoft.com', port=443): Max retries exceeded with url: /speech/recognition/conversation/cognitiveservices/v1?language=zh-CN (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000000041DE808>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',))
https:// eastasia.stt.speech.microsoft.com/
这里应该是
https://eastasia.stt.speech.microsoft.com/

错误401

"'"Ocp-Apim-Subscription-Key": access_token,
这里应该是
"Authorization" : "Bearer "+access_token,
"Authorization" : access_token,

错误400上传类型

respond.text会说格式错误
wav是不是非wav格式,虽然能播放

错误400未设置语言

"Invalid CID or language"
语言参数必须附加到 URL 以避免收到 4xx HTTP 错误。 例如,使用美国西部端点设置为美国英语的语言是:https://westus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US
出自微软官方文档https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-speech-to-text

错误400玄幻

"Client disconnected with IOException"
你需要先用language=en-US识别一次。
就像通一下马桶一样,也许更新某次堵住了吧。
之后里面就是正常的200,0和400了。

使用体验

微软经常升级,微软全球和微软中国Azure还是分开的,一不小心中国区就被踢下车。总是出现这种玄幻事情。
自带滤噪,使用体验吊打百度,而且不像科大讯飞30天使用。

参考文献

https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/troubleshooting
这里还有一个倒霉蛋差不多,没有原因
https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/680

原文地址:https://www.cnblogs.com/fengmao31/p/15436992.html