mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-19 04:17:44 +00:00
support assemblyai v3 (#1265)
* support assemblyai v3 * wip * wip * wip * wip * wip * wip
This commit is contained in:
@@ -1119,7 +1119,8 @@ class CallSession extends Emitter {
|
|||||||
else if ('assemblyai' === vendor) {
|
else if ('assemblyai' === vendor) {
|
||||||
return {
|
return {
|
||||||
speech_credential_sid: credential.speech_credential_sid,
|
speech_credential_sid: credential.speech_credential_sid,
|
||||||
api_key: credential.api_key
|
api_key: credential.api_key,
|
||||||
|
service_version: credential.service_version
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if ('voxist' === vendor) {
|
else if ('voxist' === vendor) {
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ const speechMapper = (cred) => {
|
|||||||
else if ('assemblyai' === obj.vendor) {
|
else if ('assemblyai' === 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;
|
||||||
|
obj.service_version = o.service_version;
|
||||||
}
|
}
|
||||||
else if ('voxist' === obj.vendor) {
|
else if ('voxist' === obj.vendor) {
|
||||||
const o = JSON.parse(decrypt(credential));
|
const o = JSON.parse(decrypt(credential));
|
||||||
|
|||||||
@@ -523,16 +523,27 @@ const normalizeAws = (evt, channel, language) => {
|
|||||||
|
|
||||||
const normalizeAssemblyAi = (evt, channel, language) => {
|
const normalizeAssemblyAi = (evt, channel, language) => {
|
||||||
const copy = JSON.parse(JSON.stringify(evt));
|
const copy = JSON.parse(JSON.stringify(evt));
|
||||||
|
const alternatives = [];
|
||||||
|
let is_final = false;
|
||||||
|
if (evt.type && evt.type === 'Turn') {
|
||||||
|
// v3 is here
|
||||||
|
alternatives.push({
|
||||||
|
confidence: evt.end_of_turn_confidence,
|
||||||
|
transcript: evt.transcript,
|
||||||
|
});
|
||||||
|
is_final = evt.end_of_turn;
|
||||||
|
} else {
|
||||||
|
alternatives.push({
|
||||||
|
confidence: evt.confidence,
|
||||||
|
transcript: evt.text,
|
||||||
|
});
|
||||||
|
is_final = evt.message_type === 'FinalTranscript';
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
language_code: language,
|
language_code: language,
|
||||||
channel_tag: channel,
|
channel_tag: channel,
|
||||||
is_final: evt.message_type === 'FinalTranscript',
|
is_final,
|
||||||
alternatives: [
|
alternatives,
|
||||||
{
|
|
||||||
confidence: evt.confidence,
|
|
||||||
transcript: evt.text,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
vendor: {
|
vendor: {
|
||||||
name: 'assemblyai',
|
name: 'assemblyai',
|
||||||
evt: copy
|
evt: copy
|
||||||
@@ -1018,8 +1029,28 @@ module.exports = (logger) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if ('assemblyai' === vendor) {
|
else if ('assemblyai' === vendor) {
|
||||||
|
const serviceVersion = rOpts.assemblyAiOptions?.serviceVersion || sttCredentials.service_version || 'v2';
|
||||||
|
const {
|
||||||
|
format_turns,
|
||||||
|
end_of_turn_confidence_threshold,
|
||||||
|
min_end_of_turn_silence_when_confident,
|
||||||
|
max_turn_silence
|
||||||
|
} = rOpts.assemblyAiOptions || {};
|
||||||
opts = {
|
opts = {
|
||||||
...opts,
|
...opts,
|
||||||
|
ASSEMBLYAI_API_VERSION: serviceVersion,
|
||||||
|
...(serviceVersion === 'v3' && {
|
||||||
|
...(format_turns && {
|
||||||
|
ASSEMBLYAI_FORMAT_TURNS: format_turns
|
||||||
|
}),
|
||||||
|
...(end_of_turn_confidence_threshold && {
|
||||||
|
ASSEMBLYAI_END_OF_TURN_CONFIDENCE_THRESHOLD: end_of_turn_confidence_threshold
|
||||||
|
}),
|
||||||
|
ASSEMBLYAI_MIN_END_OF_TURN_SILENCE_WHEN_CONFIDENT: min_end_of_turn_silence_when_confident || 500,
|
||||||
|
...(max_turn_silence && {
|
||||||
|
ASSEMBLYAI_MAX_TURN_SILENCE: max_turn_silence
|
||||||
|
}),
|
||||||
|
}),
|
||||||
...(sttCredentials.api_key) &&
|
...(sttCredentials.api_key) &&
|
||||||
{ASSEMBLYAI_API_KEY: sttCredentials.api_key},
|
{ASSEMBLYAI_API_KEY: sttCredentials.api_key},
|
||||||
...(rOpts.hints?.length > 0 &&
|
...(rOpts.hints?.length > 0 &&
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -18,7 +18,7 @@
|
|||||||
"@jambonz/speech-utils": "^0.2.13",
|
"@jambonz/speech-utils": "^0.2.13",
|
||||||
"@jambonz/stats-collector": "^0.1.10",
|
"@jambonz/stats-collector": "^0.1.10",
|
||||||
"@jambonz/time-series": "^0.2.13",
|
"@jambonz/time-series": "^0.2.13",
|
||||||
"@jambonz/verb-specifications": "^0.0.105",
|
"@jambonz/verb-specifications": "^0.0.106",
|
||||||
"@modelcontextprotocol/sdk": "^1.9.0",
|
"@modelcontextprotocol/sdk": "^1.9.0",
|
||||||
"@opentelemetry/api": "^1.8.0",
|
"@opentelemetry/api": "^1.8.0",
|
||||||
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
||||||
@@ -1505,9 +1505,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@jambonz/verb-specifications": {
|
"node_modules/@jambonz/verb-specifications": {
|
||||||
"version": "0.0.105",
|
"version": "0.0.106",
|
||||||
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.105.tgz",
|
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.106.tgz",
|
||||||
"integrity": "sha512-MD6RMJyXMoHpR7Wl3xmYmU54P0eF/9LNywRNNsdkAmSf0EogFqSJft4xD/yGeRWlO5O6eAYZEJdaMQeLSxitcg==",
|
"integrity": "sha512-xBCGKKW5QC7ItZyeF22esytpG2yIhkGWIvBgTaf97CilQmUdLGo3rWG3i7qnRvU9MPXFCtVCMt/aaMt1Ep6V2g==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
"@jambonz/speech-utils": "^0.2.13",
|
"@jambonz/speech-utils": "^0.2.13",
|
||||||
"@jambonz/stats-collector": "^0.1.10",
|
"@jambonz/stats-collector": "^0.1.10",
|
||||||
"@jambonz/time-series": "^0.2.13",
|
"@jambonz/time-series": "^0.2.13",
|
||||||
"@jambonz/verb-specifications": "^0.0.105",
|
"@jambonz/verb-specifications": "^0.0.106",
|
||||||
"@modelcontextprotocol/sdk": "^1.9.0",
|
"@modelcontextprotocol/sdk": "^1.9.0",
|
||||||
"@opentelemetry/api": "^1.8.0",
|
"@opentelemetry/api": "^1.8.0",
|
||||||
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user