Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,36 +6,40 @@ 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 |
-
|
10 |
st.markdown("### Choose input mode")
|
11 |
|
12 |
input_mode = st.radio("Select input type:", ("🎤 Voice", "⌨️ Text"))
|
13 |
-
|
14 |
user_query = ""
|
15 |
|
|
|
16 |
if input_mode == "🎤 Voice":
|
17 |
uploaded_audio = st.file_uploader("Upload your voice (WAV format)", type=["wav"])
|
18 |
if uploaded_audio is not None:
|
19 |
st.audio(uploaded_audio, format='audio/wav')
|
20 |
user_query = speech_to_text(uploaded_audio)
|
21 |
st.success(f"Transcribed Query: **{user_query}**")
|
22 |
-
|
23 |
elif input_mode == "⌨️ Text":
|
24 |
-
user_query = st.text_input("Ask
|
25 |
|
|
|
26 |
if st.button("Get Market Brief"):
|
27 |
if user_query.strip() == "":
|
28 |
-
st.warning("Please provide a question.")
|
29 |
else:
|
30 |
-
#
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
36 |
st.subheader("📊 Market Summary")
|
37 |
-
st.write(
|
38 |
|
39 |
-
|
|
|
40 |
with open(audio_path, "rb") as audio_file:
|
41 |
st.audio(audio_file.read(), format="audio/mp3")
|
|
|
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 |
+
# LOGIC
|
25 |
if st.button("Get Market Brief"):
|
26 |
if user_query.strip() == "":
|
27 |
+
st.warning("Please provide a valid question.")
|
28 |
else:
|
29 |
+
# get data from agents
|
30 |
+
asia_risk = get_asia_tech_risk()
|
31 |
+
earnings = get_earnings_news()
|
32 |
+
aum = get_aum_change()
|
33 |
+
earnings_summary_text = earnings_summary()
|
34 |
+
|
35 |
+
# generate smart summary
|
36 |
+
final_summary = generate_brief(user_query, asia_risk, earnings, aum, earnings_summary_text)
|
37 |
+
|
38 |
+
# show
|
39 |
st.subheader("📊 Market Summary")
|
40 |
+
st.write(final_summary)
|
41 |
|
42 |
+
# speak
|
43 |
+
audio_path = text_to_speech(final_summary)
|
44 |
with open(audio_path, "rb") as audio_file:
|
45 |
st.audio(audio_file.read(), format="audio/mp3")
|