概述允许将IBM与一起使用。我一直收到403个错误(禁止),无论我使用哪个URL,我都尝试了以下URL:
但它们都不管用。
代码样本
import json
from os.path import join, dirname
from ibm_watson import TextToSpeechV1
from ibm_watson.websocket import SynthesizeCallback
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_watson import ApiException
apikey = 'XXXXXXXXXXXXXX'
url = 'https://stream.watsonplatform.net/text-to-speech/api'
try:
authenticator = IAMAuthenticator(apikey)
service = TextToSpeechV1(authenticator=authenticator)
service.set_service_url(url)
voices = service.list_voices().get_result()
print(json.dumps(voices, indent=2))
except ApiException as ex:
print("Method failed with status code " + str(ex.code) + ": " + ex.message)我可以通过CURL使用API。
期望行为从API获得成功响应
实际行为获取403 (禁止)
截图

SDK最新版本
附加信息:
发布于 2021-02-01 10:18:11
根据API文档( https://cloud.ibm.com/apidocs/text-to-speech?code=python#authentication ),它应该是:
url = 'https://api.us-east.text-to-speech.watson.cloud.ibm.com'https://stackoverflow.com/questions/65973220
复制相似问题