I am trying to use the Watson Speech To Text service which needs the following command for the websocket Interface as per the documentation
var token = {authentication-token};
var wsURI = 'wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize'
+ '?watson-token=' + token
+ '&model=es-ES_BroadbandModel';
I have tried this to get the {authentication-token}
using curl command on terminal
curl -X GET --user "apikey:{apikey}" "https://stream.watsonplatform.net/authorization/api/v1/token?url=https://stream.watsonplatform.net/text-to-speech/api"
The above command yields
Error: {"code":401,"error":"Unauthorized","description":"ERCD250-LDAP-DN-AUTHERR"}
Couldn't find proper documentation for this including several posts which seem to be out of scope after the recent changes made by IBM watson team.
Question: How do I get the authentication-token
for connecting to the watson web socket properly?
As mentioned in the Speech to Text API docs,
Here's the known limitation,
If you have an old Speech to Text service with cloud foundry credentials (username and password), you can make a Curl request for the
watson-token
like thisEven this is documented in the API docs under watson-token parameter under Curl
Update: The WebSocket interface cannot be called from curl. Use a client-side scripting language to call the interface. You can find the code samples for streaming the audio in each of the programming languages SDKs like this example from Python SDK - https://github.com/watson-developer-cloud/python-sdk/blob/master/examples/microphone-speech-to-text.py
UPDATE 2019-02-09
According to the release documentation it is now again possible to authenticate to the websocket API from the browser. See: https://cloud.ibm.com/docs/services/speech-to-text/release-notes.html#release-notes for release 28 January 2019. However, getting an authentication token using your API key is NOT possible from the browser (prevented by CORG for security reasons). So to make this work: - get an api token for dallas (did not get it to work for other regions, looks like the lib is hardcoded set to the dallas server) - use a backend application to get an authentication token using your api key - use the authentication token straight from the browser using the speech-javascript-sdk
To get the
authentication-token
you need to run the following cURL command. This can be included in your program prior to the connection (websocket handshake).Follow this link for more details - https://console.bluemix.net/docs/services/watson/getting-started-iam.html
For C++ users - You may include this as below
inside callback take a variable
token
to hold the parsed responseThis string should be used as the request header for websoket handshake