Skip to content

Commit

Permalink
refactor(text-to-speech): remove compatibility layer for text to speech
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dpopp07 committed Oct 22, 2018
1 parent 6377067 commit 6994d3c
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 119 deletions.
24 changes: 12 additions & 12 deletions examples/text_to_speech.v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ textToSpeech
.pipe(fs.createWriteStream('output.wav'));

// Retrieve details of all available voices
textToSpeech.voices({}, function(err, res) {
textToSpeech.listVoices({}, function(err, res) {
if (err) {
return console.log(err);
}
console.log(JSON.stringify(res, null, 2));
});

// Retrieve details of a specific voice
textToSpeech.voice(
textToSpeech.getVoice(
{
voice: 'en-GB_KateVoice'
},
Expand All @@ -64,7 +64,7 @@ textToSpeech.voice(
);

// Pronunciation details for a word
textToSpeech.pronunciation(
textToSpeech.getPronunciation(
{
text: 'iPhone',
format: 'spr', // 'ipa' (default) is only for english voices
Expand All @@ -78,8 +78,8 @@ textToSpeech.pronunciation(
}
);

// create a customization model to change pronunciation of words
textToSpeech.createCustomization(
// create a voice model to change pronunciation of words
textToSpeech.createVoiceModel(
{
name: 'my custom alt language pronunciation model',
language: 'en-US', // currently, only en-US is accepted
Expand All @@ -98,8 +98,8 @@ textToSpeech.createCustomization(
}
);

// update a customization model
textToSpeech.updateCustomization(
// update a voice model
textToSpeech.updateVoiceModel(
{
customization_id: '6666451d-a23e-485c-9bc5-c7ce722550d6',
name: 'new name', // optional
Expand All @@ -118,7 +118,7 @@ textToSpeech.updateCustomization(
);

// get a list of custom voice models
textToSpeech.getCustomizations(
textToSpeech.listVoiceModels(
{
language: 'en-US' // optional filter (currently only accepts en-US)
},
Expand Down Expand Up @@ -156,7 +156,7 @@ textToSpeech.getCustomizations(
);

// get details of a custom voice model
textToSpeech.getCustomization(
textToSpeech.getVoiceModel(
{
customization_id: '6666451d-a23e-485c-9bc5-c7ce722550d6'
},
Expand Down Expand Up @@ -190,7 +190,7 @@ textToSpeech.getCustomization(
);

// delete a custom voice model
textToSpeech.deleteCustomization(
textToSpeech.deleteVoiceModel(
{
customization_id: '9d153f61-a9c4-4b73-8eaf-63951c6dd77d'
},
Expand Down Expand Up @@ -220,7 +220,7 @@ textToSpeech.addWords(
);

// add a single word to an existing model
textToSpeech.updateCustomization(
textToSpeech.updateVoiceModel(
{
customization_id: '7c7f8ba7-2f83-48f2-ae52-3a70825f9899',
word: 'NCAA',
Expand All @@ -235,7 +235,7 @@ textToSpeech.updateCustomization(
);

// get all words in a customization
textToSpeech.getWords(
textToSpeech.listWords(
{
customization_id: '7c7f8ba7-2f83-48f2-ae52-3a70825f9899'
},
Expand Down
45 changes: 21 additions & 24 deletions test/integration/test.text_to_speech.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe('text_to_speech_integration', function() {
nock.disableNetConnect();
});

it('voices()', function(done) {
text_to_speech.voices(null, done);
it('listVoices()', function(done) {
text_to_speech.listVoices(null, done);
});

it('synthesize()', function(done) {
Expand All @@ -42,7 +42,7 @@ describe('text_to_speech_integration', function() {
.on('format', done.bind(null, null));
});

it('pronunciation()', function(done) {
it('getPronunciation()', function(done) {
const checkPronunciation = function(err, res) {
assert.ifError(err);
assert.equal(
Expand All @@ -54,16 +54,16 @@ describe('text_to_speech_integration', function() {
done();
};

text_to_speech.pronunciation({ text: 'IEEE' }, checkPronunciation);
text_to_speech.getPronunciation({ text: 'IEEE' }, checkPronunciation);
});

describe('customization', function() {
let customization_id;

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

it('createCustomization()', function(done) {
text_to_speech.createCustomization(
it('createVoiceModel()', function(done) {
text_to_speech.createVoiceModel(
{
name: 'temporary-node-sdk-test',
language: 'en-US',
Expand All @@ -84,8 +84,8 @@ describe('text_to_speech_integration', function() {
);
});

it('getCustomizations()', function(done) {
text_to_speech.getCustomizations({}, function(err, response) {
it('listVoiceModels()', function(done) {
text_to_speech.listVoiceModels({}, function(err, response) {
// console.log(JSON.stringify(err || response, null, 2));
if (err) {
return done(err);
Expand All @@ -95,8 +95,8 @@ describe('text_to_speech_integration', function() {
});
});

it('getCustomizations() with language', function(done) {
text_to_speech.getCustomizations({ language: 'en-GB' }, function(err, response) {
it('listVoiceModels() with language', function(done) {
text_to_speech.listVoiceModels({ language: 'en-GB' }, function(err, response) {
// console.log(JSON.stringify(err || response, null, 2));
if (err) {
return done(err);
Expand All @@ -114,8 +114,8 @@ describe('text_to_speech_integration', function() {
});
});

it('updateCustomization()', function(done) {
text_to_speech.updateCustomization(
it('updateVoiceModel()', function(done) {
text_to_speech.updateVoiceModel(
{
customization_id: customization_id,
description: 'Updated. Should be automatically deleted within 10 minutes.',
Expand All @@ -125,17 +125,14 @@ describe('text_to_speech_integration', function() {
);
});

it('getCustomization()', function(done) {
text_to_speech.getCustomization({ customization_id: customization_id }, function(
err,
response
) {
// console.log(JSON.stringify(err || response, null, 2));
it('getVoiceModel()', function(done) {
text_to_speech.getVoiceModel({ customization_id: customization_id }, function(err, res) {
// console.log(JSON.stringify(err || res, null, 2));
if (err) {
return done(err);
}
assert.equal(response.customization_id, customization_id);
assert(response.words.length);
assert.equal(res.customization_id, customization_id);
assert(res.words.length);
done();
});
});
Expand All @@ -161,8 +158,8 @@ describe('text_to_speech_integration', function() {
);
});

it('getWords()', function(done) {
text_to_speech.getWords({ customization_id: customization_id }, function(err, response) {
it('listWords()', function(done) {
text_to_speech.listWords({ customization_id: customization_id }, function(err, response) {
if (err) {
return done(err);
}
Expand Down Expand Up @@ -196,8 +193,8 @@ describe('text_to_speech_integration', function() {
);
});

it('deleteCustomization()', function(done) {
text_to_speech.deleteCustomization({ customization_id: customization_id }, done);
it('deleteVoiceModel()', function(done) {
text_to_speech.deleteVoiceModel({ customization_id: customization_id }, done);
});
});
});
Loading

0 comments on commit 6994d3c

Please sign in to comment.