This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Timmy-time-dashboard/src/timmy/voice/activation.py

39 lines
926 B
Python

"""Voice activation detection — hallucination filtering and exit commands."""
from __future__ import annotations
# Whisper hallucinates these on silence/noise — skip them.
WHISPER_HALLUCINATIONS = frozenset(
{
"you",
"thanks.",
"thank you.",
"bye.",
"",
"thanks for watching!",
"thank you for watching!",
}
)
# Spoken phrases that end the voice session.
EXIT_COMMANDS = frozenset(
{
"goodbye",
"exit",
"quit",
"stop",
"goodbye timmy",
"stop listening",
}
)
def is_hallucination(text: str) -> bool:
"""Return True if *text* is a known Whisper hallucination."""
return not text or text.lower() in WHISPER_HALLUCINATIONS
def is_exit_command(text: str) -> bool:
"""Return True if the user asked to stop the voice session."""
return text.lower().strip().rstrip(".!") in EXIT_COMMANDS