Feature: add digitCount to amd-utils (#1111)

* add digitCount to amd-utils

* linting

* bump verb-specs
This commit is contained in:
Sam Machin
2025-03-06 17:01:51 +00:00
committed by GitHub
parent 8b8283e603
commit 3120dbc3e0
3 changed files with 20 additions and 8 deletions

View File

@@ -45,6 +45,7 @@ if (VMD_HINTS_FILE) {
});
}
class Amd extends Emitter {
constructor(logger, cs, opts) {
super();
@@ -68,6 +69,8 @@ class Amd extends Emitter {
this.getIbmAccessToken = getIbmAccessToken;
const {setChannelVarsForStt} = require('./transcription-utils')(logger);
this.setChannelVarsForStt = setChannelVarsForStt;
this.digitCount = opts.digitCount || 0;
this.numberRegEx = RegExp(`[0-9]{${this.digitCount}}`);
const {
noSpeechTimeoutMs = 5000,
@@ -163,6 +166,14 @@ class Amd extends Emitter {
language: t.language_code
});
}
else if (this.digitCount != 0 && this.numberRegEx.test(t.alternatives[0].transcript)) {
/* a string of numbers is typically a machine */
this.emit(this.decision = AmdEvents.MachineDetected, {
reason: 'digit count',
greeting: t.alternatives[0].transcript,
language: t.language_code
});
}
else if (final && wordCount < this.thresholdWordCount) {
/* a short greeting is typically a human */
this.emit(this.decision = AmdEvents.HumanDetected, {

15
package-lock.json generated
View File

@@ -18,7 +18,7 @@
"@jambonz/speech-utils": "^0.2.3",
"@jambonz/stats-collector": "^0.1.10",
"@jambonz/time-series": "^0.2.13",
"@jambonz/verb-specifications": "^0.0.97",
"@jambonz/verb-specifications": "^0.0.98",
"@opentelemetry/api": "^1.8.0",
"@opentelemetry/exporter-jaeger": "^1.23.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.50.0",
@@ -1550,9 +1550,9 @@
}
},
"node_modules/@jambonz/verb-specifications": {
"version": "0.0.97",
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.97.tgz",
"integrity": "sha512-CncykmCwc8YZcDYwFDq88n6IAyoQNae3lSF2BI5etoBKMujzxOty227lq6zgeXun9UYYDy/CONk5MiLO29kcBg==",
"version": "0.0.98",
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.98.tgz",
"integrity": "sha512-G55q5JGtbdowj+hBVBlApBsMBwG4rneJqUc1jcp/IksrlPlUjxMZURXi6jxmg87lZSX/u88osoG2olXnFhYU3g==",
"license": "MIT",
"dependencies": {
"debug": "^4.3.4",
@@ -3647,9 +3647,10 @@
}
},
"node_modules/drachtio-srf": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/drachtio-srf/-/drachtio-srf-5.0.2.tgz",
"integrity": "sha512-tM4TVNoC3IpdmpNn2gnuIp5AzNF6Ik6rvRTFjmQ25/W4gb4eVzK8cCYntc00rtbENI4HHmrX4Ep+/T+ZVnoTDw==",
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/drachtio-srf/-/drachtio-srf-5.0.3.tgz",
"integrity": "sha512-gOeOmU3LsrDXAw8a9Vd+od6cJXyqqV5E+2LsCD2N1SjoJybJS72PHTN+GfKtk3fRhFYpww2325CO4pr/DK21cA==",
"license": "MIT",
"dependencies": {
"debug": "^3.2.7",
"delegates": "^0.1.0",

View File

@@ -33,7 +33,7 @@
"@jambonz/realtimedb-helpers": "^0.8.8",
"@jambonz/speech-utils": "^0.2.3",
"@jambonz/stats-collector": "^0.1.10",
"@jambonz/verb-specifications": "^0.0.97",
"@jambonz/verb-specifications": "^0.0.98",
"@jambonz/time-series": "^0.2.13",
"@opentelemetry/api": "^1.8.0",
"@opentelemetry/exporter-jaeger": "^1.23.0",