折腾:
【已解决】Flask中ms的tts返回401感觉是获取token错误导致无法生成语音文件
期间,以为是其他原因,比如线上部署是多线程,每个都会去获取和更新ms的tts的token,导致互相冲突或覆盖,使得token无效呢。
结果后来发现是:
调用api接口:
<code>MS_GET_TOKEN_URL = "https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken" </code>
返回错误:
<code>{ "statusCode": 403, "message": "Out of call volume quota. Quota will be replenished in 4.04:43:06." } </code>
所以要求搞清楚,为何会出错。
毕竟之前都是正常调用的。
先去登陆微软Azure中看看情况:
微软Azure
先进去:
再点击 门户,进入:
进入仪表盘主页:
仪表板 – Microsoft Azure
https://portal.azure.com/#@xxx/dashboard/private/xxx
Azure-Speech – Microsoft Azure
点击 即用即付
即用即付 – Microsoft Azure
搜:
azure Out of call volume quota. Quota will be replenished in
microsoft cognitive – Out of Call Volume Quota – Stack Overflow
也没看到有什么quota方面的信息:
No Quota Info
是用的F0的Free的quota:
就是:
免费试用语音服务 – Microsoft Cognitive Services | Microsoft Docs
提到的:
“F0(有限的免费订阅)”
对应的:
如之前就知道的:
我此处调用到的服务
Text-to-speech
5M characters per month
每月有5百万的字符串转语音
我这里肯定没有超出配额才对
Cognitive Search requests with API keys generated in Azure console return 401s
Msdn forums – Cognitive Services
azure – Luis Out of call volume quota – Stack Overflow
azure – Bing Error – Out of call volume quota – Stack Overflow
microsoft cognitive – “Bing Error – Out of call volume quota” on first use – Stack Overflow
how to increase “call volume quota” for azure apim? – Stack Overflow
Solved: How can I fix the “message”: “Out of call volume q… – Power Users Community
定价概述 – Azure 如何定价 | Microsoft Azure
定价 – 必应搜索 API | Microsoft Azure
不过,感觉好像有点不对:
因为如果配额超过了,那应该所有的api调用都不正常才对
->而之前测试时,是可以正常生产语音的
-》难道是:此处刷新token时,返回超额了?或许是因为刷新token的次数有限制?而不是文字转语音的超额了?
还是去本地调试ms的tts,看看是否正常调用
结果本地调试就出错了:
<code><Response [403]> text='{ "statusCode": 403, "message": "Out of call volume quota. Quota will be replenished in 4.00:37:33." }' reason='Quota Exceeded' </code>
去换个新的Key 2试试:
<code>79xxxxx6f </code>
结果问题依旧是403和:
‘{ “statusCode”: 403, “message”: “Out of call volume quota. Quota will be replenished in 4.00:29:13.” }’
azure cognitive Out of call volume quota. Quota will be replenished in
Out of call volume quota. · Issue #249 · Microsoft/botbuilder-js
Cognitive Services APIs Reference
“Response 403
application/json
语音服务文档 – 教程、快速入门和 API 参考 – 认知服务 | Microsoft Docs
【已解决】Safari中无法进入微软Azure的门户控制台页面
免费试用语音服务 – Microsoft Cognitive Services | Microsoft Docs
-》
-》
https://account.microsoft.com/?refp=signedout-index
https://account.microsoft.com/services/
https://azure.microsoft.com/zh-cn/services/cognitive-services/
https://azure.microsoft.com/zh-cn/services/cognitive-services/directory/speech/
同样出错。
https://portal.azure.com/Error/ClientTimeout/?src=portalBootParameters%20is%20undefined&shown=true
<Microsoft> developer portal
“Response 429
application/json
{ “statusCode”: 429, “message”: “Rate limit is exceeded. Try again in 26 seconds.” }”
至此:
(1)目前理解了部分的逻辑:
微软Azure的接口,出错时候的statusCode和message
当出错时,比如401,403,都是通用的:
比如:
Web Language Model API – Break Into Words
<code>Response 400 Indicates JSON parsing error, faceRectangles cannot be parsed correctly, or count exceeds 64, or content-type is not recognized. Response 401 application/json { "statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure you are subscribed to an API you are trying to call and provide the right key." } Response 403 application/json { "statusCode": 403, "message": "Out of call volume quota. Quota will be replenished in 2.12 days." } Response 429 application/json { "statusCode": 429, "message": "Rate limit is exceeded. Try again in 26 seconds." } </code>
其中:
我此处的是返回403,是超配额了
而429是超过频率限制-》我之前担心是不是此处调用API频率太高,则确定不是,否则就返回429了。
(2)微软Azure中,想要进入相关的服务,比如Cognitive Service等,而跳转到:
都会出错:
【已解决】Safari中无法进入微软Azure的门户控制台页面
(3)而之前正常进入的:
的:
确认了自己使用的服务是:
免费试用语音服务 – Microsoft Cognitive Services | Microsoft Docs
提到的:
“F0(有限的免费订阅)”
对应的细节是:
<code> F0 Free Speech Translation 10 hours per month Speech-to-text 2 hours per month Custom Speech-to-text 2 hours per month Custom Speech model deployment 1 model Text-to-speech 5M characters per month Custom Text-to-speech 5M characters per month Custom Voice Model 1 model </code>
其中:
我此处调用到的服务
Text-to-speech
5M characters per month
每月有5百万的字符串转语音
我这里肯定没有超出配额才对
此处继续研究:
看来只有再去找找为何:
https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken
即:cognitive的issueToken,为何会返回403错误
azure cognitive issueToken Out of call volume quota
找到了Cognitive Services的社区:
Msdn forums – Cognitive Services
结果去搜:
403 Out of call volume quota
竟然还页面挂了:
502 – Web server received an invalid response while acting as a gateway or proxy server.
https://social.msdn.microsoft.com/Forums/en-US/home?searchTerm=403+Out+of+call+volume+quota
微软这系统,这服务,做的也够烂的。
-》
-》
Support for Cognitive Services has moved to a new location. See Details here.
Frequent ‘microsoft-cognitive’ Questions – Stack Overflow
搜:
403 Out of call volume quota
只有一个人问这个问题(带这个tag的)
microsoft cognitive – Out of Call Volume Quota – Stack Overflow
有人是解决了:
说是免费,其实有限制,后来转成付费paid subscription就可以了。
-》但是我此处已经是服务的订阅了,都绑定支付的信用卡了(不过也的确是用的是F0的免费的)
不是S0的付费的
https://stackoverflow.com/questions/43979134/bing-error-out-of-call-volume-quota
-》
使用 Azure API 管理转换和保护 API | Microsoft Docs
“I had to update to the pay subscription plan. Then, it worked. MS gave me a $250 credit for the first month.”
也是换成收费模式就可以了。
至此,感觉最大可能:
网上其实有很多人,都在这里:
和我此处类似,用的是微软的Azure的Cognitive Service认知服务,但是用的是免费的版本:
即使我此处是注册了账号,绑定了信用卡,但是选择的是F0的免费套餐
->虽然F0的套餐中,免费的服务量的限制很低,可以使用很多,比如:
每月有5M=5百万的字符,可以文字转语音
-》但是其实内部好像是有限制使用量的
-》猜测是微软的内部为了赚钱而搞的鬼:告诉你免费,但是你使用量没超过免费额度,却提示你超额了
-》这样就能鼓励你花钱去买收费的服务了
-》目前感觉:
只有花钱,从F0免费套餐换成S0的收费套餐,估计就可以解决问题了。
再去定价的地方看看:
定价概述 – Azure 如何定价 | Microsoft Azure
https://azure.microsoft.com/zh-cn/pricing/#product-picker
我此处只用到了:
文本到语音转换
F0免费套餐是:500 万字符/月
我确定是没有超过额度限制
看了看,既然收费服务是:
S0收费:$2/一百万个字符 -> 1百万个字符,也只要2美元=16元左右,还是能接受的。那就去升级为收费的吧。
毕竟人家微软Azure也不容易。
去从F0换S0:
点击:Pricing tier
Choose your pricing tier – Microsoft Azure
“S0 Standard
Speech Translation
$1.25 per hour
Speech-to-text
$0.50 per hour
Custom Speech-to-text
$0.70 per hour
Custom Speech model deployment
$20 per model per month
Text-to-speech
$2.00 per 1M chars
Custom Text-to-speech
$3.00 per 1M char
Custom Voice Model
$20 per model per month
0.50
STARTING USD PER HOUR (ESTIMATED)”
其中主要就只是用:
Text-to-speech $2.00 per 1M chars
而平时只是测试测试,以及少量的使用,也就几百几千的字符,远不到百万字符量级,所以费用也不会很多的,估计少的话,只有0.1美元左右
<code>Pricing tier:Standard </code>
不知道是否有延迟。
不过先去本地调试看看,是否立刻生效了:
还真的是离开就生效了:
【总结】
此处,微软的做法,还是很垃圾,很变态的:
1.微软的Azure的,是有两种套餐的,免费的F0和收费的S0
其中F0的额度还是很宽裕的,比如文字换语言是500 万字符/月
2.此处遇到问题是:
在调用接口:
https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken
之前近2个月左右,都是没问题的,现在出问题了,返回:
<code>{ "statusCode": 403, "message": "Out of call volume quota. Quota will be replenished in 4.04:43:06." } </code>
对于此错误,意思很清楚了:就是超过配额,超过限制了。
3.而实际上:此处的文字转语音的使用量很小,估计连500字符/月都不到,根本不可能超过配额,超过500万字符/月,但是系统真的是提醒你超过额度了
4.经过网上一番查证,尤其是:
基本上确定是:
虽然你的使用量是没有超过免费套餐的限制
但是系统(在没有任何其他提示的情况下)就说你超过额度了
而解决办法只有:你把套餐(从免费的F0)换成收费的(S0套餐)
5.其背后的做法和逻辑就清晰了:
微软Azure,打着鼓励你用免费F0套餐,且免费的额度很多很多,但是实际上你使用了一点点后,就不给你继续使用,就告诉你超额了。然后你只能升级换成收费的套餐,才能正常继续使用。
但是问题来了:
如果不是网上能找到讨论这个问题的帖子,
可能你永远也不知道此处虽然没超额,但是为何系统返回超额
Azure真的想要挣钱,鼓励,变相刺激你,从免费套餐换收费套餐
那也可以用正常的思路和逻辑,比如把免费的额度调整的很低等等,
也不至于用这么变态,这么流氓的做法吧!!真是无语了。
转载请注明:在路上 » 【已解决】调用微软Azure的cognitive的sts/tts的api生成token时出错:Out of call volume quota. Quota will be replenished in