Skip to content

Commit 30c5611

Browse files
committed
Added support for 'X-Watson-Learning-Opt-Out' and 'accept' params in TTS synthesize()
1 parent 6bdb88e commit 30c5611

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
### v0.29.0
4+
* BREAKING: recognizeFile()'s data option renamed to file
5+
* File option may be a string URL. This enables streaming transcription/playback and mobile Safari support.
6+
* Added support for 'X-Watson-Learning-Opt-Out' and 'accept' params in TTS synthesize()
7+
38
### v0.28.4
49
* Prevent RecognizeStream from sending a blank content-type header - now emits an error if content-type is unset and unable to be automatically determined.
510

text-to-speech/synthesize.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
var pick = require('object.pick');
1818
var qs = require('../util/querystring.js');
1919

20-
var QUERY_PARAMS_ALLOWED = ['voice', 'X-WDC-PL-OPT-OUT', 'text', 'watson-token'];
20+
var QUERY_PARAMS_ALLOWED = ['voice', 'X-WDC-PL-OPT-OUT', 'X-Watson-Learning-Opt-Out', 'text', 'watson-token', 'accept'];
2121

2222
/**
2323
* @module watson-speech/text-to-speech/synthesize
@@ -32,7 +32,8 @@ var QUERY_PARAMS_ALLOWED = ['voice', 'X-WDC-PL-OPT-OUT', 'text', 'watson-token']
3232
* @param {String} options.token auth token
3333
* @param {String} options.text text to speak
3434
* @param {String} [options.voice=en-US_MichaelVoice] what voice to use - call getVoices() for a complete list.
35-
* @param {Number} [options.X-WDC-PL-OPT-OUT=0] set to 1 to opt-out of allowing Watson to use this request to improve it's services
35+
* @param {String} [options.accept] - specify desired audio format. Leave unset to allow (most) browsers to automatically negotiate an ideal format.
36+
* @param {Number} [options.X-Watson-Learning-Opt-Out=0] set to 1 to opt-out of allowing Watson to use this request to improve it's services
3637
* @param {Boolean} [options.autoPlay=true] automatically play the audio
3738
* @param {DOMAudioElement} [options.element] <audio> element - will be used instead of creating a new one if provided
3839
* @returns {Audio}
@@ -45,7 +46,7 @@ module.exports = function synthesize(options) {
4546
options['watson-token'] = options.token;
4647
delete options.token;
4748
var audio = options.element || new Audio();
48-
audio.crossOrigin = true;
49+
audio.crossOrigin = 'anonymous';
4950
audio.src = 'https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?' + qs.stringify(pick(options, QUERY_PARAMS_ALLOWED));
5051
if (options.autoPlay !== false) {
5152
audio.play();

0 commit comments

Comments
 (0)