02-ago: [proyecto] vigilancia - Fase 1: sirena wail estilo Proteccion Civil (400-1000Hz, 8s) + Fase 2: titulo ALERTA rojo parpadeante en el teleprompter

This commit is contained in:
minguezsanzjuanjose
2026-08-02 15:11:11 +02:00
parent 0ad6dac79e
commit fbfc395f3b
4 changed files with 45 additions and 6 deletions

View File

@@ -64,6 +64,27 @@ def sintetizar_con_oraciones(texto, nombre="anuncio.mp3"):
return ruta, oraciones
_TITULO_COLORES = {
"red": (255, 30, 30),
"rojo": (255, 30, 30),
"rosa": (255, 105, 180),
"pink": (255, 105, 180),
}
def _dibujar_titulo(d, t, font_title):
"""Titulo parpadeante en mayusculas (rojo/rosa) en la parte superior."""
titulo = config.TV_TITULO.upper()
if not titulo:
return
if config.TV_TITULO_PARPADEO and int(t * 2) % 2 == 1:
return
color = _TITULO_COLORES.get(config.TV_TITULO_COLOR, (255, 30, 30))
ancho = d.textlength(titulo, font=font_title)
x = (W - ancho) // 2
d.text((x, 30), titulo, fill=color, font=font_title)
def _palabras(oraciones):
"""Distribuye las palabras dentro de cada frase por longitud."""
palabras = []
@@ -90,6 +111,7 @@ def generar_video(texto, ruta_audio, oraciones, nombre="anuncio.mp4"):
n_frames = int(total * FPS)
font = ImageFont.truetype(FUENTE, 52) if FUENTE else ImageFont.load_default()
font_title = ImageFont.truetype(FUENTE, 96) if FUENTE else ImageFont.load_default()
gap = 18
# agrupar en lineas
@@ -120,6 +142,7 @@ def generar_video(texto, ruta_audio, oraciones, nombre="anuncio.mp4"):
t = i / FPS
img = Image.new("RGB", (W, H), (8, 8, 8))
d = ImageDraw.Draw(img)
_dibujar_titulo(d, t, font_title)
y = H // 2 - (len(lineas) // 2) * 80 + 30
for linea_words in lineas:
x = 40
@@ -150,6 +173,7 @@ def generar_video_texto_final(texto, segundos, nombre="texto_final.mp4"):
ruta_video = os.path.join(os.path.dirname(os.path.abspath(__file__)),
"voz_media", nombre)
font = ImageFont.truetype(FUENTE, 52) if FUENTE else ImageFont.load_default()
font_title = ImageFont.truetype(FUENTE, 96) if FUENTE else ImageFont.load_default()
gap = 18
lineas = []
@@ -178,6 +202,7 @@ def generar_video_texto_final(texto, segundos, nombre="texto_final.mp4"):
for i in range(n_frames):
img = Image.new("RGB", (W, H), (8, 8, 8))
d = ImageDraw.Draw(img)
_dibujar_titulo(d, i / FPS, font_title)
y = H // 2 - (len(lineas) // 2) * 80 + 30
for linea_words in lineas:
x = 40