Update app.py
Browse files
app.py
CHANGED
|
@@ -166,6 +166,18 @@ def identity_manager (frase, persona):
|
|
| 166 |
clean_output = frase
|
| 167 |
return clean_output
|
| 168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
# ------------------- HTTP (opcional, clientes puros) -------------------
|
| 170 |
# Si quieres, puedes a帽adir un endpoint HTTP POST /generate (FastAPI),
|
| 171 |
# pero con Gradio Client es suficiente para engine/local.
|
|
@@ -253,4 +265,20 @@ with gr.Blocks(title="Salamandra 7B Instruct 路 ZeroGPU",css=custom_css,theme=gr
|
|
| 253 |
concurrency_limit=1
|
| 254 |
)
|
| 255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
demo.queue(max_size=16).launch()
|
|
|
|
| 166 |
clean_output = frase
|
| 167 |
return clean_output
|
| 168 |
|
| 169 |
+
def free_narration (srt_final):
|
| 170 |
+
prompt = f"""Instrucci贸: Converteix aquesta audiodescripci贸 en una narraci贸 lliure breu, natural i coherent.,
|
| 171 |
+
input: {srt_final}
|
| 172 |
+
output:
|
| 173 |
+
"""
|
| 174 |
+
result = generate_advanced(prompt=prompt, system="", max_new_tokens=512, temperature=0.7, top_p=0.95)
|
| 175 |
+
if "assistant" in result:
|
| 176 |
+
clean_output = result.split("assistant", 1)[1].strip().split("\n")[0]
|
| 177 |
+
else:
|
| 178 |
+
clean_output = frase
|
| 179 |
+
return clean_output
|
| 180 |
+
|
| 181 |
# ------------------- HTTP (opcional, clientes puros) -------------------
|
| 182 |
# Si quieres, puedes a帽adir un endpoint HTTP POST /generate (FastAPI),
|
| 183 |
# pero con Gradio Client es suficiente para engine/local.
|
|
|
|
| 265 |
concurrency_limit=1
|
| 266 |
)
|
| 267 |
|
| 268 |
+
gr.Markdown('<h2 style="text-align:center">Narraci贸 lliure</h2>')
|
| 269 |
+
with gr.Row():
|
| 270 |
+
with gr.Column(scale=1):
|
| 271 |
+
srt = gr.Textbox(label="Audiodescripci贸", value="(AD)\nTOTS CANTANT: avui celebrem la nostra festa major\nAINA: som hi tots a ballar", lines=3)
|
| 272 |
+
btn_modificar = gr.Button("Generar audiodescripci贸", variant="primary")
|
| 273 |
+
with gr.Column(scale=1):
|
| 274 |
+
narraci贸_lliure = gr.Textbox(label="Narraci贸 lliure", lines=18)
|
| 275 |
+
|
| 276 |
+
btn_modificar.click(
|
| 277 |
+
free_narration,
|
| 278 |
+
inputs=[srt],
|
| 279 |
+
outputs=narraci贸_lliure,
|
| 280 |
+
api_name="narraci贸",
|
| 281 |
+
concurrency_limit=1
|
| 282 |
+
)
|
| 283 |
+
|
| 284 |
demo.queue(max_size=16).launch()
|