@@ -28,10 +28,7 @@ var requestFactory = require('../../lib/requestwrapper');
28
28
function TextToSpeech ( options ) {
29
29
// Default URL
30
30
var serviceDefaults = {
31
- url : 'https://stream.watsonplatform.net/text-to-speech/api' ,
32
- headers : {
33
- 'content-type' : 'application/json'
34
- }
31
+ url : 'https://stream.watsonplatform.net/text-to-speech/api'
35
32
} ;
36
33
37
34
// Replace default options with user provided
@@ -40,6 +37,13 @@ function TextToSpeech(options) {
40
37
41
38
/**
42
39
* Streaming speech synthesis of the text in a query parameter
40
+ *
41
+ * @param {Object } options
42
+ * @param {String } options.text
43
+ * @param {String } [options.voice]
44
+ * @param {String } [options.accept]
45
+ * @param {Boolean } [options.X-Watson-Learning-Opt-Out]
46
+ * @param {Function } callback
43
47
*/
44
48
TextToSpeech . prototype . synthesize = function ( params , callback ) {
45
49
params = extend ( { accept :'audio/ogg; codecs=opus' } , params ) ;
@@ -54,9 +58,9 @@ TextToSpeech.prototype.synthesize = function(params, callback) {
54
58
url : '/v1/synthesize' ,
55
59
body : JSON . stringify ( pick ( params , [ 'text' ] ) ) ,
56
60
qs : pick ( params , [ 'accept' , 'voice' ] ) ,
57
- headers : {
61
+ headers : extend ( {
58
62
'content-type' : 'application/json'
59
- } ,
63
+ } , pick ( params , [ 'X-Watson-Learning-Opt-Out' ] ) ) ,
60
64
encoding : null
61
65
} ,
62
66
defaultOptions : this . _options
0 commit comments