File size: 2,352 Bytes
a31f556
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# backend/voice/tts_router.py
# Β§0.4 β€” Locked TTS Engine Routing Rule (Single Source of Truth)
# select_engine(context) is the ONLY place that decides which engine is used.
# No other file in OMEGA decides this. All callers pass a ResponseContext.

from dataclasses import dataclass
from enum import Enum

class TTSEngine(Enum):
    KOKORO      = "kokoro"       # Fast system notifications & alerts
    XTTS        = "xtts"         # Conversational JARVIS/FRIDAY speaking
    CHATTERBOX  = "chatterbox"   # Cinematic / pre-rendered / scripted content

@dataclass
class ResponseContext:
    type: str = "conversation"   # Default: real JARVIS/FRIDAY speaking

# ── Locked routing rule ────────────────────────────────────────────────────────
def select_engine(context: ResponseContext) -> TTSEngine:
    """
    Final, locked routing rule.
    Cinematic β†’ Chatterbox
    System notifications & alerts β†’ Kokoro (fast, functional)
    Everything else (JARVIS/FRIDAY actually speaking) β†’ XTTS (tuned profile)
    """
    # Cinematic / scripted β€” never in the live wake-word loop
    if context.type in ("scripted_intro", "demo_narration", "storytelling"):
        return TTSEngine.CHATTERBOX

    # System notifications & alerts β€” fast, functional, breaks immersion intentionally
    # These are system events, not JARVIS "speaking" in character
    if context.type in (
        "usb_device_alert",        # device connected/ejected
        "vault_backup_complete",   # vault build finished
        "vault_backup_started",
        "automation_status",       # automation running/paused/failed/completed
        "github_commit_status",    # commit success/failure
        "system_warning",          # low disk, connection lost, etc.
        "upgrade_notification",    # "Feature implemented" toast-paired speech
        "research_alert",          # safety/critical research alert
        "quick_command_ack",       # "Done." "Lights on." style acks
    ):
        return TTSEngine.KOKORO

    # Everything else: actual JARVIS/FRIDAY speaking β€” conversation, AR/automation
    # speak() actions with personality, space-change acknowledgements, OSINT results,
    # internet summaries read aloud, etc.
    return TTSEngine.XTTS