Spaces:
Sleeping
Sleeping
| 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() | |