Skip to content

Commit 1bc946b

Browse files
feat(stt-tts): generation release changes
1 parent 8e70b7f commit 1bc946b

File tree

6 files changed

+1818
-167
lines changed

6 files changed

+1818
-167
lines changed

speech-to-text/v1-generated.ts

Lines changed: 347 additions & 154 deletions
Large diffs are not rendered by default.

test/integration/text-to-speech.test.js

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
const { IamAuthenticator } = require('../../dist/auth');
44
const TextToSpeechV1 = require('../../dist/text-to-speech/v1');
5+
const fs = require('fs');
6+
const path = require('path');
57
const wav = require('wav');
68
const authHelper = require('../resources/auth_helper.js');
79
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
@@ -94,6 +96,66 @@ describe('text to speech_integration', () => {
9496
customizationId = result.customization_id;
9597
});
9698

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+
97159
it('should listCustomModels() with language', async () => {
98160
const params = {
99161
language: 'en-GB',
@@ -220,4 +282,52 @@ describe('text to speech_integration', () => {
220282
expect(result).toBeDefined();
221283
});
222284
});
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+
});
223333
});

test/resources/tts_audio.wav

74 KB
Binary file not shown.

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2018, 2020.
2+
* (C) Copyright IBM Corp. 2018, 2021.
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.
@@ -253,6 +253,7 @@ describe('SpeechToTextV1', () => {
253253
const splitTranscriptAtPhraseEnd = true;
254254
const speechDetectorSensitivity = 36.0;
255255
const backgroundAudioSuppression = 36.0;
256+
const lowLatency = true;
256257
const params = {
257258
audio: audio,
258259
contentType: contentType,
@@ -279,6 +280,7 @@ describe('SpeechToTextV1', () => {
279280
splitTranscriptAtPhraseEnd: splitTranscriptAtPhraseEnd,
280281
speechDetectorSensitivity: speechDetectorSensitivity,
281282
backgroundAudioSuppression: backgroundAudioSuppression,
283+
lowLatency: lowLatency,
282284
};
283285

284286
const recognizeResult = speechToTextService.recognize(params);
@@ -320,6 +322,7 @@ describe('SpeechToTextV1', () => {
320322
expect(options.qs['split_transcript_at_phrase_end']).toEqual(splitTranscriptAtPhraseEnd);
321323
expect(options.qs['speech_detector_sensitivity']).toEqual(speechDetectorSensitivity);
322324
expect(options.qs['background_audio_suppression']).toEqual(backgroundAudioSuppression);
325+
expect(options.qs['low_latency']).toEqual(lowLatency);
323326
});
324327

325328
test('should prioritize user-given headers', () => {
@@ -538,6 +541,7 @@ describe('SpeechToTextV1', () => {
538541
const splitTranscriptAtPhraseEnd = true;
539542
const speechDetectorSensitivity = 36.0;
540543
const backgroundAudioSuppression = 36.0;
544+
const lowLatency = true;
541545
const params = {
542546
audio: audio,
543547
contentType: contentType,
@@ -570,6 +574,7 @@ describe('SpeechToTextV1', () => {
570574
splitTranscriptAtPhraseEnd: splitTranscriptAtPhraseEnd,
571575
speechDetectorSensitivity: speechDetectorSensitivity,
572576
backgroundAudioSuppression: backgroundAudioSuppression,
577+
lowLatency: lowLatency,
573578
};
574579

575580
const createJobResult = speechToTextService.createJob(params);
@@ -617,6 +622,7 @@ describe('SpeechToTextV1', () => {
617622
expect(options.qs['split_transcript_at_phrase_end']).toEqual(splitTranscriptAtPhraseEnd);
618623
expect(options.qs['speech_detector_sensitivity']).toEqual(speechDetectorSensitivity);
619624
expect(options.qs['background_audio_suppression']).toEqual(backgroundAudioSuppression);
625+
expect(options.qs['low_latency']).toEqual(lowLatency);
620626
});
621627

622628
test('should prioritize user-given headers', () => {

0 commit comments

Comments
 (0)