|
2 | 2 |
|
3 | 3 | const { IamAuthenticator } = require('../../dist/auth');
|
4 | 4 | const TextToSpeechV1 = require('../../dist/text-to-speech/v1');
|
| 5 | +const fs = require('fs'); |
| 6 | +const path = require('path'); |
5 | 7 | const wav = require('wav');
|
6 | 8 | const authHelper = require('../resources/auth_helper.js');
|
7 | 9 | const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
|
@@ -94,6 +96,66 @@ describe('text to speech_integration', () => {
|
94 | 96 | customizationId = result.customization_id;
|
95 | 97 | });
|
96 | 98 |
|
| 99 | + describe('custom prompts', () => { |
| 100 | + const promptId = 'Hello'; |
| 101 | + |
| 102 | + it('should addCustomPrompt()', async () => { |
| 103 | + expect(customizationId).toBeTruthy(); |
| 104 | + |
| 105 | + const params = { |
| 106 | + customizationId, |
| 107 | + promptId, |
| 108 | + metadata: { |
| 109 | + prompt_text: 'Hello, how are you today?', |
| 110 | + }, |
| 111 | + file: fs.createReadStream(path.join(__dirname, '../resources/tts_audio.wav')), |
| 112 | + filename: 'tts_audio.wav', |
| 113 | + }; |
| 114 | + |
| 115 | + const res = await textToSpeech.addCustomPrompt(params); |
| 116 | + const { result } = res || {}; |
| 117 | + expect(result.prompt_id).toBe('Hello'); |
| 118 | + }); |
| 119 | + |
| 120 | + it('should listCustomPrompts()', async () => { |
| 121 | + expect(customizationId).toBeTruthy(); |
| 122 | + |
| 123 | + const params = { |
| 124 | + customizationId, |
| 125 | + }; |
| 126 | + |
| 127 | + const res = await textToSpeech.listCustomPrompts(params); |
| 128 | + const { result } = res || {}; |
| 129 | + expect(result.prompts.length).toBeTruthy(); |
| 130 | + }); |
| 131 | + |
| 132 | + it('should getCustomPrompt()', async () => { |
| 133 | + expect(customizationId).toBeTruthy(); |
| 134 | + |
| 135 | + const params = { |
| 136 | + customizationId, |
| 137 | + promptId, |
| 138 | + }; |
| 139 | + |
| 140 | + const res = await textToSpeech.getCustomPrompt(params); |
| 141 | + const { result } = res || {}; |
| 142 | + expect(result.prompt_id).toBe('Hello'); |
| 143 | + }); |
| 144 | + |
| 145 | + it('should deleteCustomPrompt()', async () => { |
| 146 | + expect(customizationId).toBeTruthy(); |
| 147 | + |
| 148 | + const params = { |
| 149 | + customizationId, |
| 150 | + promptId, |
| 151 | + }; |
| 152 | + |
| 153 | + const res = await textToSpeech.deleteCustomPrompt(params); |
| 154 | + const { result } = res || {}; |
| 155 | + expect(result).toBeDefined(); |
| 156 | + }); |
| 157 | + }); |
| 158 | + |
97 | 159 | it('should listCustomModels() with language', async () => {
|
98 | 160 | const params = {
|
99 | 161 | language: 'en-GB',
|
@@ -220,4 +282,52 @@ describe('text to speech_integration', () => {
|
220 | 282 | expect(result).toBeDefined();
|
221 | 283 | });
|
222 | 284 | });
|
| 285 | + |
| 286 | + describe('speaker models', () => { |
| 287 | + let speakerId; |
| 288 | + |
| 289 | + it('should createSpeakerModel()', async () => { |
| 290 | + const params = { |
| 291 | + speakerName: 'Angelo', |
| 292 | + audio: fs.createReadStream(path.join(__dirname, '../resources/tts_audio.wav')), |
| 293 | + }; |
| 294 | + |
| 295 | + const res = await textToSpeech.createSpeakerModel(params); |
| 296 | + const { result } = res || {}; |
| 297 | + expect(result.speaker_id).toBeDefined(); |
| 298 | + speakerId = result.speaker_id; |
| 299 | + }); |
| 300 | + |
| 301 | + it('should listSpeakerModels()', async () => { |
| 302 | + expect(speakerId).toBeTruthy(); |
| 303 | + |
| 304 | + const res = await textToSpeech.listSpeakerModels(); |
| 305 | + const { result } = res || {}; |
| 306 | + expect(result.speakers.length).toBeTruthy(); |
| 307 | + }); |
| 308 | + |
| 309 | + it('should getSpeakerModel()', async () => { |
| 310 | + expect(speakerId).toBeTruthy(); |
| 311 | + |
| 312 | + const params = { |
| 313 | + speakerId, |
| 314 | + }; |
| 315 | + |
| 316 | + const res = await textToSpeech.getSpeakerModel(params); |
| 317 | + const { result } = res || {}; |
| 318 | + expect(result.customizations).toBeDefined(); |
| 319 | + }); |
| 320 | + |
| 321 | + it('should deleteSpeakerModel()', async () => { |
| 322 | + expect(speakerId).toBeTruthy(); |
| 323 | + |
| 324 | + const params = { |
| 325 | + speakerId, |
| 326 | + }; |
| 327 | + |
| 328 | + const res = await textToSpeech.deleteSpeakerModel(params); |
| 329 | + const { result } = res || {}; |
| 330 | + expect(result).toBeDefined(); |
| 331 | + }); |
| 332 | + }); |
223 | 333 | });
|
0 commit comments