Skip to content

Commit b9fad7b

Browse files
feat(tts): add params and add model constants
add params ratePercentage and pitchPercentage to synthesize function
1 parent d41c7ee commit b9fad7b

File tree

2 files changed

+208
-118
lines changed

2 files changed

+208
-118
lines changed

test/unit/text-to-speech.v1.test.js

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2018, 2022.
2+
* (C) Copyright IBM Corp. 2018, 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -191,8 +191,8 @@ describe('TextToSpeechV1', () => {
191191
const voice = 'ar-MS_OmarVoice';
192192
const customizationId = 'testString';
193193
const getVoiceParams = {
194-
voice: voice,
195-
customizationId: customizationId,
194+
voice,
195+
customizationId,
196196
};
197197

198198
const getVoiceResult = textToSpeechService.getVoice(getVoiceParams);
@@ -280,12 +280,16 @@ describe('TextToSpeechV1', () => {
280280
const voice = 'en-US_MichaelV3Voice';
281281
const customizationId = 'testString';
282282
const spellOutMode = 'default';
283+
const ratePercentage = 38;
284+
const pitchPercentage = 38;
283285
const synthesizeParams = {
284-
text: text,
285-
accept: accept,
286-
voice: voice,
287-
customizationId: customizationId,
288-
spellOutMode: spellOutMode,
286+
text,
287+
accept,
288+
voice,
289+
customizationId,
290+
spellOutMode,
291+
ratePercentage,
292+
pitchPercentage,
289293
};
290294

291295
const synthesizeResult = textToSpeechService.synthesize(synthesizeParams);
@@ -307,6 +311,8 @@ describe('TextToSpeechV1', () => {
307311
expect(mockRequestOptions.qs.voice).toEqual(voice);
308312
expect(mockRequestOptions.qs.customization_id).toEqual(customizationId);
309313
expect(mockRequestOptions.qs.spell_out_mode).toEqual(spellOutMode);
314+
expect(mockRequestOptions.qs.rate_percentage).toEqual(ratePercentage);
315+
expect(mockRequestOptions.qs.pitch_percentage).toEqual(pitchPercentage);
310316
expect(mockRequestOptions.responseType).toBe('stream');
311317
}
312318

@@ -377,10 +383,10 @@ describe('TextToSpeechV1', () => {
377383
const format = 'ipa';
378384
const customizationId = 'testString';
379385
const getPronunciationParams = {
380-
text: text,
381-
voice: voice,
382-
format: format,
383-
customizationId: customizationId,
386+
text,
387+
voice,
388+
format,
389+
customizationId,
384390
};
385391

386392
const getPronunciationResult = textToSpeechService.getPronunciation(getPronunciationParams);
@@ -469,9 +475,9 @@ describe('TextToSpeechV1', () => {
469475
const language = 'en-US';
470476
const description = 'testString';
471477
const createCustomModelParams = {
472-
name: name,
473-
language: language,
474-
description: description,
478+
name,
479+
language,
480+
description,
475481
};
476482

477483
const createCustomModelResult = textToSpeechService.createCustomModel(createCustomModelParams);
@@ -557,7 +563,7 @@ describe('TextToSpeechV1', () => {
557563
// Construct the params object for operation listCustomModels
558564
const language = 'ar-MS';
559565
const listCustomModelsParams = {
560-
language: language,
566+
language,
561567
};
562568

563569
const listCustomModelsResult = textToSpeechService.listCustomModels(listCustomModelsParams);
@@ -633,10 +639,10 @@ describe('TextToSpeechV1', () => {
633639
const description = 'testString';
634640
const words = [wordModel];
635641
const updateCustomModelParams = {
636-
customizationId: customizationId,
637-
name: name,
638-
description: description,
639-
words: words,
642+
customizationId,
643+
name,
644+
description,
645+
words,
640646
};
641647

642648
const updateCustomModelResult = textToSpeechService.updateCustomModel(updateCustomModelParams);
@@ -723,7 +729,7 @@ describe('TextToSpeechV1', () => {
723729
// Construct the params object for operation getCustomModel
724730
const customizationId = 'testString';
725731
const getCustomModelParams = {
726-
customizationId: customizationId,
732+
customizationId,
727733
};
728734

729735
const getCustomModelResult = textToSpeechService.getCustomModel(getCustomModelParams);
@@ -807,7 +813,7 @@ describe('TextToSpeechV1', () => {
807813
// Construct the params object for operation deleteCustomModel
808814
const customizationId = 'testString';
809815
const deleteCustomModelParams = {
810-
customizationId: customizationId,
816+
customizationId,
811817
};
812818

813819
const deleteCustomModelResult = textToSpeechService.deleteCustomModel(deleteCustomModelParams);
@@ -901,8 +907,8 @@ describe('TextToSpeechV1', () => {
901907
const customizationId = 'testString';
902908
const words = [wordModel];
903909
const addWordsParams = {
904-
customizationId: customizationId,
905-
words: words,
910+
customizationId,
911+
words,
906912
};
907913

908914
const addWordsResult = textToSpeechService.addWords(addWordsParams);
@@ -989,7 +995,7 @@ describe('TextToSpeechV1', () => {
989995
// Construct the params object for operation listWords
990996
const customizationId = 'testString';
991997
const listWordsParams = {
992-
customizationId: customizationId,
998+
customizationId,
993999
};
9941000

9951001
const listWordsResult = textToSpeechService.listWords(listWordsParams);
@@ -1076,10 +1082,10 @@ describe('TextToSpeechV1', () => {
10761082
const translation = 'testString';
10771083
const partOfSpeech = 'Dosi';
10781084
const addWordParams = {
1079-
customizationId: customizationId,
1080-
word: word,
1081-
translation: translation,
1082-
partOfSpeech: partOfSpeech,
1085+
customizationId,
1086+
word,
1087+
translation,
1088+
partOfSpeech,
10831089
};
10841090

10851091
const addWordResult = textToSpeechService.addWord(addWordParams);
@@ -1171,8 +1177,8 @@ describe('TextToSpeechV1', () => {
11711177
const customizationId = 'testString';
11721178
const word = 'testString';
11731179
const getWordParams = {
1174-
customizationId: customizationId,
1175-
word: word,
1180+
customizationId,
1181+
word,
11761182
};
11771183

11781184
const getWordResult = textToSpeechService.getWord(getWordParams);
@@ -1260,8 +1266,8 @@ describe('TextToSpeechV1', () => {
12601266
const customizationId = 'testString';
12611267
const word = 'testString';
12621268
const deleteWordParams = {
1263-
customizationId: customizationId,
1264-
word: word,
1269+
customizationId,
1270+
word,
12651271
};
12661272

12671273
const deleteWordResult = textToSpeechService.deleteWord(deleteWordParams);
@@ -1348,7 +1354,7 @@ describe('TextToSpeechV1', () => {
13481354
// Construct the params object for operation listCustomPrompts
13491355
const customizationId = 'testString';
13501356
const listCustomPromptsParams = {
1351-
customizationId: customizationId,
1357+
customizationId,
13521358
};
13531359

13541360
const listCustomPromptsResult = textToSpeechService.listCustomPrompts(listCustomPromptsParams);
@@ -1443,10 +1449,10 @@ describe('TextToSpeechV1', () => {
14431449
const metadata = promptMetadataModel;
14441450
const file = Buffer.from('This is a mock file.');
14451451
const addCustomPromptParams = {
1446-
customizationId: customizationId,
1447-
promptId: promptId,
1448-
metadata: metadata,
1449-
file: file,
1452+
customizationId,
1453+
promptId,
1454+
metadata,
1455+
file,
14501456
};
14511457

14521458
const addCustomPromptResult = textToSpeechService.addCustomPrompt(addCustomPromptParams);
@@ -1541,8 +1547,8 @@ describe('TextToSpeechV1', () => {
15411547
const customizationId = 'testString';
15421548
const promptId = 'testString';
15431549
const getCustomPromptParams = {
1544-
customizationId: customizationId,
1545-
promptId: promptId,
1550+
customizationId,
1551+
promptId,
15461552
};
15471553

15481554
const getCustomPromptResult = textToSpeechService.getCustomPrompt(getCustomPromptParams);
@@ -1630,8 +1636,8 @@ describe('TextToSpeechV1', () => {
16301636
const customizationId = 'testString';
16311637
const promptId = 'testString';
16321638
const deleteCustomPromptParams = {
1633-
customizationId: customizationId,
1634-
promptId: promptId,
1639+
customizationId,
1640+
promptId,
16351641
};
16361642

16371643
const deleteCustomPromptResult = textToSpeechService.deleteCustomPrompt(deleteCustomPromptParams);
@@ -1779,8 +1785,8 @@ describe('TextToSpeechV1', () => {
17791785
const speakerName = 'testString';
17801786
const audio = Buffer.from('This is a mock file.');
17811787
const createSpeakerModelParams = {
1782-
speakerName: speakerName,
1783-
audio: audio,
1788+
speakerName,
1789+
audio,
17841790
};
17851791

17861792
const createSpeakerModelResult = textToSpeechService.createSpeakerModel(createSpeakerModelParams);
@@ -1867,7 +1873,7 @@ describe('TextToSpeechV1', () => {
18671873
// Construct the params object for operation getSpeakerModel
18681874
const speakerId = 'testString';
18691875
const getSpeakerModelParams = {
1870-
speakerId: speakerId,
1876+
speakerId,
18711877
};
18721878

18731879
const getSpeakerModelResult = textToSpeechService.getSpeakerModel(getSpeakerModelParams);
@@ -1951,7 +1957,7 @@ describe('TextToSpeechV1', () => {
19511957
// Construct the params object for operation deleteSpeakerModel
19521958
const speakerId = 'testString';
19531959
const deleteSpeakerModelParams = {
1954-
speakerId: speakerId,
1960+
speakerId,
19551961
};
19561962

19571963
const deleteSpeakerModelResult = textToSpeechService.deleteSpeakerModel(deleteSpeakerModelParams);
@@ -2035,7 +2041,7 @@ describe('TextToSpeechV1', () => {
20352041
// Construct the params object for operation deleteUserData
20362042
const customerId = 'testString';
20372043
const deleteUserDataParams = {
2038-
customerId: customerId,
2044+
customerId,
20392045
};
20402046

20412047
const deleteUserDataResult = textToSpeechService.deleteUserData(deleteUserDataParams);

0 commit comments

Comments
 (0)