From 84b7456c2da99f962f85be2d18086ddecf419e47 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Fri, 11 Oct 2024 09:24:36 -0400 Subject: [PATCH] add support for speechmatics asr (#920) * update to verb specs with speechmatics support * discover local ip using os module --- lib/utils/install-srf-locals.js | 19 ++++++++++++++++--- package-lock.json | 25 +++++++------------------ package.json | 3 +-- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/lib/utils/install-srf-locals.js b/lib/utils/install-srf-locals.js index e8f06521..b97a3d40 100644 --- a/lib/utils/install-srf-locals.js +++ b/lib/utils/install-srf-locals.js @@ -1,5 +1,5 @@ const Mrf = require('drachtio-fsmrf'); -const ip = require('ip'); +const os = require('os'); const { JAMBONES_MYSQL_HOST, JAMBONES_MYSQL_USER, @@ -18,6 +18,19 @@ const { const Registrar = require('@jambonz/mw-registrar'); const assert = require('assert'); +function getLocalIp() { + const interfaces = os.networkInterfaces(); + for (const interfaceName in interfaces) { + const interface = interfaces[interfaceName]; + for (const iface of interface) { + if (iface.family === 'IPv4' && !iface.internal) { + return iface.address; + } + } + } + return '127.0.0.1'; // Fallback to localhost if no suitable interface found +} + function initMS(logger, wrapper, ms) { Object.assign(wrapper, {ms, active: true, connects: 1}); logger.info(`connected to freeswitch at ${ms.address}`); @@ -195,8 +208,8 @@ function installSrfLocals(srf, logger) { let localIp; try { - // Either use the configured IP address or call ip.address() to find it - localIp = HTTP_IP || ip.address(); + // Either use the configured IP address or discover it + localIp = HTTP_IP || getLocalIp(); } catch (err) { logger.error({err}, 'installSrfLocals - error detecting local ipv4 address'); } diff --git a/package-lock.json b/package-lock.json index ba386314..daf31e9b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@jambonz/speech-utils": "^0.1.18", "@jambonz/stats-collector": "^0.1.10", "@jambonz/time-series": "^0.2.9", - "@jambonz/verb-specifications": "^0.0.81", + "@jambonz/verb-specifications": "^0.0.82", "@opentelemetry/api": "^1.8.0", "@opentelemetry/exporter-jaeger": "^1.23.0", "@opentelemetry/exporter-trace-otlp-http": "^0.50.0", @@ -35,7 +35,6 @@ "drachtio-srf": "^4.5.35", "express": "^4.19.2", "express-validator": "^7.0.1", - "ip": "^2.0.1", "moment": "^2.30.1", "parse-url": "^9.2.0", "pino": "^8.20.0", @@ -1575,9 +1574,9 @@ } }, "node_modules/@jambonz/verb-specifications": { - "version": "0.0.81", - "resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.81.tgz", - "integrity": "sha512-lufYMLpwaejF3zl8FNy1SvmsxFHXNXU8p7I+GoiwbgOHmFeOX4bQla4RD7bNLFvfjSXPRc2u9h5fceicVa9dcg==", + "version": "0.0.82", + "resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.82.tgz", + "integrity": "sha512-jgbu0nUXQOGz9Kd0h7gBOrykl2FoZkS7fg5MdNbvnMGO+D4bboBsNTYwGk0k+OSm0D8I7JUQoaFbuKBo8Cj0RA==", "dependencies": { "debug": "^4.3.4", "pino": "^8.8.0" @@ -5632,11 +5631,6 @@ "url": "https://opencollective.com/ioredis" } }, - "node_modules/ip": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", - "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==" - }, "node_modules/ip6addr": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/ip6addr/-/ip6addr-0.2.5.tgz", @@ -10538,9 +10532,9 @@ } }, "@jambonz/verb-specifications": { - "version": "0.0.81", - "resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.81.tgz", - "integrity": "sha512-lufYMLpwaejF3zl8FNy1SvmsxFHXNXU8p7I+GoiwbgOHmFeOX4bQla4RD7bNLFvfjSXPRc2u9h5fceicVa9dcg==", + "version": "0.0.82", + "resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.82.tgz", + "integrity": "sha512-jgbu0nUXQOGz9Kd0h7gBOrykl2FoZkS7fg5MdNbvnMGO+D4bboBsNTYwGk0k+OSm0D8I7JUQoaFbuKBo8Cj0RA==", "requires": { "debug": "^4.3.4", "pino": "^8.8.0" @@ -13645,11 +13639,6 @@ "standard-as-callback": "^2.1.0" } }, - "ip": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", - "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==" - }, "ip6addr": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/ip6addr/-/ip6addr-0.2.5.tgz", diff --git a/package.json b/package.json index 2a9fc867..071c4a1f 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@jambonz/speech-utils": "^0.1.18", "@jambonz/stats-collector": "^0.1.10", "@jambonz/time-series": "^0.2.9", - "@jambonz/verb-specifications": "^0.0.81", + "@jambonz/verb-specifications": "^0.0.82", "@opentelemetry/api": "^1.8.0", "@opentelemetry/exporter-jaeger": "^1.23.0", "@opentelemetry/exporter-trace-otlp-http": "^0.50.0", @@ -51,7 +51,6 @@ "drachtio-srf": "^4.5.35", "express": "^4.19.2", "express-validator": "^7.0.1", - "ip": "^2.0.1", "moment": "^2.30.1", "parse-url": "^9.2.0", "pino": "^8.20.0",