I'm using IBM Watson "Text to Speech", when I use it, it asks me for the credentials. My code (it's jQuery) is:
var url = "https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=es-ES_EnriqueVoice&accept=audio/wav&text=" + text;
$("#speech").attr("src", url)[0].play();
Can I put the credentials in the URL? If so, how? Thanks for your support!
I think Watson TTS supports CORS so you should be ok. Then the authentication is in two parts. First use the APIKey to fetch a token, then use the token as a 'Bearer' token as part of your url. The documentation, however, says that you can pass the APIKey directly as a basic header - https://www.ibm.com/watson/developercloud/text-to-speech/api/v1/curl.html?curl#authentication
So if your key is 123456
then
var url = "https://apikey:[email protected]/text-to-speech/api/v1/synthesize?voice=es-ES_EnriqueVoice&accept=audio/wav&text=" + text;
However this does mean that you are passing your credentials in the clear in a browser application for anyone to use. So outside of a local test system totally useless. You would be better off constructing a server side application that either gives you a token with an expiry time, or does the voice systhesis and returns the generated audio file.