add support for speechmatics asr (#920)

* update to verb specs with speechmatics support

* discover local ip using os module
This commit is contained in:
Dave Horton
2024-10-11 09:24:36 -04:00
committed by GitHub
parent c67499e38b
commit 84b7456c2d
3 changed files with 24 additions and 23 deletions

View File

@@ -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');
}