Spaces:
Sleeping
Sleeping
File size: 1,437 Bytes
420231f e6c42e8 ae2c20b 4dbe7ed f367670 4dbe7ed e6c42e8 229579e ae2c20b 17de251 ae2c20b 77ba057 e6c42e8 420231f d58f53a 420231f d58f53a 4a992a9 d58f53a 4a992a9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
import gradio as gr
from transformers import pipeline
from langdetect import detect
# Model de rezumare valid și public
summarizer = pipeline("summarization", model="csebuetnlp/mT5_multilingual_XLSum")
# Model de traducere valid pentru română → engleză
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ROMANCE-en")
def rezuma_text(text, lungime):
lang = detect(text)
if lang != "ro":
return f"⚠️ Textul detectat este în limba '{lang}', dar aplicația funcționează doar cu texte în limba română."
summary = summarizer(
text,
max_length=lungime,
min_length=int(lungime * 0.4),
do_sample=True,
temperature=0.7
)[0]['summary_text']
translated = translator(summary)[0]['translation_text']
return f"🔹 Rezumat în română:\n{summary}\n\n🔸 Traducere în engleză:\n{translated}"
gr.Interface(
fn=rezuma_text,
inputs=[
gr.Textbox(label="Text de rezumat"),
gr.Slider(50, 300, value=150, label="Lungime maximă")
],
outputs="text",
title="SmartRezumat",
description="AI care transformă texte lungi în rezumate scurte, în limba română",
css="""
body { background-color: #f5f5f5; }
.gradio-container { font-family: 'Segoe UI'; }
h1, h2 { color: #2c3e50; }
.input-textbox textarea { background-color: #ffffff; border-radius: 8px; }
"""
).launch()
|