support mod_cartesia_transcribe (#1245)

This commit is contained in:
Hoan Luu Huu
2025-06-18 01:54:26 +07:00
committed by GitHub
parent 259dedcded
commit 5be6c54339
6 changed files with 67 additions and 0 deletions

View File

@@ -110,6 +110,10 @@ const stickyVars = {
voxist: [
'VOXIST_API_KEY',
],
cartesia: [
'CARTESIA_API_KEY',
'CARTESIA_MODEL_ID'
],
speechmatics: [
'SPEECHMATICS_API_KEY',
'SPEECHMATICS_HOST',
@@ -555,6 +559,25 @@ const normalizeVoxist = (evt, channel, language) => {
};
};
const normalizeCartesia = (evt, channel, language) => {
const copy = JSON.parse(JSON.stringify(evt));
return {
language_code: language,
channel_tag: channel,
is_final: evt.is_final,
alternatives: [
{
confidence: 1.00,
transcript: evt.text,
}
],
vendor: {
name: 'cartesia',
evt: copy
}
};
};
const normalizeSpeechmatics = (evt, channel, language) => {
const copy = JSON.parse(JSON.stringify(evt));
const is_final = evt.message === 'AddTranscript';
@@ -636,6 +659,8 @@ module.exports = (logger) => {
return normalizeAssemblyAi(evt, channel, language, shortUtterance);
case 'voxist':
return normalizeVoxist(evt, channel, language);
case 'cartesia':
return normalizeCartesia(evt, channel, language);
case 'verbio':
return normalizeVerbio(evt, channel, language);
case 'speechmatics':
@@ -1008,6 +1033,16 @@ module.exports = (logger) => {
{VOXIST_API_KEY: sttCredentials.api_key},
};
}
else if ('cartesia' === vendor) {
opts = {
...opts,
...(sttCredentials.api_key &&
{CARTESIA_API_KEY: sttCredentials.api_key}),
...(sttCredentials.stt_model_id && {
CARTESIA_MODEL_ID: sttCredentials.stt_model_id
})
};
}
else if ('openai' === vendor) {
const {openaiOptions = {}} = rOpts;
const model = openaiOptions.model || rOpts.model || sttCredentials.model_id || 'whisper-1';