Skip to content

Commit

Permalink
feat(stt-tts): generation release changes
Browse files Browse the repository at this point in the history
  • Loading branch information
apaparazzi0329 committed May 26, 2021
1 parent 8e70b7f commit 1bc946b
Show file tree
Hide file tree
Showing 6 changed files with 1,818 additions and 167 deletions.
501 changes: 347 additions & 154 deletions speech-to-text/v1-generated.ts

Large diffs are not rendered by default.

110 changes: 110 additions & 0 deletions test/integration/text-to-speech.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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

describe('custom prompts', () => {
const promptId = 'Hello';

it('should addCustomPrompt()', async () => {
expect(customizationId).toBeTruthy();

const params = {
customizationId,
promptId,
metadata: {
prompt_text: 'Hello, how are you today?',
},
file: fs.createReadStream(path.join(__dirname, '../resources/tts_audio.wav')),
filename: 'tts_audio.wav',
};

const res = await textToSpeech.addCustomPrompt(params);
const { result } = res || {};
expect(result.prompt_id).toBe('Hello');
});

it('should listCustomPrompts()', async () => {
expect(customizationId).toBeTruthy();

const params = {
customizationId,
};

const res = await textToSpeech.listCustomPrompts(params);
const { result } = res || {};
expect(result.prompts.length).toBeTruthy();
});

it('should getCustomPrompt()', async () => {
expect(customizationId).toBeTruthy();

const params = {
customizationId,
promptId,
};

const res = await textToSpeech.getCustomPrompt(params);
const { result } = res || {};
expect(result.prompt_id).toBe('Hello');
});

it('should deleteCustomPrompt()', async () => {
expect(customizationId).toBeTruthy();

const params = {
customizationId,
promptId,
};

const res = await textToSpeech.deleteCustomPrompt(params);
const { result } = res || {};
expect(result).toBeDefined();
});
});

it('should listCustomModels() with language', async () => {
const params = {
language: 'en-GB',
Expand Down Expand Up @@ -220,4 +282,52 @@ describe('text to speech_integration', () => {
expect(result).toBeDefined();
});
});

describe('speaker models', () => {
let speakerId;

it('should createSpeakerModel()', async () => {
const params = {
speakerName: 'Angelo',
audio: fs.createReadStream(path.join(__dirname, '../resources/tts_audio.wav')),
};

const res = await textToSpeech.createSpeakerModel(params);
const { result } = res || {};
expect(result.speaker_id).toBeDefined();
speakerId = result.speaker_id;
});

it('should listSpeakerModels()', async () => {
expect(speakerId).toBeTruthy();

const res = await textToSpeech.listSpeakerModels();
const { result } = res || {};
expect(result.speakers.length).toBeTruthy();
});

it('should getSpeakerModel()', async () => {
expect(speakerId).toBeTruthy();

const params = {
speakerId,
};

const res = await textToSpeech.getSpeakerModel(params);
const { result } = res || {};
expect(result.customizations).toBeDefined();
});

it('should deleteSpeakerModel()', async () => {
expect(speakerId).toBeTruthy();

const params = {
speakerId,
};

const res = await textToSpeech.deleteSpeakerModel(params);
const { result } = res || {};
expect(result).toBeDefined();
});
});
});
Binary file added test/resources/tts_audio.wav
Binary file not shown.
8 changes: 7 additions & 1 deletion test/unit/speech-to-text.v1.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corp. 2018, 2020.
* (C) Copyright IBM Corp. 2018, 2021.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -253,6 +253,7 @@ describe('SpeechToTextV1', () => {
const splitTranscriptAtPhraseEnd = true;
const speechDetectorSensitivity = 36.0;
const backgroundAudioSuppression = 36.0;
const lowLatency = true;
const params = {
audio: audio,
contentType: contentType,
Expand All @@ -279,6 +280,7 @@ describe('SpeechToTextV1', () => {
splitTranscriptAtPhraseEnd: splitTranscriptAtPhraseEnd,
speechDetectorSensitivity: speechDetectorSensitivity,
backgroundAudioSuppression: backgroundAudioSuppression,
lowLatency: lowLatency,
};

const recognizeResult = speechToTextService.recognize(params);
Expand Down Expand Up @@ -320,6 +322,7 @@ describe('SpeechToTextV1', () => {
expect(options.qs['split_transcript_at_phrase_end']).toEqual(splitTranscriptAtPhraseEnd);
expect(options.qs['speech_detector_sensitivity']).toEqual(speechDetectorSensitivity);
expect(options.qs['background_audio_suppression']).toEqual(backgroundAudioSuppression);
expect(options.qs['low_latency']).toEqual(lowLatency);
});

test('should prioritize user-given headers', () => {
Expand Down Expand Up @@ -538,6 +541,7 @@ describe('SpeechToTextV1', () => {
const splitTranscriptAtPhraseEnd = true;
const speechDetectorSensitivity = 36.0;
const backgroundAudioSuppression = 36.0;
const lowLatency = true;
const params = {
audio: audio,
contentType: contentType,
Expand Down Expand Up @@ -570,6 +574,7 @@ describe('SpeechToTextV1', () => {
splitTranscriptAtPhraseEnd: splitTranscriptAtPhraseEnd,
speechDetectorSensitivity: speechDetectorSensitivity,
backgroundAudioSuppression: backgroundAudioSuppression,
lowLatency: lowLatency,
};

const createJobResult = speechToTextService.createJob(params);
Expand Down Expand Up @@ -617,6 +622,7 @@ describe('SpeechToTextV1', () => {
expect(options.qs['split_transcript_at_phrase_end']).toEqual(splitTranscriptAtPhraseEnd);
expect(options.qs['speech_detector_sensitivity']).toEqual(speechDetectorSensitivity);
expect(options.qs['background_audio_suppression']).toEqual(backgroundAudioSuppression);
expect(options.qs['low_latency']).toEqual(lowLatency);
});

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

0 comments on commit 1bc946b

Please sign in to comment.