support elevenlabs stt

This commit is contained in:
Hoan HL
2025-11-18 16:47:52 +07:00
parent 98b845f489
commit cd9f9632ba
3 changed files with 37 additions and 0 deletions

View File

@@ -1139,6 +1139,7 @@ class CallSession extends Emitter {
return {
api_key: credential.api_key,
model_id: credential.model_id,
stt_model_id: credential.stt_model_id,
api_uri: credential.api_uri,
options: credential.options
};

View File

@@ -106,6 +106,7 @@ const speechMapper = (cred) => {
const o = JSON.parse(decrypt(credential));
obj.api_key = o.api_key;
obj.model_id = o.model_id;
obj.stt_model_id = o.stt_model_id;
obj.api_uri = o.api_uri;
obj.options = o.options;
}

View File

@@ -545,6 +545,21 @@ const normalizeVerbio = (evt, channel, language) => {
};
};
const normalizeElevenlabs = (evt, channel, language) => {
const copy = JSON.parse(JSON.stringify(evt));
console.log(copy);
return {
language_code: language,
channel_tag: channel,
is_final: evt.is_final,
alternatives: evt.alternatives,
vendor: {
name: 'elevenlabs',
evt: copy
}
};
};
const normalizeMicrosoft = (evt, channel, language, punctuation = true) => {
const copy = JSON.parse(JSON.stringify(evt));
const nbest = evt.NBest;
@@ -770,6 +785,8 @@ module.exports = (logger) => {
return normalizeGladia(evt, channel, language, shortUtterance);
case 'deepgramflux':
return normalizeDeepgramFlux(evt, channel, language, shortUtterance);
case 'elevenlabs':
return normalizeElevenlabs(evt, channel, language);
case 'microsoft':
return normalizeMicrosoft(evt, channel, language, punctuation);
case 'google':
@@ -1085,6 +1102,24 @@ module.exports = (logger) => {
...(keyterms && keyterms.length > 0 && {DEEPGRAMFLUX_SPEECH_KEYTERMS: keyterms.join(',')}),
};
}
else if ('elevenlabs' === vendor) {
const {api_key, stt_model_id} = sttCredentials;
const {includeTimestamps, commitStrategy, vadSilenceThresholdSecs, vadThreshold,
minSpeechDurationMs, minSilenceDurationMs, enableLogging} = rOpts.elevenlabsOptions || {};
opts = {
...opts,
ELEVENLABS_API_KEY: api_key,
ELEVENLABS_MODEL_ID: stt_model_id,
ELEVENLABS_INCLUDE_TIMESTAMPS: includeTimestamps === true ? true : false,
...(commitStrategy && {ELEVENLABS_COMMIT_STRATEGY: commitStrategy}),
...(vadSilenceThresholdSecs && {ELEVENLABS_VAD_SILENCE_THRESHOLD_SECS: vadSilenceThresholdSecs}),
...(vadThreshold && {ELEVENLABS_VAD_THRESHOLD: vadThreshold}),
...(minSpeechDurationMs && {ELEVENLABS_MIN_SPEECH_DURATION_MS: minSpeechDurationMs}),
...(minSilenceDurationMs && {ELEVENLABS_MIN_SILENCE_DURATION_MS: minSilenceDurationMs}),
...(enableLogging && {ELEVENLABS_ENABLE_LOGGING: enableLogging ? 1 : 0}),
};
}
else if ('gladia' === vendor) {
const {host, path} = sttCredentials;
opts = {