Disable twotone decode for now

This commit is contained in:
Christopher Cookman 2026-07-29 07:19:54 -06:00
parent c285b5119c
commit 8ebcf2927d

View file

@ -152,31 +152,49 @@ conn.on("message", (data) => {
console.log(`New Call ${globalSystems[parsed[1].system][parsed[1].talkgroup].name} call #${parsed[1].id}`); console.log(`New Call ${globalSystems[parsed[1].system][parsed[1].talkgroup].name} call #${parsed[1].id}`);
const tgName = globalSystems[parsed[1].system][parsed[1].talkgroup].name; const tgName = globalSystems[parsed[1].system][parsed[1].talkgroup].name;
fs.writeFileSync(`./temp/${parsed[1].audioName}`, Buffer.from(parsed[1].audio.data)); fs.writeFileSync(`./temp/${parsed[1].audioName}`, Buffer.from(parsed[1].audio.data));
decodeTwoTone(`./temp/${parsed[1].audioName}`).then((result) => { // decodeTwoTone(`./temp/${parsed[1].audioName}`).then((result) => {
console.log(`Two-tone detection result for ${tgName}:`, result); // console.log(`Two-tone detection result for ${tgName}:`, result);
// Two tone result will be array of objects for each detected twotone activation. .detected is array of two frequencies, one for each tone. Create a counter for each pair of frequencies detected. Make a message to send to discord with the tone names, so if 2 copies of RC EMS are sent, send "RC EMS (2x)" instead. For multiple, send "RC EMS (2x), RC Fire (1x)" etc. // // Two tone result will be array of objects for each detected twotone activation. .detected is array of two frequencies, one for each tone. Create a counter for each pair of frequencies detected. Make a message to send to discord with the tone names, so if 2 copies of RC EMS are sent, send "RC EMS (2x)" instead. For multiple, send "RC EMS (2x), RC Fire (1x)" etc.
const toneCounts = {}; // const toneCounts = {};
for (const activation of result) { // for (const activation of result) {
const detected = activation.detected; // const detected = activation.detected;
const key = `${detected[0]}:${detected[1]}`; // const key = `${detected[0]}:${detected[1]}`;
if (toneCounts[key]) { // if (toneCounts[key]) {
toneCounts[key]++; // toneCounts[key]++;
} else { // } else {
toneCounts[key] = 1; // toneCounts[key] = 1;
} // }
} // }
const toneMessages = []; // const toneMessages = [];
for (const key in toneCounts) { // for (const key in toneCounts) {
const name = knownTones[key] || key; // const name = knownTones[key] || key;
const count = toneCounts[key]; // const count = toneCounts[key];
toneMessages.push(count > 1 ? `${name} (${count}x)` : name); // toneMessages.push(count > 1 ? `${name} (${count}x)` : name);
} // }
const message = toneMessages.join(", "); // const message = toneMessages.join(", ");
console.log(`Two-tone summary for ${tgName}:`, message); // console.log(`Two-tone summary for ${tgName}:`, message);
// hook.send({
// // Username is tg name
// username: globalSystems[parsed[1].system][parsed[1].talkgroup].name,
// content: `${message}`,
// // Upload audio file
// files: [{
// attachment: `./temp/${parsed[1].audioName}`,
// name: parsed[1].audioName
// }]
// }).then(() => {
// // Delete the audio file after sending to Discord
// fs.unlink(`./temp/${parsed[1].audioName}`, (err) => {
// if (err) {
// console.error(`Error deleting audio file: ${err}`);
// }
// });
// })
// }); // TwoTone breaks on my server. Will fix later (I think i need py 3.12 not 3.13)
hook.send({ hook.send({
// Username is tg name // Username is tg name
username: globalSystems[parsed[1].system][parsed[1].talkgroup].name, username: globalSystems[parsed[1].system][parsed[1].talkgroup].name,
content: `${message}`, // content: `${message}`,
// Upload audio file // Upload audio file
files: [{ files: [{
attachment: `./temp/${parsed[1].audioName}`, attachment: `./temp/${parsed[1].audioName}`,
@ -190,7 +208,6 @@ conn.on("message", (data) => {
} }
}); });
}) })
});
break; break;
default: default:
console.log("Unknown message:", JSON.stringify(parsed)); console.log("Unknown message:", JSON.stringify(parsed));