语音识别(IBM)用户名和密码



我希望使用没有- curlibm_watson模块的IBM语音识别服务
我的尝试如下:

import speech_recognition as sr
r = sr.Recognizer()
text = r.recognize_ibm(audio,username='',password='')

尽管我有IBM云语音到文本的"服务凭据",但我找不到该函数的正确形式
recognize_ibm()的文档中,据说我需要输入link_1才能找到XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX格式的username
但链接1已断开。在哪里可以找到usernamepassword

我还尝试了text = r.recognize_ibm(audio,username='apikey',password=api_key)作为之前的答案link_2。

事实上,我意识到模块不起作用。

以下是语音到文本的官方API文档:https://cloud.ibm.com/apidocs/speech-to-text

它包括各种样本和进一步的链接。您可以使用IAMAuthenticator将API密钥转换为身份验证令牌,并处理刷新令牌。如果您不想使用SDK,您必须自己处理IBM Cloud IAM Identity Service API。API具有获取身份验证/访问令牌的功能。

我经常使用这样的函数将API密钥转换为访问令牌:

def getAuthTokens(api_key):
url     = "https://iam.cloud.ibm.com/identity/token"
headers = { "Content-Type" : "application/x-www-form-urlencoded" }
data    = "apikey=" + api_key + "&grant_type=urn:ibm:params:oauth:grant-type:apikey"
response  = requests.post( url, headers=headers, data=data )
return response.json()

你可以

最新更新