Skip to content

Commit

Permalink
update review
Browse files Browse the repository at this point in the history
  • Loading branch information
xquanluu committed Nov 9, 2023
1 parent f86234a commit 73baa81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions lib/synth-audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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({
Expand Down
6 changes: 3 additions & 3 deletions test/synth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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'
Expand All @@ -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));
Expand Down

0 comments on commit 73baa81

Please sign in to comment.