Reputation: 147
Running this on Raspbian Buster. I upgraded as per the instructions on cloud.ibm.com api docs:
Installing collected packages: ibm-cloud-sdk-core, ibm-watson
Found existing installation: ibm-cloud-sdk-core 0.5.1
Uninstalling ibm-cloud-sdk-core-0.5.1:
Successfully uninstalled ibm-cloud-sdk-core-0.5.1
Found existing installation: ibm-watson 3.4.0
Uninstalling ibm-watson-3.4.0:
Successfully uninstalled ibm-watson-3.4.0
Successfully installed ibm-cloud-sdk-core-1.0.0 ibm-watson-4.0.1
The script looks like:
#!/usr/bin/python3
from ibm_watson import TextToSpeechV1
import json
text_to_speech = TextToSpeechV1(
iam_apikey='7XT8Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
url='https://stream.watsonplatform.net/text-to-speech/api'
)
with open('file.wav', 'wb') as audio_file:
audio_file.write(
...
Again, the code block only includes the first line. Not real helpful. The almost identical script runs fine on Mint 18.
The actual error:
python3 watson.py
Traceback (most recent call last):
File "watson.py", line 7, in <module>
url='https://stream.watsonplatform.net/text-to-speech/api'
TypeError: __init__() got an unexpected keyword argument 'iam_apikey'
Just for good measure I attempted to connect using node.js code and I get a similar error, "missing keyword apikey"
Thanks for any help. Jim.
Upvotes: 2
Views: 2024
Reputation: 19625
In version 4, which you are now using, the TextToSpeechV1
constructor changed to accept an authenticator
instead of an iam_apikey
to allow additional authentication mechanisms. From the migration docs:
Before
from ibm_watson import MyService service = MyService( iam_apikey='{apikey}', url='{url}' )
After (V4.0)
from ibm_watson import MyService from ibm_cloud_sdk_core.authenticators import IAMAuthenticator authenticator = IAMAuthenticator('{apikey}') service = MyService( authenticator=authenticator ) service.set_service_url('{url}')
In your case, MyService
would be TextToSpeechV1
.
Upvotes: 3