02-ago: [proyecto] vigilancia - teleprompter en la tele: video mp4 con el texto componiendose palabra a palabra sincronizado con la voz (edge-tts SentenceBoundary + ffmpeg via imageio-ffmpeg)

This commit is contained in:
minguezsanzjuanjose
2026-08-02 14:51:19 +02:00
parent c15800fb10
commit 67ff032eb2
2 changed files with 165 additions and 2 deletions

View File

@@ -82,6 +82,23 @@ def _descubrir():
pychromecast.discovery.stop_discovery(browser)
def _url_video(texto):
"""Genera el video teleprompter (texto que se compone mientras habla)."""
try:
from teleprompter import generar_video, sintetizar_con_oraciones
ruta_audio, oraciones = sintetizar_con_oraciones(texto)
if ruta_audio is None or not oraciones:
return None, None
ruta_video = generar_video(texto, ruta_audio, oraciones)
_arrancar_servidor()
if _server is None:
return None, None
return f"http://{_ip_lan()}:{config.GOOGLE_TV_PUERTO}/{os.path.basename(ruta_video)}", "video/mp4"
except Exception as e:
print(f"[Voz] No se pudo generar el video: {e}")
return None, None
def _url_audio(texto, nombre="anuncio.mp3"):
ruta = sintetizar(texto, nombre=nombre)
if ruta is None:
@@ -210,7 +227,10 @@ def anuncio_en_teles(texto):
mensaje y apaga por ADB."""
if not config.GOOGLE_TV_ACTIVO:
return
url_mensaje = _url_audio(texto)
url_mensaje, tipo_mensaje = _url_video(texto)
if url_mensaje is None:
url_mensaje = _url_audio(texto)
tipo_mensaje = "audio/mpeg"
if url_mensaje is None:
return
url_pitido = _url_pitido() if config.GOOGLE_TV_PITIDO_ACTIVO else None
@@ -251,7 +271,7 @@ def anuncio_en_teles(texto):
f"Pitido de emergencia en {c.cast_info.friendly_name}")
_reproducir_y_esperar(
c, url_mensaje, "audio/mpeg", texto[:80],
c, url_mensaje, tipo_mensaje, texto[:80],
f"Anuncio en {c.cast_info.friendly_name} "
f"(vol {config.GOOGLE_TV_VOLUMEN})")