"""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
