From d66a9e745b01bb8b6b570aeb79cfcb20c28dff6d Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sun, 12 Oct 2025 17:13:41 -0700 Subject: [PATCH] enhance --- config.template | 4 ++++ modules/radio.py | 14 +++++++++----- modules/settings.py | 6 +++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/config.template b/config.template index 2bb8a8d..65b8e1e 100644 --- a/config.template +++ b/config.template @@ -300,6 +300,10 @@ signalCycleLimit = 5 voxDetectionEnabled = False # description to use in the alert message voxDescription = VOX +useLocalVoxModel = False +voxLanguage = en-us +voxInputDevice = -1 + [fileMon] filemon_enabled = False diff --git a/modules/radio.py b/modules/radio.py index 09be9f7..00c390e 100644 --- a/modules/radio.py +++ b/modules/radio.py @@ -2,7 +2,7 @@ # detect signal strength and frequency of active channel if appears to be in use send to mesh network # depends on rigctld running externally as a network service # also can use VOX detection with a microphone and vosk speech to text to send voice messages to mesh network -# requires vosk and sounddevice python modules +# requires vosk and sounddevice python modules. download from https://alphacephei.com/vosk/models and unpack # 2024 Kelly Keeton K7MHI previousVoxState = False @@ -11,9 +11,14 @@ import asyncio if radio_detection_enabled: import socket - if voxDetectionEnabled: voxHoldTime = signalHoldTime + + if useLocalVoxModel: + voxModel = Model(lang=localVoxModelPath) # use built in model for specified language + else: + voxModel = Model(lang=voxLanguage) # use auto downloaded model for specified language + try: import sounddevice as sd # pip install sounddevice sudo apt install portaudio19-dev from vosk import Model, KaldiRecognizer # pip install vosk @@ -193,12 +198,11 @@ def make_vox_callback(loop, q): except RuntimeError: pass return vox_callback - -voxInputDevice = None + async def voxMonitor(): global previousVoxState, voxMsgQueue try: - model = Model(lang="en-us") + model = voxModel device_info = sd.query_devices(voxInputDevice, 'input') samplerate = 16000 logger.debug(f"RadioMon: VOX monitor started on device {device_info['name']} with samplerate {samplerate}") diff --git a/modules/settings.py b/modules/settings.py index cb2713f..8c872db 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -368,7 +368,11 @@ try: signalCycleLimit = config['radioMon'].getint('signalCycleLimit', 5) # default 5 cycles, used with SIGNAL_COOLDOWN voxDetectionEnabled = config['radioMon'].getboolean('voxDetectionEnabled', False) # default VOX detection disabled voxDescription = config['radioMon'].get('voxDescription', 'VOX') # default VOX detected audio message - + useLocalVoxModel = config['radioMon'].getboolean('useLocalVoxModel', False) # default False + localVoxModelPath = config['radioMon'].get('localVoxModelPath', 'no') # default models/vox.tflite + voxLanguage = config['radioMon'].get('voxLanguage', 'en-US') # default en-US + voxInputDevice = config['radioMon'].getint('voxInputDevice', -1) # default -1 use system default input device + # file monitor file_monitor_enabled = config['fileMon'].getboolean('filemon_enabled', False) file_monitor_file_path = config['fileMon'].get('file_path', 'alert.txt') # default alert.txt