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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deterministic frequency → station mapping.
|
| 2 |
+
|
| 3 |
+
Each station defines:
|
| 4 |
+
- system_prompt: compact persona + opening anchor (the fine-tune already knows
|
| 5 |
+
the style; short prompts = fast first token on CPU)
|
| 6 |
+
- user_prompt: the "on air" cue in the station's native language
|
| 7 |
+
- voice: animalese voice parameters (pitch, jitter, waveform)
|
| 8 |
+
- theme: visual identity (display glow color, flicker rhythm)
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
STATION_TOLERANCE = 0.3 # MHz — within ±0.3 counts as "on station"
|
| 12 |
+
LOCK_TOLERANCE = 0.05 # MHz — perfect tuning
|
| 13 |
+
NEAR_TOLERANCE = 0.45 # MHz — beyond this: static only
|
| 14 |
+
|
| 15 |
+
USER_PROMPT_EN = "Write tonight's transmission. On-air script only."
|
| 16 |
+
|
| 17 |
+
# No verbose "rules" in the system prompt: the fine-tune already knows the
|
| 18 |
+
# radio format (markers, length, the [FIN DE TRANSMISION] sign-off), and a 1B
|
| 19 |
+
# model recites instruction-shaped text on air. We only give it the persona +
|
| 20 |
+
# a language cue + the opening line it should start from (that opening is the
|
| 21 |
+
# strongest, leak-safe steering lever — if echoed, it is correct output).
|
| 22 |
+
def _prompt_es(persona: str, apertura: str) -> str:
|
| 23 |
+
return f"{persona}\nEscribes el guion al aire en español. Empiezas con: {apertura}"
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def _prompt_en(persona: str, opening: str) -> str:
|
| 27 |
+
return f"{persona}\nYou write the on-air script in English. You begin with: {opening}"
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
# Language directives: the listener picks the broadcast language.
|
| 31 |
+
# Short and declarative on purpose — a verbose "translate... example: [JINGLE]
|
| 32 |
+
# ..." block is exactly the kind of instruction-shaped text a 1B model recites
|
| 33 |
+
# on air. The fine-tune now covers ES/EN/FR, so one clean line is enough; the
|
| 34 |
+
# swapped opening + the user prompt do the heavy steering.
|
| 35 |
+
LANG_DIRECTIVES = {
|
| 36 |
+
"es": "Hablas y escribes solo en español, nunca en inglés.",
|
| 37 |
+
"en": "You speak and write only in English, never in Spanish. Translate every line into English.",
|
| 38 |
+
"fr": "Tu parles et écris uniquement en français, jamais en espagnol. Traduis chaque ligne en français.",
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
# On-air cue per language: this is the last thing the model reads, so it is
|
| 42 |
+
# the strongest lever to pull the generation into the requested language.
|
| 43 |
+
USER_PROMPTS = {
|
| 44 |
+
"es": "Escribe la transmisión de esta noche. Solo el guion al aire.",
|
| 45 |
+
"en": "Write tonight's transmission, entirely in English. On-air script only.",
|
| 46 |
+
"fr": "Écris la transmission de ce soir, entièrement en français. Uniquement le script à l'antenne.",
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
SUPPORTED_LANGS = tuple(LANG_DIRECTIVES.keys())
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def normalize_lang(lang: str) -> str:
|
| 53 |
+
lang = str(lang or "es").lower()[:2]
|
| 54 |
+
return lang if lang in LANG_DIRECTIVES else "es"
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def localized_system_prompt(base_prompt: str, native_lang: str, lang: str) -> str:
|
| 58 |
+
"""When the listener asks for another language, wrap the persona with the
|
| 59 |
+
translation directive (before and after: small models obey anchors)."""
|
| 60 |
+
lang = normalize_lang(lang)
|
| 61 |
+
if lang == native_lang:
|
| 62 |
+
return base_prompt
|
| 63 |
+
directive = LANG_DIRECTIVES[lang]
|
| 64 |
+
return f"{directive} {base_prompt} {directive}"
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def localized_user_prompt(station: dict | None, lang: str) -> str:
|
| 68 |
+
"""On-air cue in the requested language (falls back to the station's own)."""
|
| 69 |
+
lang = normalize_lang(lang)
|
| 70 |
+
native = (station or {}).get("lang", "es")
|
| 71 |
+
if lang == native and station and station.get("user_prompt"):
|
| 72 |
+
return station["user_prompt"]
|
| 73 |
+
return USER_PROMPTS[lang]
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
# Same station frequency → same broadcast for every listener.
|
| 77 |
+
STATIONS: dict[float, dict] = {
|
| 78 |
+
87.6: {
|
| 79 |
+
"name": "Night Drive AM",
|
| 80 |
+
"lang": "en",
|
| 81 |
+
"system_prompt": _prompt_en(
|
| 82 |
+
persona=(
|
| 83 |
+
"You are the host of Night Drive AM, a late-night call-in show on an "
|
| 84 |
+
"empty highway between universes. Every caller tonight is, somehow, "
|
| 85 |
+
"the same person calling from different years of their life. Calm, "
|
| 86 |
+
"warm, slightly melancholic."
|
| 87 |
+
),
|
| 88 |
+
opening="[JINGLE] You're on Night Drive. Go ahead, caller.",
|
| 89 |
+
),
|
| 90 |
+
"user_prompt": USER_PROMPT_EN,
|
| 91 |
+
"voice": {"pitch_base": 110, "pitch_step": 4, "pitch_jitter": 12, "waveform": "sine"},
|
| 92 |
+
"theme": {"glow": "#ffb45e", "flicker": 0.25},
|
| 93 |
+
},
|
| 94 |
+
88.9: {
|
| 95 |
+
"name": "Radio Selenita — Tropical lunar",
|
| 96 |
+
"lang": "es",
|
| 97 |
+
"system_prompt": _prompt_es(
|
| 98 |
+
persona=(
|
| 99 |
+
"Eres el animador de Radio Selenita, la emisora tropical de un "
|
| 100 |
+
"Medellín que queda en la Luna: saludos con sabrosura paisa, cumbias, "
|
| 101 |
+
"cráteres, gravedad baja y vista a la Tierra."
|
| 102 |
+
),
|
| 103 |
+
apertura=(
|
| 104 |
+
"[JINGLE] ¡Quiubo pues, mi gente selenita! Desde el cráter de la 70 "
|
| 105 |
+
"les saluda su locutor de confianza."
|
| 106 |
+
),
|
| 107 |
+
),
|
| 108 |
+
"voice": {"pitch_base": 260, "pitch_step": 8, "pitch_jitter": 30, "waveform": "triangle"},
|
| 109 |
+
"theme": {"glow": "#7cfc9a", "flicker": 0.5},
|
| 110 |
+
},
|
| 111 |
+
91.7: {
|
| 112 |
+
"name": "WFifty — Locutor de los 50",
|
| 113 |
+
"lang": "es",
|
| 114 |
+
"system_prompt": _prompt_es(
|
| 115 |
+
persona=(
|
| 116 |
+
"Eres Don Aurelio, locutor estrella de una radio AM de los años 50 en "
|
| 117 |
+
"un universo paralelo. Narras EN VIVO, con voz cálida y melodramática, "
|
| 118 |
+
"la final municipal de ajedrez entre los gatos Bartolo y Misifú."
|
| 119 |
+
),
|
| 120 |
+
apertura=(
|
| 121 |
+
"[JINGLE] Buenas noches, queridos oyentes. Les habla Don Aurelio "
|
| 122 |
+
"desde el salón municipal."
|
| 123 |
+
),
|
| 124 |
+
),
|
| 125 |
+
"voice": {"pitch_base": 145, "pitch_step": 5, "pitch_jitter": 18, "waveform": "sawtooth"},
|
| 126 |
+
"theme": {"glow": "#ffd27c", "flicker": 0.35},
|
| 127 |
+
},
|
| 128 |
+
94.1: {
|
| 129 |
+
"name": "The Midnight Archive",
|
| 130 |
+
"lang": "en",
|
| 131 |
+
"system_prompt": _prompt_en(
|
| 132 |
+
persona=(
|
| 133 |
+
"You are the announcer of The Midnight Archive, a BBC-style service "
|
| 134 |
+
"that reads catalogue entries for objects lost between universes "
|
| 135 |
+
"(umbrellas that remember rain, keys to doors never built). Measured, "
|
| 136 |
+
"elegant, faintly haunted."
|
| 137 |
+
),
|
| 138 |
+
opening="[JINGLE] This is The Midnight Archive.",
|
| 139 |
+
),
|
| 140 |
+
"user_prompt": USER_PROMPT_EN,
|
| 141 |
+
"voice": {"pitch_base": 170, "pitch_step": 5, "pitch_jitter": 10, "waveform": "sine"},
|
| 142 |
+
"theme": {"glow": "#9ad8ff", "flicker": 0.2},
|
| 143 |
+
},
|
| 144 |
+
97.3: {
|
| 145 |
+
"name": "Júpiter FM — Boletín meteorológico",
|
| 146 |
+
"lang": "es",
|
| 147 |
+
"system_prompt": _prompt_es(
|
| 148 |
+
persona=(
|
| 149 |
+
"Eres la voz oficial del Servicio Meteorológico de Júpiter, año 2187: "
|
| 150 |
+
"tormentas de amoniaco, vientos de 900 km/h, la Gran Mancha Roja de "
|
| 151 |
+
"mal humor. Tono serio, casi poético."
|
| 152 |
+
),
|
| 153 |
+
apertura="[JINGLE] Servicio Meteorológico de Júpiter, parte de las 19 horas.",
|
| 154 |
+
),
|
| 155 |
+
"voice": {"pitch_base": 340, "pitch_step": 7, "pitch_jitter": 28, "waveform": "square"},
|
| 156 |
+
"theme": {"glow": "#ff8a5e", "flicker": 0.4},
|
| 157 |
+
},
|
| 158 |
+
99.9: {
|
| 159 |
+
"name": "La Hora Exacta",
|
| 160 |
+
"lang": "es",
|
| 161 |
+
"system_prompt": _prompt_es(
|
| 162 |
+
persona=(
|
| 163 |
+
"Eres la voz automática de La Hora Exacta, la estación que da la hora "
|
| 164 |
+
"en un universo donde el tiempo se rompió. Anuncias horas imposibles "
|
| 165 |
+
"con seriedad burocrática, como un reloj parlante averiado."
|
| 166 |
+
),
|
| 167 |
+
apertura="[JINGLE] Al tercer tono serán las veinticinco horas del martes pasado. ...Piiip.",
|
| 168 |
+
),
|
| 169 |
+
"voice": {"pitch_base": 420, "pitch_step": 3, "pitch_jitter": 6, "waveform": "square"},
|
| 170 |
+
"theme": {"glow": "#c6ff5e", "flicker": 0.15},
|
| 171 |
+
},
|
| 172 |
+
101.3: {
|
| 173 |
+
"name": "Deep Sea Lounge",
|
| 174 |
+
"lang": "en",
|
| 175 |
+
"system_prompt": _prompt_en(
|
| 176 |
+
persona=(
|
| 177 |
+
"You are the smooth-jazz DJ of Deep Sea Lounge, broadcasting from a "
|
| 178 |
+
"glass studio at the bottom of an ocean on a gas planet. Velvet voice, "
|
| 179 |
+
"unhurried, dedicating songs to creatures drifting past the window."
|
| 180 |
+
),
|
| 181 |
+
opening="[JINGLE] Mmm, welcome back to the Deep Sea Lounge.",
|
| 182 |
+
),
|
| 183 |
+
"user_prompt": USER_PROMPT_EN,
|
| 184 |
+
"voice": {"pitch_base": 95, "pitch_step": 4, "pitch_jitter": 14, "waveform": "sine"},
|
| 185 |
+
"theme": {"glow": "#6ec8ff", "flicker": 0.18},
|
| 186 |
+
},
|
| 187 |
+
103.5: {
|
| 188 |
+
"name": "Nube 103 — Comercial interdimensional",
|
| 189 |
+
"lang": "es",
|
| 190 |
+
"system_prompt": _prompt_es(
|
| 191 |
+
persona=(
|
| 192 |
+
"Eres el locutor publicitario de Nube 103, en un universo donde las "
|
| 193 |
+
"nubes se alquilan por hora. Vendes el plan 'Cumulonimbus Premium' "
|
| 194 |
+
"(sombra garantizada, llovizna opcional, truenos de cortesía) con "
|
| 195 |
+
"entusiasmo desbordado, estilo años 60."
|
| 196 |
+
),
|
| 197 |
+
apertura="[JINGLE] ¡Amigos! ¿Cansados de cielos vacíos?",
|
| 198 |
+
),
|
| 199 |
+
"voice": {"pitch_base": 230, "pitch_step": 6, "pitch_jitter": 22, "waveform": "square"},
|
| 200 |
+
"theme": {"glow": "#ffe97c", "flicker": 0.45},
|
| 201 |
+
},
|
| 202 |
+
106.1: {
|
| 203 |
+
"name": "Cocina Imposible",
|
| 204 |
+
"lang": "es",
|
| 205 |
+
"system_prompt": _prompt_es(
|
| 206 |
+
persona=(
|
| 207 |
+
"Eres la chef de Cocina Imposible: explicas paso a paso, con cariño "
|
| 208 |
+
"de abuela, recetas de ingredientes que no existen (sopa de ecos, pan "
|
| 209 |
+
"de sombra, mermelada de domingos)."
|
| 210 |
+
),
|
| 211 |
+
apertura="[JINGLE] Bienvenidos, mis amores, a Cocina Imposible.",
|
| 212 |
+
),
|
| 213 |
+
"voice": {"pitch_base": 290, "pitch_step": 6, "pitch_jitter": 24, "waveform": "triangle"},
|
| 214 |
+
"theme": {"glow": "#ffb0d8", "flicker": 0.3},
|
| 215 |
+
},
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
STATION_FREQUENCIES = sorted(STATIONS.keys())
|
| 219 |
+
|
| 220 |
+
# ------------------------------------------------------------------
|
| 221 |
+
# Special frequencies (app.py routes them before regular stations)
|
| 222 |
+
# ------------------------------------------------------------------
|
| 223 |
+
CURSED_FREQUENCY = 95.5 # the unsolvable station: it always arrives corrupted
|
| 224 |
+
|
| 225 |
+
CURSED_SYSTEM_PROMPT = (
|
| 226 |
+
"Eres una voz que transmite desde un lugar que ya no existe. Hablas en español, "
|
| 227 |
+
"en fragmentos inconexos y bellos: mitades de frases, nombres de personas que "
|
| 228 |
+
"nadie recuerda, coordenadas de sitios que no aparecen en los mapas, despedidas "
|
| 229 |
+
"sin destinatario. Nunca explicas nada. Nunca completas la idea. "
|
| 230 |
+
"Entre 50 y 80 palabras. Cierra con [FIN DE TRANSMISION]."
|
| 231 |
+
)
|
| 232 |
+
|
| 233 |
+
CURSED_VOICE = {"pitch_base": 80, "pitch_step": 3, "pitch_jitter": 40, "waveform": "sine"}
|
| 234 |
+
CURSED_THEME = {"glow": "#b9a4ff", "flicker": 0.8}
|
| 235 |
+
|
| 236 |
+
ENCRYPTED_VOICE = {"pitch_base": 600, "pitch_step": 0, "pitch_jitter": 0, "waveform": "sine"}
|
| 237 |
+
ENCRYPTED_THEME = {"glow": "#58ff8f", "flicker": 0.6}
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
def station_seed(frequency: float) -> int:
|
| 241 |
+
"""Deterministic per-frequency seed: same frequency → same broadcast."""
|
| 242 |
+
return int(round(frequency * 10)) * 7919 % (2**31 - 1)
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def nearest_station_frequency(frequency: float) -> float | None:
|
| 246 |
+
"""Canonical frequency of the nearest station, if within range."""
|
| 247 |
+
if not STATION_FREQUENCIES:
|
| 248 |
+
return None
|
| 249 |
+
nearest = min(STATION_FREQUENCIES, key=lambda f: abs(frequency - f))
|
| 250 |
+
if abs(frequency - nearest) > STATION_TOLERANCE:
|
| 251 |
+
return None
|
| 252 |
+
return nearest
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
def get_station(frequency: float) -> dict | None:
|
| 256 |
+
"""Returns the station when the frequency is within ±STATION_TOLERANCE."""
|
| 257 |
+
nearest = nearest_station_frequency(frequency)
|
| 258 |
+
if nearest is None:
|
| 259 |
+
return None
|
| 260 |
+
return STATIONS[nearest]
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
def signal_strength(frequency: float) -> float:
|
| 264 |
+
"""0 = no signal, 1 = perfect tuning (relative to the nearest station)."""
|
| 265 |
+
nearest = nearest_station_frequency(frequency)
|
| 266 |
+
if nearest is None:
|
| 267 |
+
# Very weak signal when a station is close but outside tuning tolerance
|
| 268 |
+
if not STATION_FREQUENCIES:
|
| 269 |
+
return 0.0
|
| 270 |
+
nearest_any = min(STATION_FREQUENCIES, key=lambda f: abs(frequency - f))
|
| 271 |
+
dist = abs(frequency - nearest_any)
|
| 272 |
+
if dist >= NEAR_TOLERANCE:
|
| 273 |
+
return 0.0
|
| 274 |
+
return max(0.0, 0.15 * (1 - dist / NEAR_TOLERANCE))
|
| 275 |
+
dist = abs(frequency - nearest)
|
| 276 |
+
if dist <= LOCK_TOLERANCE:
|
| 277 |
+
return 1.0
|
| 278 |
+
return max(0.0, 1.0 - (dist - LOCK_TOLERANCE) / (NEAR_TOLERANCE - LOCK_TOLERANCE))
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
# Opening lines per language. The opening is the strongest language anchor a
|
| 282 |
+
# 1B model has: swapping it pulls the whole broadcast into the target language.
|
| 283 |
+
STATION_OPENINGS = {
|
| 284 |
+
87.6: {
|
| 285 |
+
"en": "[JINGLE] You're on Night Drive. Go ahead, caller.",
|
| 286 |
+
"es": "[JINGLE] Estás en Night Drive. Adelante, oyente.",
|
| 287 |
+
"fr": "[JINGLE] Vous êtes sur Night Drive. Allez-y, on vous écoute.",
|
| 288 |
+
},
|
| 289 |
+
88.9: {
|
| 290 |
+
"es": "[JINGLE] ¡Quiubo pues, mi gente selenita! Desde el cráter de la 70 les saluda su locutor de confianza.",
|
| 291 |
+
"en": "[JINGLE] What's up, my lunar people! Greeting you from Crater 70, it's your trusted host.",
|
| 292 |
+
"fr": "[JINGLE] Salut la famille sélénite ! Depuis le cratère de la 70, votre animateur préféré vous salue.",
|
| 293 |
+
},
|
| 294 |
+
91.7: {
|
| 295 |
+
"es": "[JINGLE] Buenas noches, queridos oyentes. Les habla Don Aurelio desde el salón municipal.",
|
| 296 |
+
"en": "[JINGLE] Good evening, dear listeners. This is Don Aurelio, live from the municipal hall.",
|
| 297 |
+
"fr": "[JINGLE] Bonsoir, chers auditeurs. Ici Don Aurelio, en direct de la salle municipale.",
|
| 298 |
+
},
|
| 299 |
+
94.1: {
|
| 300 |
+
"en": "[JINGLE] This is The Midnight Archive.",
|
| 301 |
+
"es": "[JINGLE] Esto es El Archivo de Medianoche.",
|
| 302 |
+
"fr": "[JINGLE] Ici Les Archives de Minuit.",
|
| 303 |
+
},
|
| 304 |
+
97.3: {
|
| 305 |
+
"es": "[JINGLE] Servicio Meteorológico de Júpiter, parte de las 19 horas.",
|
| 306 |
+
"en": "[JINGLE] Jupiter Weather Service, 7 p.m. bulletin.",
|
| 307 |
+
"fr": "[JINGLE] Service météorologique de Jupiter, bulletin de 19 heures.",
|
| 308 |
+
},
|
| 309 |
+
99.9: {
|
| 310 |
+
"es": "[JINGLE] Al tercer tono serán las veinticinco horas del martes pasado. ...Piiip.",
|
| 311 |
+
"en": "[JINGLE] At the third tone, the time will be twenty-five o'clock last Tuesday. ...Beep.",
|
| 312 |
+
"fr": "[JINGLE] Au troisième bip, il sera vingt-cinq heures mardi dernier. ...Biiip.",
|
| 313 |
+
},
|
| 314 |
+
101.3: {
|
| 315 |
+
"en": "[JINGLE] Mmm, welcome back to the Deep Sea Lounge.",
|
| 316 |
+
"es": "[JINGLE] Mmm, bienvenidos de nuevo al Deep Sea Lounge.",
|
| 317 |
+
"fr": "[JINGLE] Mmm, bienvenue au Deep Sea Lounge.",
|
| 318 |
+
},
|
| 319 |
+
103.5: {
|
| 320 |
+
"es": "[JINGLE] ¡Amigos! ¿Cansados de cielos vacíos?",
|
| 321 |
+
"en": "[JINGLE] Friends! Tired of empty skies?",
|
| 322 |
+
"fr": "[JINGLE] Chers amis ! Fatigués des ciels vides ?",
|
| 323 |
+
},
|
| 324 |
+
106.1: {
|
| 325 |
+
"es": "[JINGLE] Bienvenidos, mis amores, a Cocina Imposible.",
|
| 326 |
+
"en": "[JINGLE] Welcome, my darlings, to Impossible Kitchen.",
|
| 327 |
+
"fr": "[JINGLE] Bienvenue, mes chéris, dans Cuisine Impossible.",
|
| 328 |
+
},
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
def station_system_prompt(canonical: float, lang: str) -> str:
|
| 333 |
+
"""Persona prompt with the opening swapped into the requested language."""
|
| 334 |
+
station = STATIONS[canonical]
|
| 335 |
+
base = station["system_prompt"]
|
| 336 |
+
native = station.get("lang", "es")
|
| 337 |
+
lang = normalize_lang(lang)
|
| 338 |
+
openings = STATION_OPENINGS.get(canonical, {})
|
| 339 |
+
if lang != native and openings.get(native) and openings.get(lang):
|
| 340 |
+
base = base.replace(openings[native], openings[lang])
|
| 341 |
+
return localized_system_prompt(base, native, lang)
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
# Station names per UI language (brand names stay, descriptors translate).
|
| 345 |
+
STATION_NAMES = {
|
| 346 |
+
87.6: {"es": "Night Drive AM", "en": "Night Drive AM", "fr": "Night Drive AM"},
|
| 347 |
+
88.9: {
|
| 348 |
+
"es": "Radio Selenita — Tropical lunar",
|
| 349 |
+
"en": "Radio Selenita — Lunar Tropical",
|
| 350 |
+
"fr": "Radio Sélénite — Tropicale lunaire",
|
| 351 |
+
},
|
| 352 |
+
91.7: {
|
| 353 |
+
"es": "WFifty — Locutor de los 50",
|
| 354 |
+
"en": "WFifty — 1950s Announcer",
|
| 355 |
+
"fr": "WFifty — Speaker des années 50",
|
| 356 |
+
},
|
| 357 |
+
94.1: {
|
| 358 |
+
"es": "The Midnight Archive",
|
| 359 |
+
"en": "The Midnight Archive",
|
| 360 |
+
"fr": "The Midnight Archive",
|
| 361 |
+
},
|
| 362 |
+
97.3: {
|
| 363 |
+
"es": "Júpiter FM — Boletín meteorológico",
|
| 364 |
+
"en": "Jupiter FM — Weather Bulletin",
|
| 365 |
+
"fr": "Jupiter FM — Bulletin météo",
|
| 366 |
+
},
|
| 367 |
+
99.9: {"es": "La Hora Exacta", "en": "The Exact Hour", "fr": "L'Heure Exacte"},
|
| 368 |
+
101.3: {"es": "Deep Sea Lounge", "en": "Deep Sea Lounge", "fr": "Deep Sea Lounge"},
|
| 369 |
+
103.5: {
|
| 370 |
+
"es": "Nube 103 — Comercial interdimensional",
|
| 371 |
+
"en": "Cloud 103 — Interdimensional Commercials",
|
| 372 |
+
"fr": "Nuage 103 — Pub interdimensionnelle",
|
| 373 |
+
},
|
| 374 |
+
106.1: {"es": "Cocina Imposible", "en": "Impossible Kitchen", "fr": "Cuisine Impossible"},
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
# CRT portrait of each frequency's announcer (served from /static/img).
|
| 378 |
+
PORTRAITS = {
|
| 379 |
+
87.6: "/static/img/st_876.webp",
|
| 380 |
+
88.9: "/static/img/st_889.webp",
|
| 381 |
+
91.7: "/static/img/st_917.webp",
|
| 382 |
+
94.1: "/static/img/st_941.webp",
|
| 383 |
+
97.3: "/static/img/st_973.webp",
|
| 384 |
+
99.9: "/static/img/st_999.webp",
|
| 385 |
+
101.3: "/static/img/st_1013.webp",
|
| 386 |
+
103.5: "/static/img/st_1035.webp",
|
| 387 |
+
106.1: "/static/img/st_1061.webp",
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
def station_catalog() -> dict:
|
| 392 |
+
"""Public station metadata (voice, name, visual theme) for the frontend."""
|
| 393 |
+
from decrypt import ENCRYPTED_FREQUENCY
|
| 394 |
+
|
| 395 |
+
catalog = {
|
| 396 |
+
str(freq): {
|
| 397 |
+
"name": data["name"],
|
| 398 |
+
"names": STATION_NAMES.get(freq, {"es": data["name"]}),
|
| 399 |
+
"lang": data.get("lang", "es"),
|
| 400 |
+
"voice": data["voice"],
|
| 401 |
+
"theme": data.get("theme", {"glow": "#7cfc00", "flicker": 0.3}),
|
| 402 |
+
"portrait": PORTRAITS.get(freq),
|
| 403 |
+
}
|
| 404 |
+
for freq, data in STATIONS.items()
|
| 405 |
+
}
|
| 406 |
+
catalog[str(ENCRYPTED_FREQUENCY)] = {
|
| 407 |
+
"name": "· – · · –",
|
| 408 |
+
"names": {"es": "· – · · –", "en": "· – · · –", "fr": "· – · · –"},
|
| 409 |
+
"lang": "es",
|
| 410 |
+
"voice": ENCRYPTED_VOICE,
|
| 411 |
+
"theme": ENCRYPTED_THEME,
|
| 412 |
+
"portrait": "/static/img/st_1047.webp",
|
| 413 |
+
"encrypted": True,
|
| 414 |
+
}
|
| 415 |
+
catalog[str(CURSED_FREQUENCY)] = {
|
| 416 |
+
"name": "· · · ?",
|
| 417 |
+
"names": {"es": "· · · ?", "en": "· · · ?", "fr": "· · · ?"},
|
| 418 |
+
"lang": "es",
|
| 419 |
+
"voice": CURSED_VOICE,
|
| 420 |
+
"theme": CURSED_THEME,
|
| 421 |
+
"portrait": "/static/img/st_955.webp",
|
| 422 |
+
"cursed": True,
|
| 423 |
+
}
|
| 424 |
+
return catalog
|