Skip to content

Commit 6994d3c

Browse files
committed
refactor(text-to-speech): remove compatibility layer for text to speech
BREAKING CHANGE: Deprecated methods in Text to Speech are no longer available. Changed parameter names are no longer interally corrected. To migrate your code, use the methods and parameters currently available with the service as documented here: https://www.ibm.com/watson/developercloud/text-to-speech/api/v1/node.html?node
1 parent 6377067 commit 6994d3c

File tree

4 files changed

+71
-119
lines changed

4 files changed

+71
-119
lines changed

examples/text_to_speech.v1.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ textToSpeech
4343
.pipe(fs.createWriteStream('output.wav'));
4444

4545
// Retrieve details of all available voices
46-
textToSpeech.voices({}, function(err, res) {
46+
textToSpeech.listVoices({}, function(err, res) {
4747
if (err) {
4848
return console.log(err);
4949
}
5050
console.log(JSON.stringify(res, null, 2));
5151
});
5252

5353
// Retrieve details of a specific voice
54-
textToSpeech.voice(
54+
textToSpeech.getVoice(
5555
{
5656
voice: 'en-GB_KateVoice'
5757
},
@@ -64,7 +64,7 @@ textToSpeech.voice(
6464
);
6565

6666
// Pronunciation details for a word
67-
textToSpeech.pronunciation(
67+
textToSpeech.getPronunciation(
6868
{
6969
text: 'iPhone',
7070
format: 'spr', // 'ipa' (default) is only for english voices
@@ -78,8 +78,8 @@ textToSpeech.pronunciation(
7878
}
7979
);
8080

81-
// create a customization model to change pronunciation of words
82-
textToSpeech.createCustomization(
81+
// create a voice model to change pronunciation of words
82+
textToSpeech.createVoiceModel(
8383
{
8484
name: 'my custom alt language pronunciation model',
8585
language: 'en-US', // currently, only en-US is accepted
@@ -98,8 +98,8 @@ textToSpeech.createCustomization(
9898
}
9999
);
100100

101-
// update a customization model
102-
textToSpeech.updateCustomization(
101+
// update a voice model
102+
textToSpeech.updateVoiceModel(
103103
{
104104
customization_id: '6666451d-a23e-485c-9bc5-c7ce722550d6',
105105
name: 'new name', // optional
@@ -118,7 +118,7 @@ textToSpeech.updateCustomization(
118118
);
119119

120120
// get a list of custom voice models
121-
textToSpeech.getCustomizations(
121+
textToSpeech.listVoiceModels(
122122
{
123123
language: 'en-US' // optional filter (currently only accepts en-US)
124124
},
@@ -156,7 +156,7 @@ textToSpeech.getCustomizations(
156156
);
157157

158158
// get details of a custom voice model
159-
textToSpeech.getCustomization(
159+
textToSpeech.getVoiceModel(
160160
{
161161
customization_id: '6666451d-a23e-485c-9bc5-c7ce722550d6'
162162
},
@@ -190,7 +190,7 @@ textToSpeech.getCustomization(
190190
);
191191

192192
// delete a custom voice model
193-
textToSpeech.deleteCustomization(
193+
textToSpeech.deleteVoiceModel(
194194
{
195195
customization_id: '9d153f61-a9c4-4b73-8eaf-63951c6dd77d'
196196
},
@@ -220,7 +220,7 @@ textToSpeech.addWords(
220220
);
221221

222222
// add a single word to an existing model
223-
textToSpeech.updateCustomization(
223+
textToSpeech.updateVoiceModel(
224224
{
225225
customization_id: '7c7f8ba7-2f83-48f2-ae52-3a70825f9899',
226226
word: 'NCAA',
@@ -235,7 +235,7 @@ textToSpeech.updateCustomization(
235235
);
236236

237237
// get all words in a customization
238-
textToSpeech.getWords(
238+
textToSpeech.listWords(
239239
{
240240
customization_id: '7c7f8ba7-2f83-48f2-ae52-3a70825f9899'
241241
},

test/integration/test.text_to_speech.js

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ describe('text_to_speech_integration', function() {
2525
nock.disableNetConnect();
2626
});
2727

28-
it('voices()', function(done) {
29-
text_to_speech.voices(null, done);
28+
it('listVoices()', function(done) {
29+
text_to_speech.listVoices(null, done);
3030
});
3131

3232
it('synthesize()', function(done) {
@@ -42,7 +42,7 @@ describe('text_to_speech_integration', function() {
4242
.on('format', done.bind(null, null));
4343
});
4444

45-
it('pronunciation()', function(done) {
45+
it('getPronunciation()', function(done) {
4646
const checkPronunciation = function(err, res) {
4747
assert.ifError(err);
4848
assert.equal(
@@ -54,16 +54,16 @@ describe('text_to_speech_integration', function() {
5454
done();
5555
};
5656

57-
text_to_speech.pronunciation({ text: 'IEEE' }, checkPronunciation);
57+
text_to_speech.getPronunciation({ text: 'IEEE' }, checkPronunciation);
5858
});
5959

6060
describe('customization', function() {
6161
let customization_id;
6262

6363
// todo: before task that cleans up any leftover customizations from previous runs
6464

65-
it('createCustomization()', function(done) {
66-
text_to_speech.createCustomization(
65+
it('createVoiceModel()', function(done) {
66+
text_to_speech.createVoiceModel(
6767
{
6868
name: 'temporary-node-sdk-test',
6969
language: 'en-US',
@@ -84,8 +84,8 @@ describe('text_to_speech_integration', function() {
8484
);
8585
});
8686

87-
it('getCustomizations()', function(done) {
88-
text_to_speech.getCustomizations({}, function(err, response) {
87+
it('listVoiceModels()', function(done) {
88+
text_to_speech.listVoiceModels({}, function(err, response) {
8989
// console.log(JSON.stringify(err || response, null, 2));
9090
if (err) {
9191
return done(err);
@@ -95,8 +95,8 @@ describe('text_to_speech_integration', function() {
9595
});
9696
});
9797

98-
it('getCustomizations() with language', function(done) {
99-
text_to_speech.getCustomizations({ language: 'en-GB' }, function(err, response) {
98+
it('listVoiceModels() with language', function(done) {
99+
text_to_speech.listVoiceModels({ language: 'en-GB' }, function(err, response) {
100100
// console.log(JSON.stringify(err || response, null, 2));
101101
if (err) {
102102
return done(err);
@@ -114,8 +114,8 @@ describe('text_to_speech_integration', function() {
114114
});
115115
});
116116

117-
it('updateCustomization()', function(done) {
118-
text_to_speech.updateCustomization(
117+
it('updateVoiceModel()', function(done) {
118+
text_to_speech.updateVoiceModel(
119119
{
120120
customization_id: customization_id,
121121
description: 'Updated. Should be automatically deleted within 10 minutes.',
@@ -125,17 +125,14 @@ describe('text_to_speech_integration', function() {
125125
);
126126
});
127127

128-
it('getCustomization()', function(done) {
129-
text_to_speech.getCustomization({ customization_id: customization_id }, function(
130-
err,
131-
response
132-
) {
133-
// console.log(JSON.stringify(err || response, null, 2));
128+
it('getVoiceModel()', function(done) {
129+
text_to_speech.getVoiceModel({ customization_id: customization_id }, function(err, res) {
130+
// console.log(JSON.stringify(err || res, null, 2));
134131
if (err) {
135132
return done(err);
136133
}
137-
assert.equal(response.customization_id, customization_id);
138-
assert(response.words.length);
134+
assert.equal(res.customization_id, customization_id);
135+
assert(res.words.length);
139136
done();
140137
});
141138
});
@@ -161,8 +158,8 @@ describe('text_to_speech_integration', function() {
161158
);
162159
});
163160

164-
it('getWords()', function(done) {
165-
text_to_speech.getWords({ customization_id: customization_id }, function(err, response) {
161+
it('listWords()', function(done) {
162+
text_to_speech.listWords({ customization_id: customization_id }, function(err, response) {
166163
if (err) {
167164
return done(err);
168165
}
@@ -196,8 +193,8 @@ describe('text_to_speech_integration', function() {
196193
);
197194
});
198195

199-
it('deleteCustomization()', function(done) {
200-
text_to_speech.deleteCustomization({ customization_id: customization_id }, done);
196+
it('deleteVoiceModel()', function(done) {
197+
text_to_speech.deleteVoiceModel({ customization_id: customization_id }, done);
201198
});
202199
});
203200
});

0 commit comments

Comments
 (0)