zoya23's picture
Update app.py
9f7fe30 verified
raw
history blame
1.64 kB
import streamlit as st
from agents.api_agent import get_asia_tech_risk
from agents.scrapping_agent import get_earnings_news
from agents.analysis_agent import get_aum_change, earnings_summary
from agents.language_agent import generate_brief
from agents.voice_agent import speech_to_text, text_to_speech
st.title("🧠 Morning Market Brief - Voice Assistant")
st.markdown("### Choose input mode")
input_mode = st.radio("Select input type:", ("🎤 Voice", "⌨️ Text"))
user_query = ""
if input_mode == "🎤 Voice":
uploaded_audio = st.file_uploader("Upload your voice (WAV format)", type=["wav"])
if uploaded_audio is not None:
st.audio(uploaded_audio, format='audio/wav')
user_query = speech_to_text(uploaded_audio)
st.success(f"Transcribed Query: **{user_query}**")
elif input_mode == "⌨️ Text":
user_query = st.text_input("Ask:", "What’s our risk exposure in Asia tech stocks today, and highlight any earnings surprises?")
if st.button("Get Market Brief"):
if user_query.strip() == "":
st.warning("Please provide a question.")
else:
# Fake output for now – plug in RAG later
response = """
Today, your Asia tech allocation is 22% of AUM, up from 18% yesterday.
TSMC beat estimates by 4%, Samsung missed by 2%.
Regional sentiment is neutral with a cautionary tilt due to rising yields.
"""
st.subheader("📊 Market Summary")
st.write(response)
audio_path = text_to_speech(response)
with open(audio_path, "rb") as audio_file:
st.audio(audio_file.read(), format="audio/mp3")