Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,37 +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.set_page_config(page_title="🧠
|
9 |
st.title("🧠 Morning Market Brief - Voice Assistant")
|
10 |
|
11 |
-
st.markdown("Ask:
|
12 |
|
13 |
input_mode = st.radio("Choose input mode", ["🎤 Voice", "⌨️ Button"])
|
14 |
|
15 |
query = ""
|
16 |
-
if input_mode == "
|
|
|
|
|
|
|
|
|
17 |
if st.button("Get Market Brief"):
|
18 |
-
query = "What
|
19 |
|
20 |
if query:
|
21 |
-
# --- Run all agents ---
|
22 |
stocks = get_asia_tech_risk(['TSM', 'SSNLF'])
|
23 |
-
|
24 |
earnings = earnings_summary(stocks)
|
25 |
aum_change = get_aum_change(22, 18)
|
26 |
narrative = generate_brief(query)
|
27 |
|
28 |
-
# --- Construct final brief ---
|
29 |
final_brief = (
|
30 |
f"Today, your Asia tech allocation is 22% of AUM, up from 18% yesterday.\n\n"
|
31 |
f"Earnings Summary: {earnings}.\n\n"
|
32 |
-
f"Top Headlines:\n" + "\n".join([f"- {h}" for h in
|
33 |
f"{narrative}"
|
34 |
)
|
35 |
|
36 |
st.success(final_brief)
|
37 |
-
|
38 |
-
# --- Convert to speech and play ---
|
39 |
-
audio_path = text_to_speech(final_brief)
|
40 |
-
with open(audio_path, "rb") as audio_file:
|
41 |
-
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)
|
|
|
|
|
|
|
|