import streamlit as st import requests from utils import ( fetch_from_web, analyze_sentiment, generate_comparative_sentiment, generate_final_report, get_summaries_by_sentiment, translate, text_to_speech, ) st.title("Company Sentiment Analyzer") company_name = st.text_input("Enter Company Name", "Tesla") model_provider = st.selectbox("Model Provider", options=["Ollama", "Groq"]) if st.button("Fetch Sentiment Data"): web_results = fetch_from_web(company_name) if "sources" not in web_results: return {"error": "No sources found."} sentiment_output = [ analyze_sentiment(article, model_provider) for article in web_results["sources"][:5] ] comparative_sentiment = generate_comparative_sentiment(sentiment_output) positive_summary, negative_summary, neutral_summary = get_summaries_by_sentiment( sentiment_output ) final_report = generate_final_report( positive_summary, negative_summary, neutral_summary, comparative_sentiment, model_provider, ) hindi_translation = translate(final_report, model_provider) audio_path = text_to_speech(hindi_translation) output_dict = { "company_name": company_name, "articles": sentiment_output, "comparative_sentiment": comparative_sentiment, "final_report": final_report, "hindi_translation": hindi_translation, "audio_url": audio_path, } st.subheader("Company Name") st.write(output_dict.get("company_name")) st.subheader("Final Report") st.write(output_dict.get("final_report")) st.subheader("🔊 Audio Output") audio_file = "output.mp3" if audio_file: st.audio(audio_file) except requests.exceptions.RequestException as e: st.error(f"Error fetching data: {e}") #