zoya23 commited on
Commit
1f4f052
·
verified ·
1 Parent(s): 6639baf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -38
app.py CHANGED
@@ -5,45 +5,35 @@ from agents.analysis_agent import get_aum_change, earnings_summary
5
  from agents.language_agent import generate_brief
6
  from agents.voice_agent import speech_to_text, text_to_speech
7
 
 
8
  st.title("🧠 Morning Market Brief - Voice Assistant")
9
- st.markdown("### Choose input mode")
10
-
11
- input_mode = st.radio("Select input type:", ("🎤 Voice", "⌨️ Text"))
12
- user_query = ""
13
-
14
- # INPUT
15
- if input_mode == "🎤 Voice":
16
- uploaded_audio = st.file_uploader("Upload your voice (WAV format)", type=["wav"])
17
- if uploaded_audio is not None:
18
- st.audio(uploaded_audio, format='audio/wav')
19
- user_query = speech_to_text(uploaded_audio)
20
- st.success(f"Transcribed Query: **{user_query}**")
21
- elif input_mode == "⌨️ Text":
22
- user_query = st.text_input("Ask your market question", "What’s our risk exposure in Asia tech stocks today, and highlight any earnings surprises?")
23
-
24
 
 
25
 
 
26
 
27
-
28
- # LOGIC
29
- if st.button("Get Market Brief"):
30
- if user_query.strip() == "":
31
- st.warning("Please provide a valid question.")
32
- else:
33
- # get data from agents
34
- asia_risk = get_asia_tech_risk(['TSM', 'SSNLF'])
35
- earnings = get_earnings_news()
36
- aum = get_aum_change(22,18)
37
- earnings_summary_text = earnings_summary(asia_risk)
38
-
39
- # generate smart summary
40
- final_summary = generate_brief(user_query, asia_risk, earnings, aum, earnings_summary_text)
41
-
42
- # show
43
- st.subheader("📊 Market Summary")
44
- st.write(final_summary)
45
-
46
- # speak
47
- audio_path = text_to_speech(final_summary)
48
- with open(audio_path, "rb") as audio_file:
49
- st.audio(audio_file.read(), format="audio/mp3")
 
 
 
5
  from agents.language_agent import generate_brief
6
  from agents.voice_agent import speech_to_text, text_to_speech
7
 
8
+ st.set_page_config(page_title="🧠 Finance Assistant", layout="centered")
9
  st.title("🧠 Morning Market Brief - Voice Assistant")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
+ st.markdown("Ask: _What’s our risk exposure in Asia tech stocks today, and highlight any earnings surprises?_")
12
 
13
+ input_mode = st.radio("Choose input mode", ["🎤 Voice", "⌨️ Button"])
14
 
15
+ query = ""
16
+ if input_mode == "🎤 Voice":
17
+ if st.button("Record Voice"):
18
+ query = speech_to_text()
19
+ st.write("You said:", query)
20
+ else:
21
+ if st.button("Get Market Brief"):
22
+ query = "What's our risk exposure in Asia tech stocks today?"
23
+
24
+ if query:
25
+ stocks = get_asia_tech_risk(['TSM', 'SSNLF'])
26
+ news = get_earnings_news()
27
+ earnings = earnings_summary(stocks)
28
+ aum_change = get_aum_change(22, 18)
29
+ narrative = generate_brief(query)
30
+
31
+ final_brief = (
32
+ f"Today, your Asia tech allocation is 22% of AUM, up from 18% yesterday.\n\n"
33
+ f"Earnings Summary: {earnings}.\n\n"
34
+ f"Top Headlines:\n" + "\n".join([f"- {h}" for h in news]) + "\n\n"
35
+ f"{narrative}"
36
+ )
37
+
38
+ st.success(final_brief)
39
+ text_to_speech(final_brief)