Spaces:
Sleeping
Sleeping
import streamlit as st | |
from transformers import pipeline | |
from langdetect import detect | |
# Initialize models | |
summarizer = pipeline("summarization") | |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ur") | |
grammar_corrector = pipeline("text2text-generation", model="vennify/t5-base-grammar-correction") | |
st.set_page_config(page_title="CSS AI Assistant by Komal", layout="wide") | |
st.title("π CSS AI Assistant π΅π°") | |
st.write("Helping students with news summaries, precis, essays & more β for free!") | |
menu = st.sidebar.radio("Select Feature", [ | |
"Daily News Summary", | |
"Precis Evaluation", | |
"Essay Feedback", | |
"Saved Notes" | |
]) | |
# --- Daily News Summary --- | |
if menu == "Daily News Summary": | |
st.header("π° AI-Powered News Summarizer") | |
user_news = st.text_area("Paste or write today's news:", height=200) | |
lang = st.radio("Language", ["English", "Urdu"]) | |
if st.button("Summarize") and user_news: | |
summary = summarizer(user_news, max_length=100, min_length=30, do_sample=False)[0]['summary_text'] | |
if lang == "Urdu": | |
translation = translator(summary)[0]['translation_text'] | |
st.success("Summary in Urdu:") | |
st.write(translation) | |
else: | |
st.success("Summary in English:") | |
st.write(summary) | |
# --- Precis Evaluation --- | |
elif menu == "Precis Evaluation": | |
st.header("βοΈ Precis Evaluation Tool") | |
precis_input = st.text_area("Enter your precis for evaluation:", height=200) | |
if st.button("Evaluate Precis") and precis_input: | |
corrected = grammar_corrector("grammar: " + precis_input)[ | |