mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-07-04 19:31:49 +00:00
support elevenlabs options
This commit is contained in:
+7
-3
@@ -586,20 +586,24 @@ const synthCustomVendor = async(logger, {credentials, stats, language, voice, te
|
||||
};
|
||||
|
||||
const synthElevenlabs = async(logger, {credentials, stats, language, voice, text}) => {
|
||||
const {api_key, model_id} = credentials;
|
||||
const {api_key, model_id, options} = credentials;
|
||||
const opts = JSON.parse(options || '{}');
|
||||
const optimize_streaming_latency = opts.optimize_streaming_latency ?
|
||||
`?optimize_streaming_latency=${opts.optimize_streaming_latency}` : '';
|
||||
try {
|
||||
const post = bent('https://api.elevenlabs.io', 'POST', 'buffer', {
|
||||
'xi-api-key': api_key,
|
||||
'Accept': 'audio/mpeg',
|
||||
'Content-Type': 'application/json'
|
||||
});
|
||||
const mp3 = await post(`/v1/text-to-speech/${voice}`, {
|
||||
const mp3 = await post(`/v1/text-to-speech/${voice}${optimize_streaming_latency}`, {
|
||||
text,
|
||||
model_id,
|
||||
voice_settings: {
|
||||
stability: 0.5,
|
||||
similarity_boost: 0.5
|
||||
}
|
||||
},
|
||||
...opts
|
||||
});
|
||||
return mp3;
|
||||
} catch (err) {
|
||||
|
||||
+10
-1
@@ -459,7 +459,16 @@ test('Elevenlabs speech synth tests', async(t) => {
|
||||
vendor: 'elevenlabs',
|
||||
credentials: {
|
||||
api_key: process.env.ELEVENLABS_API_KEY,
|
||||
model_id: process.env.ELEVENLABS_MODEL_ID
|
||||
model_id: process.env.ELEVENLABS_MODEL_ID,
|
||||
options: JSON.stringify({
|
||||
optimize_streaming_latency: 1,
|
||||
voice_settings: {
|
||||
similarity_boost: 1,
|
||||
stability: 0.8,
|
||||
style: 1,
|
||||
use_speaker_boost: true
|
||||
}
|
||||
})
|
||||
},
|
||||
language: 'en-US',
|
||||
voice: process.env.ELEVENLABS_VOICE_ID,
|
||||
|
||||
Reference in New Issue
Block a user