File size: 1,748 Bytes
bce1255
f4b0447
 
 
 
 
bce1255
7e5aa7c
9f7fe30
7e5aa7c
9f7fe30
 
7e5aa7c
df16bec
8009a79
9f7fe30
 
 
 
 
 
df16bec
9f7fe30
df16bec
9f7fe30
 
df16bec
9f7fe30
df16bec
 
 
 
 
 
 
 
 
 
9f7fe30
df16bec
9f7fe30
df16bec
 
9f7fe30
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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 = ""

# INPUT
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 your market question", "What’s our risk exposure in Asia tech stocks today, and highlight any earnings surprises?")

# LOGIC
if st.button("Get Market Brief"):
    if user_query.strip() == "":
        st.warning("Please provide a valid question.")
    else:
        # get data from agents
        asia_risk = get_asia_tech_risk()
        earnings = get_earnings_news()
        aum = get_aum_change()
        earnings_summary_text = earnings_summary()
        
        # generate smart summary
        final_summary = generate_brief(user_query, asia_risk, earnings, aum, earnings_summary_text)

        # show
        st.subheader("📊 Market Summary")
        st.write(final_summary)

        # speak
        audio_path = text_to_speech(final_summary)
        with open(audio_path, "rb") as audio_file:
            st.audio(audio_file.read(), format="audio/mp3")