From 73baa81177ef1ea2cc0a84345866cc4658174301 Mon Sep 17 00:00:00 2001 From: Quan HL Date: Thu, 9 Nov 2023 09:15:54 +0700 Subject: [PATCH] update review --- lib/synth-audio.js | 10 +++++----- test/synth.js | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/synth-audio.js b/lib/synth-audio.js index c1312d6..87ba9b2 100644 --- a/lib/synth-audio.js +++ b/lib/synth-audio.js @@ -84,7 +84,7 @@ async function synthAudio(client, logger, stats, { account_sid, logger = logger || noopLogger; assert.ok(['google', 'aws', 'polly', 'microsoft', - 'wellsaid', 'nuance', 'nvidia', 'ibm', 'elevenlabs', 'openai'].includes(vendor) || + 'wellsaid', 'nuance', 'nvidia', 'ibm', 'elevenlabs', 'whisper'].includes(vendor) || vendor.startsWith('custom'), `synthAudio supported vendors are google, aws, microsoft, nuance, nvidia and wellsaid, not ${vendor}`); if ('google' === vendor) { @@ -122,7 +122,7 @@ async function synthAudio(client, logger, stats, { account_sid, assert.ok(voice, 'synthAudio requires voice when elevenlabs is used'); assert.ok(credentials.api_key, 'synthAudio requires api_key when elevenlabs is used'); assert.ok(credentials.model_id, 'synthAudio requires model_id when elevenlabs is used'); - } else if ('openai' === vendor) { + } else if ('whisper' === vendor) { assert.ok(voice, 'synthAudio requires voice when openai is used'); assert.ok(credentials.model, 'synthAudio requires model when openai is used'); assert.ok(credentials.api_key, 'synthAudio requires api_key when openai is used'); @@ -196,8 +196,8 @@ async function synthAudio(client, logger, stats, { account_sid, case 'elevenlabs': audioBuffer = await synthElevenlabs(logger, {credentials, stats, language, voice, text, filePath}); break; - case 'openai': - audioBuffer = await synthOpenAI(logger, {credentials, stats, voice, text}); + case 'whisper': + audioBuffer = await synthWhisper(logger, {credentials, stats, voice, text}); break; case vendor.startsWith('custom') ? vendor : 'cant_match_value': ({ audioBuffer, filePath } = await synthCustomVendor(logger, @@ -609,7 +609,7 @@ const synthElevenlabs = async(logger, {credentials, stats, language, voice, text } }; -const synthOpenAI = async(logger, {credentials, stats, voice, text}) => { +const synthWhisper = async(logger, {credentials, stats, voice, text}) => { const {api_key, model, baseURL, timeout} = credentials; try { const openai = new OpenAI.OpenAI({ diff --git a/test/synth.js b/test/synth.js index 905fa61..dd1603f 100644 --- a/test/synth.js +++ b/test/synth.js @@ -474,7 +474,7 @@ test('Elevenlabs speech synth tests', async(t) => { client.quit(); }) -test('openai speech synth tests', async(t) => { +test('whisper speech synth tests', async(t) => { const fn = require('..'); const {synthAudio, client} = fn(opts, logger); @@ -485,7 +485,7 @@ test('openai speech synth tests', async(t) => { const text = 'Hi there and welcome to jambones!'; try { let opts = await synthAudio(stats, { - vendor: 'openai', + vendor: 'whisper', credentials: { api_key: process.env.OPENAI_API_KEY, model: 'tts-1' @@ -494,7 +494,7 @@ test('openai speech synth tests', async(t) => { voice: 'alloy', text, }); - t.ok(!opts.servedFromCache, `successfully synthesized openai audio to ${opts.filePath}`); + t.ok(!opts.servedFromCache, `successfully synthesized whisper audio to ${opts.filePath}`); } catch (err) { console.error(JSON.stringify(err));