mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-01-25 02:08:26 +00:00
update review
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user