Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
29 |
-
if st.button("
|
30 |
-
|
31 |
-
st.
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
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)
|