mirror of
https://github.com/jambonz/speech-utils.git
synced 2025-12-19 03:37:49 +00:00
support openai
This commit is contained in:
@@ -450,7 +450,7 @@ test('Elevenlabs speech synth tests', async(t) => {
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.ELEVENLABS_API_KEY || !process.env.ELEVENLABS_VOICE_ID || !process.env.ELEVENLABS_MODEL_ID) {
|
||||
t.pass('skipping IBM Watson speech synth tests since IBM_TTS_API_KEY or IBM_TTS_API_KEY not provided');
|
||||
t.pass('skipping ElevenLabs speech synth tests since ELEVENLABS_API_KEY or ELEVENLABS_VOICE_ID or ELEVENLABS_MODEL_ID not provided');
|
||||
return t.end();
|
||||
}
|
||||
const text = 'Hi there and welcome to jambones!';
|
||||
@@ -474,6 +474,35 @@ test('Elevenlabs speech synth tests', async(t) => {
|
||||
client.quit();
|
||||
})
|
||||
|
||||
test('openai speech synth tests', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.OPENAI_API_KEY) {
|
||||
t.pass('skipping OPENAI speech synth tests since OPENAI_API_KEY not provided');
|
||||
return t.end();
|
||||
}
|
||||
const text = 'Hi there and welcome to jambones!';
|
||||
try {
|
||||
let opts = await synthAudio(stats, {
|
||||
vendor: 'openai',
|
||||
credentials: {
|
||||
api_key: process.env.OPENAI_API_KEY,
|
||||
model: 'tts-1'
|
||||
},
|
||||
language: 'en-US',
|
||||
voice: 'alloy',
|
||||
text,
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized openai audio to ${opts.filePath}`);
|
||||
|
||||
} catch (err) {
|
||||
console.error(JSON.stringify(err));
|
||||
t.end(err);
|
||||
}
|
||||
client.quit();
|
||||
})
|
||||
|
||||
test('TTS Cache tests', async(t) => {
|
||||
const fn = require('..');
|
||||
const {purgeTtsCache, getTtsSize, client} = fn(opts, logger);
|
||||
|
||||
Reference in New Issue
Block a user