support voxist stt (#1066)

* support voxist stt

* wip
This commit is contained in:
Hoan Luu Huu
2025-02-05 20:33:35 +07:00
committed by GitHub
parent 7105453d81
commit dbdc1cd43d
6 changed files with 71 additions and 0 deletions

View File

@@ -1084,6 +1084,12 @@ class CallSession extends Emitter {
api_key: credential.api_key api_key: credential.api_key
}; };
} }
else if ('voxist' === vendor) {
return {
speech_credential_sid: credential.speech_credential_sid,
api_key: credential.api_key
};
}
else if ('whisper' === vendor) { else if ('whisper' === vendor) {
return { return {
api_key: credential.api_key, api_key: credential.api_key,

View File

@@ -11,6 +11,7 @@ const {
NvidiaTranscriptionEvents, NvidiaTranscriptionEvents,
JambonzTranscriptionEvents, JambonzTranscriptionEvents,
AssemblyAiTranscriptionEvents, AssemblyAiTranscriptionEvents,
VoxistTranscriptionEvents,
VadDetection, VadDetection,
VerbioTranscriptionEvents, VerbioTranscriptionEvents,
SpeechmaticsTranscriptionEvents SpeechmaticsTranscriptionEvents
@@ -524,6 +525,17 @@ class TaskGather extends SttTask {
this._onVendorConnectFailure.bind(this, cs, ep)); this._onVendorConnectFailure.bind(this, cs, ep));
break; break;
case 'voxist':
this.bugname = `${this.bugname_prefix}voxist_transcribe`;
this.addCustomEventListener(ep, VoxistTranscriptionEvents.Transcription,
this._onTranscription.bind(this, cs, ep));
this.addCustomEventListener(
ep, VoxistTranscriptionEvents.Connect, this._onVendorConnect.bind(this, cs, ep));
this.addCustomEventListener(ep, VoxistTranscriptionEvents.Error, this._onVendorError.bind(this, cs, ep));
this.addCustomEventListener(ep, VoxistTranscriptionEvents.ConnectFailure,
this._onVendorConnectFailure.bind(this, cs, ep));
break;
case 'speechmatics': case 'speechmatics':
this.bugname = `${this.bugname_prefix}speechmatics_transcribe`; this.bugname = `${this.bugname_prefix}speechmatics_transcribe`;
this.addCustomEventListener( this.addCustomEventListener(

View File

@@ -13,6 +13,7 @@ const {
JambonzTranscriptionEvents, JambonzTranscriptionEvents,
TranscribeStatus, TranscribeStatus,
AssemblyAiTranscriptionEvents, AssemblyAiTranscriptionEvents,
VoxistTranscriptionEvents,
VerbioTranscriptionEvents, VerbioTranscriptionEvents,
SpeechmaticsTranscriptionEvents SpeechmaticsTranscriptionEvents
} = require('../utils/constants.json'); } = require('../utils/constants.json');
@@ -300,6 +301,17 @@ class TaskTranscribe extends SttTask {
this._onVendorConnectFailure.bind(this, cs, ep, channel)); this._onVendorConnectFailure.bind(this, cs, ep, channel));
break; break;
case 'voxist':
this.bugname = `${this.bugname_prefix}voxist_transcribe`;
this.addCustomEventListener(ep, VoxistTranscriptionEvents.Transcription,
this._onTranscription.bind(this, cs, ep, channel));
this.addCustomEventListener(ep,
VoxistTranscriptionEvents.Connect, this._onVendorConnect.bind(this, cs, ep));
this.addCustomEventListener(ep, VoxistTranscriptionEvents.Error, this._onVendorError.bind(this, cs, ep));
this.addCustomEventListener(ep, VoxistTranscriptionEvents.ConnectFailure,
this._onVendorConnectFailure.bind(this, cs, ep, channel));
break;
case 'speechmatics': case 'speechmatics':
this.bugname = `${this.bugname_prefix}speechmatics_transcribe`; this.bugname = `${this.bugname_prefix}speechmatics_transcribe`;
this.addCustomEventListener( this.addCustomEventListener(

View File

@@ -149,6 +149,12 @@
"ConnectFailure": "assemblyai_transcribe::connect_failed", "ConnectFailure": "assemblyai_transcribe::connect_failed",
"Connect": "assemblyai_transcribe::connect" "Connect": "assemblyai_transcribe::connect"
}, },
"VoxistTranscriptionEvents": {
"Transcription": "voxist_transcribe::transcription",
"Error": "voxist_transcribe::error",
"ConnectFailure": "voxist_transcribe::connect_failed",
"Connect": "voxist_transcribe::connect"
},
"VadDetection": { "VadDetection": {
"Detection": "vad_detect:detection" "Detection": "vad_detect:detection"
}, },

View File

@@ -122,6 +122,10 @@ const speechMapper = (cred) => {
const o = JSON.parse(decrypt(credential)); const o = JSON.parse(decrypt(credential));
obj.api_key = o.api_key; obj.api_key = o.api_key;
} }
else if ('voxist' === obj.vendor) {
const o = JSON.parse(decrypt(credential));
obj.api_key = o.api_key;
}
else if ('whisper' === obj.vendor) { else if ('whisper' === obj.vendor) {
const o = JSON.parse(decrypt(credential)); const o = JSON.parse(decrypt(credential));
obj.api_key = o.api_key; obj.api_key = o.api_key;

View File

@@ -105,6 +105,9 @@ const stickyVars = {
'ASSEMBLYAI_API_KEY', 'ASSEMBLYAI_API_KEY',
'ASSEMBLYAI_WORD_BOOST' 'ASSEMBLYAI_WORD_BOOST'
], ],
voxist: [
'VOXIST_API_KEY',
],
speechmatics: [ speechmatics: [
'SPEECHMATICS_API_KEY', 'SPEECHMATICS_API_KEY',
'SPEECHMATICS_HOST', 'SPEECHMATICS_HOST',
@@ -517,6 +520,25 @@ const normalizeAssemblyAi = (evt, channel, language) => {
}; };
}; };
const normalizeVoxist = (evt, channel, language) => {
const copy = JSON.parse(JSON.stringify(evt));
return {
language_code: language,
channel_tag: channel,
is_final: evt.type === 'final',
alternatives: [
{
confidence: 1.00,
transcript: evt.text,
}
],
vendor: {
name: 'voxist',
evt: copy
}
};
};
const normalizeSpeechmatics = (evt, channel, language) => { const normalizeSpeechmatics = (evt, channel, language) => {
const copy = JSON.parse(JSON.stringify(evt)); const copy = JSON.parse(JSON.stringify(evt));
const is_final = evt.message === 'AddTranscript'; const is_final = evt.message === 'AddTranscript';
@@ -567,6 +589,8 @@ module.exports = (logger) => {
return normalizeCobalt(evt, channel, language); return normalizeCobalt(evt, channel, language);
case 'assemblyai': case 'assemblyai':
return normalizeAssemblyAi(evt, channel, language, shortUtterance); return normalizeAssemblyAi(evt, channel, language, shortUtterance);
case 'voxist':
return normalizeVoxist(evt, channel, language);
case 'verbio': case 'verbio':
return normalizeVerbio(evt, channel, language); return normalizeVerbio(evt, channel, language);
case 'speechmatics': case 'speechmatics':
@@ -926,6 +950,13 @@ module.exports = (logger) => {
{ASSEMBLYAI_WORD_BOOST: JSON.stringify(rOpts.hints)}) {ASSEMBLYAI_WORD_BOOST: JSON.stringify(rOpts.hints)})
}; };
} }
else if ('voxist' === vendor) {
opts = {
...opts,
...(sttCredentials.api_key) &&
{VOXIST_API_KEY: sttCredentials.api_key},
};
}
else if ('verbio' === vendor) { else if ('verbio' === vendor) {
const {verbioOptions = {}} = rOpts; const {verbioOptions = {}} = rOpts;
opts = { opts = {