Overview Enable to use IBM Watson API with Python. I keep getting 403 error (forbidden) no matter which URL I used I tried the following URLs:
- https://stream.watsonplatform.net/text-to-speech/api
- https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/synthesize
- https://api.us-south.speech-to-text.watson.cloud.ibm.com/text-to-speech/api
- https://api.us-south.speech-to-text.watson.cloud.ibm.com
But none of them work.
Code sampleimport 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)
I'm able to use the API via CURL.
Expected behavior Getting a success response from the API
Actual behavior Getting 403 (forbidden)
Screenshots
SDK Version Latest
Additional information:
- OS: Windows 10
- Python 3.9.1