Safe Voice Commands for My Home Automation Server
Описание и применение
Система безопасного голосового управления домашней автоматикой использует предварительный фильтр регулярных выражений, чтобы разрешать только явно одобренные команды, а затем, при необходимости, обрабатывает варианты через LLM.
Задача
Voice assistants can misinterpret speech‑to‑text, potentially triggering dangerous actions; a deterministic gate was needed to allow only approved commands.
Результат
The system now safely processes voice commands, rejecting any that do not match the whitelist and only allowing a small, auditable set of actions.
Рабочий процесс
- 1. Create a JSON whitelist of regex patterns and corresponding actions.
- 2. Load the whitelist in the server code.
- 3. On receiving a transcript, iterate over the whitelist and test each pattern (case‑insensitive).
- 4. If a match is found, return the associated action and execute it (e.g., send MQTT or run a script).
- 5. If no match, call the LLM with a narrow prompt that lists allowed actions and expects one keyword or "unknown".
- 6. If the LLM returns a known action, execute it; otherwise reject the command and log a warning.
Доказательства
filter everything through a whitelist regular expression before handing the text to a language model
I kept the whitelist in a JSON file so I could edit it without touching code.
run the regex first, and only if it fails do I fall back to the LLM with a very narrow prompt
- Дата записи: 2026-10-17T13:56:08.295Z