02-ago: [proyecto] vigilancia - bucle de mensaje x3 (GOOGLE_TV_REPETICIONES) + texto final en pantalla 30s (GOOGLE_TV_TEXTO_FINAL_SG) antes de apagar

This commit is contained in:
minguezsanzjuanjose
2026-08-02 14:59:54 +02:00
parent 2b13da934e
commit 0ad6dac79e
4 changed files with 85 additions and 4 deletions

View File

@@ -99,6 +99,22 @@ def _url_video(texto):
return None, None
def _url_texto_final(texto):
"""Video estatico con el texto completo (al final del bucle)."""
if config.GOOGLE_TV_TEXTO_FINAL_SG <= 0:
return None
try:
from teleprompter import generar_video_texto_final
ruta = generar_video_texto_final(texto, config.GOOGLE_TV_TEXTO_FINAL_SG)
_arrancar_servidor()
if _server is None:
return None
return f"http://{_ip_lan()}:{config.GOOGLE_TV_PUERTO}/{os.path.basename(ruta)}"
except Exception as e:
print(f"[Voz] No se pudo generar el texto final: {e}")
return None
def _url_audio(texto, nombre="anuncio.mp3"):
ruta = sintetizar(texto, nombre=nombre)
if ruta is None:
@@ -229,6 +245,7 @@ def anuncio_en_teles(texto):
return
url_pitido = _url_pitido() if config.GOOGLE_TV_PITIDO_ACTIVO else None
url_silencio = _url_silencio() if url_pitido else None
url_final = _url_texto_final(texto)
try:
import pychromecast
@@ -264,10 +281,18 @@ def anuncio_en_teles(texto):
c, url_pitido, "audio/wav", "pitido",
f"Pitido de emergencia en {c.cast_info.friendly_name}")
_reproducir_y_esperar(
c, url_mensaje, tipo_mensaje, texto[:80],
f"Anuncio en {c.cast_info.friendly_name} "
f"(vol {config.GOOGLE_TV_VOLUMEN})")
rep = max(1, config.GOOGLE_TV_REPETICIONES)
for n in range(rep):
_reproducir_y_esperar(
c, url_mensaje, tipo_mensaje, texto[:80],
f"Anuncio {n + 1}/{rep} en {c.cast_info.friendly_name} "
f"(vol {config.GOOGLE_TV_VOLUMEN})")
if url_final:
_reproducir_y_esperar(
c, url_final, "video/mp4", "texto final",
f"Texto final {config.GOOGLE_TV_TEXTO_FINAL_SG}s en "
f"{c.cast_info.friendly_name}")
if config.GOOGLE_TV_APAGAR_VIA_ADB:
from tv_adb import apagar_tv