Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,13 @@ from transformers import pipeline
|
|
| 3 |
|
| 4 |
summarizer = pipeline("summarization", model="IonutBot/mt5-ro-summarizer")
|
| 5 |
|
|
|
|
|
|
|
| 6 |
def rezuma_text(text, lungime):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
summary = summarizer(
|
| 8 |
text,
|
| 9 |
max_length=lungime,
|
|
@@ -13,6 +19,8 @@ def rezuma_text(text, lungime):
|
|
| 13 |
)
|
| 14 |
return summary[0]['summary_text']
|
| 15 |
|
|
|
|
|
|
|
| 16 |
gr.Interface(
|
| 17 |
fn=rezuma_text,
|
| 18 |
inputs=[gr.Textbox(label="Text de rezumat"), gr.Slider(50, 300, value=150, label="Lungime maximă")],
|
|
|
|
| 3 |
|
| 4 |
summarizer = pipeline("summarization", model="IonutBot/mt5-ro-summarizer")
|
| 5 |
|
| 6 |
+
from langdetect import detect
|
| 7 |
+
|
| 8 |
def rezuma_text(text, lungime):
|
| 9 |
+
lang = detect(text)
|
| 10 |
+
if lang != "ro":
|
| 11 |
+
return f"Textul detectat este în limba '{lang}', dar aplicația funcționează doar cu texte în limba română."
|
| 12 |
+
|
| 13 |
summary = summarizer(
|
| 14 |
text,
|
| 15 |
max_length=lungime,
|
|
|
|
| 19 |
)
|
| 20 |
return summary[0]['summary_text']
|
| 21 |
|
| 22 |
+
|
| 23 |
+
|
| 24 |
gr.Interface(
|
| 25 |
fn=rezuma_text,
|
| 26 |
inputs=[gr.Textbox(label="Text de rezumat"), gr.Slider(50, 300, value=150, label="Lungime maximă")],
|