diff --git a/README.md b/README.md index c2cd7d57..9e736891 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ where the max length is around 1000 characters after the token is accounted for. Options: * text - the text to speak +* url - the Watson Text to Speech API URL (defaults to https://stream.watsonplatform.net/text-to-speech/api) * voice - the desired playback voice's name - see .getVoices(). Note that the voices are language-specific. * customization_id - GUID of a custom voice model - omit to use the voice with no customization. * autoPlay - set to false to prevent the audio from automatically playing diff --git a/speech-to-text/get-models.js b/speech-to-text/get-models.js index 288ecef6..9073e18b 100644 --- a/speech-to-text/get-models.js +++ b/speech-to-text/get-models.js @@ -37,6 +37,7 @@ * @todo define format in @return statement * @param {Object} options + * @param {String} options.url=https://stream.watsonplatform.net/speech-to-text/api URL for Watson Speech to Text API * @param {String} options.token auth token for CF services * @param {String} options.access_token IAM access token for RC services * @return {Promise.} @@ -51,11 +52,11 @@ module.exports = function getModels(options) { accept: 'application/json' } }; - var url; + var url = options.url || 'https://stream.watsonplatform.net/speech-to-text/api'; if (options.access_token) { - url = 'https://stream.watsonplatform.net/speech-to-text/api/v1/models?access_token=' + options.access_token; + url = `${url}/v1/models?access_token=${options.access_token}`; } else { - url = 'https://stream.watsonplatform.net/speech-to-text/api/v1/models?watson-token=' + options.token; + url = `${url}/v1/models?access_token=${options.token}`; } return fetch(url, reqOpts) .then(function(response) { diff --git a/text-to-speech/get-voices.js b/text-to-speech/get-voices.js index 882762d7..7a5ccc7f 100644 --- a/text-to-speech/get-voices.js +++ b/text-to-speech/get-voices.js @@ -38,6 +38,7 @@ * @todo define format in @return statement * @param {Object} options + * @param {String} options.url=https://stream.watsonplatform.net/text-to-speech/api URL for Watson Text to Speech API * @param {String} options.token auth token for CF services * @param {String} options.access_token IAM access token for RC services * @return {Promise.} @@ -52,11 +53,11 @@ module.exports = function getVoices(options) { accept: 'application/json' } }; - var url; + var url = options.url || 'https://stream.watsonplatform.net/text-to-speech/api'; if (options.access_token) { - url = 'https://stream.watsonplatform.net/text-to-speech/api/v1/voices?watson-token=' + options.access_token; + url = `${url}'/v1/voices?watson-token='${options.access_token}`; } else { - url = 'https://stream.watsonplatform.net/text-to-speech/api/v1/voices?watson-token=' + options.token; + url = `${url}'/v1/voices?watson-token='${options.token}`; } return fetch(url, reqOpts) .then(function(response) { diff --git a/text-to-speech/synthesize.js b/text-to-speech/synthesize.js index b272e826..be04f59b 100644 --- a/text-to-speech/synthesize.js +++ b/text-to-speech/synthesize.js @@ -29,6 +29,7 @@ var QUERY_PARAMS_ALLOWED = ['voice', 'X-WDC-PL-OPT-OUT', 'X-Watson-Learning-Opt- * Creates and returns a HTML5 `