Spaces:
Sleeping
Sleeping
Tu Nombre commited on
Commit ·
85ef151
1
Parent(s): 254bc2a
anade prompt automatico que faltaba
Browse files
app.py
CHANGED
|
@@ -151,6 +151,26 @@ def generar_guion(texto_base, estilo, duracion=60):
|
|
| 151 |
continue
|
| 152 |
raise last_err if last_err else Exception("Sin keys Groq")
|
| 153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
# ========== VOZ ==========
|
| 155 |
async def generar_voz(guion, idioma="es", genero="masculina", pais=""):
|
| 156 |
voces = VOCES.get(idioma, VOCES["es"]).get(genero, ["es-ES-AlvaroNeural"])
|
|
@@ -512,6 +532,10 @@ async def ep_video(request: Request):
|
|
| 512 |
from nichos import detectar_nicho
|
| 513 |
nicho_detectado = detectar_nicho(guion)
|
| 514 |
print(f"[Fenix] Nicho detectado: {nicho_detectado}", flush=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
for e in escenas:
|
| 516 |
if e.get("prompt","").strip() and not e.get("prompt_manual","").strip():
|
| 517 |
e["prompt_manual"] = e["prompt"].strip()
|
|
|
|
| 151 |
continue
|
| 152 |
raise last_err if last_err else Exception("Sin keys Groq")
|
| 153 |
|
| 154 |
+
|
| 155 |
+
def prompt_visual_auto(texto_escena):
|
| 156 |
+
if not texto_escena or not texto_escena.strip():
|
| 157 |
+
texto_escena = "cinematic atmospheric scene"
|
| 158 |
+
instruccion = ("Eres un director de fotografia. Crea UN prompt visual en INGLES, "
|
| 159 |
+
"cinematografico y concreto, para un clip que ilustre esta frase. "
|
| 160 |
+
"Solo el prompt, sin comillas, max 40 palabras. Frase: " + texto_escena)
|
| 161 |
+
for modelo in ["llama-3.1-8b-instant", "llama-3.3-70b-versatile"]:
|
| 162 |
+
for k in GROQ_KEYS:
|
| 163 |
+
try:
|
| 164 |
+
client = Groq(api_key=k)
|
| 165 |
+
res = client.chat.completions.create(
|
| 166 |
+
messages=[{"role":"user","content":instruccion}], model=modelo, temperature=0.8)
|
| 167 |
+
return res.choices[0].message.content.strip().strip('"')
|
| 168 |
+
except Exception as e:
|
| 169 |
+
if "rate_limit" in str(e).lower() or "429" in str(e): continue
|
| 170 |
+
if "model" in str(e).lower() or "decommission" in str(e).lower(): break
|
| 171 |
+
continue
|
| 172 |
+
return texto_escena
|
| 173 |
+
|
| 174 |
# ========== VOZ ==========
|
| 175 |
async def generar_voz(guion, idioma="es", genero="masculina", pais=""):
|
| 176 |
voces = VOCES.get(idioma, VOCES["es"]).get(genero, ["es-ES-AlvaroNeural"])
|
|
|
|
| 532 |
from nichos import detectar_nicho
|
| 533 |
nicho_detectado = detectar_nicho(guion)
|
| 534 |
print(f"[Fenix] Nicho detectado: {nicho_detectado}", flush=True)
|
| 535 |
+
for e in escenas:
|
| 536 |
+
if not e.get("prompt","").strip():
|
| 537 |
+
e["prompt"] = prompt_visual_auto(e.get("texto","") or e.get("narracion",""))
|
| 538 |
+
print("[Fenix] Prompt auto generado", flush=True)
|
| 539 |
for e in escenas:
|
| 540 |
if e.get("prompt","").strip() and not e.get("prompt_manual","").strip():
|
| 541 |
e["prompt_manual"] = e["prompt"].strip()
|