天天看點

一次神奇的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