Compare commits

...

7 Commits

Author SHA1 Message Date
Hoan HL
85b1166194 rebase 2025-12-01 15:44:44 +07:00
Hoan HL
5d8ea34716 wip 2025-11-19 11:33:42 +07:00
Hoan HL
cf7e89914b update verb specification 2025-11-19 11:29:47 +07:00
Hoan HL
225d1039db wip 2025-11-19 10:29:31 +07:00
Hoan HL
14c5bc18cd wip 2025-11-19 05:54:31 +07:00
Hoan HL
e8817814bf wip 2025-11-18 17:24:45 +07:00
Hoan HL
cd9f9632ba support elevenlabs stt 2025-11-18 16:47:52 +07:00
6 changed files with 58 additions and 0 deletions

View File

@@ -1141,6 +1141,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

@@ -5,6 +5,7 @@ const {
AwsTranscriptionEvents,
AzureTranscriptionEvents,
DeepgramTranscriptionEvents,
ElevenlabsTranscriptionEvents,
GladiaTranscriptionEvents,
SonioxTranscriptionEvents,
CobaltTranscriptionEvents,
@@ -492,6 +493,17 @@ class TaskGather extends SttTask {
this.addCustomEventListener(ep, DeepgramfluxTranscriptionEvents.Error, this._onVendorError.bind(this, cs, ep));
break;
case 'elevenlabs':
this.bugname = `${this.bugname_prefix}elevenlabs_transcribe`;
this.addCustomEventListener(
ep, ElevenlabsTranscriptionEvents.Transcription, this._onTranscription.bind(this, cs, ep));
this.addCustomEventListener(
ep, ElevenlabsTranscriptionEvents.Connect, this._onVendorConnect.bind(this, cs, ep));
this.addCustomEventListener(ep, ElevenlabsTranscriptionEvents.ConnectFailure,
this._onVendorConnectFailure.bind(this, cs, ep));
this.addCustomEventListener(ep, ElevenlabsTranscriptionEvents.Error, this._onVendorError.bind(this, cs, ep));
break;
case 'gladia':
this.bugname = `${this.bugname_prefix}gladia_transcribe`;
this.addCustomEventListener(

View File

@@ -103,6 +103,12 @@
"Connect": "deepgramflux_transcribe::connect",
"Error": "deepgramflux_transcribe::error"
},
"ElevenlabsTranscriptionEvents": {
"Transcription": "elevenlabs_transcribe::transcription",
"ConnectFailure": "elevenlabs_transcribe::connect_failed",
"Connect": "elevenlabs_transcribe::connect",
"Error": "elevenlabs_transcribe::error"
},
"GladiaTranscriptionEvents": {
"Transcription": "gladia_transcribe::transcription",
"ConnectFailure": "gladia_transcribe::connect_failed",

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,23 @@ const normalizeVerbio = (evt, channel, language) => {
};
};
const normalizeElevenlabs = (evt, channel, language) => {
const copy = JSON.parse(JSON.stringify(evt));
return {
language_code: language,
channel_tag: channel,
is_final: evt.message_type === 'committed_transcript',
alternatives: [{
confidence: 1.0,
transcript: evt.text,
}],
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 +787,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 +1104,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 = {

1
package-lock.json generated
View File

@@ -8752,6 +8752,7 @@
},
"node_modules/unix-dgram": {
"version": "2.0.6",
"hasInstallScript": true,
"license": "ISC",
"optional": true,
"dependencies": {