Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,7 @@ client = ElevenLabs(api_key=ELEVENLABS_API_KEY)
|
|
22 |
st.set_page_config(page_title="Voice Agent Pro", page_icon="π§")
|
23 |
logger.info("π¬ Streamlit app started")
|
24 |
|
25 |
-
# Inject large fonts + tips
|
26 |
st.markdown("""
|
27 |
<style>
|
28 |
.big-title {
|
@@ -46,39 +46,11 @@ st.markdown("""
|
|
46 |
border-radius: 0.5em;
|
47 |
margin-bottom: 1em;
|
48 |
}
|
49 |
-
.bolt-badge {
|
50 |
-
position: fixed;
|
51 |
-
bottom: 20px;
|
52 |
-
right: 20px;
|
53 |
-
z-index: 1000;
|
54 |
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
55 |
-
color: white;
|
56 |
-
padding: 8px 16px;
|
57 |
-
border-radius: 25px;
|
58 |
-
font-size: 0.85em;
|
59 |
-
font-weight: 600;
|
60 |
-
text-decoration: none;
|
61 |
-
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
|
62 |
-
transition: all 0.3s ease;
|
63 |
-
display: flex;
|
64 |
-
align-items: center;
|
65 |
-
gap: 6px;
|
66 |
-
}
|
67 |
-
.bolt-badge:hover {
|
68 |
-
transform: translateY(-2px);
|
69 |
-
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
|
70 |
-
text-decoration: none;
|
71 |
-
color: white;
|
72 |
-
}
|
73 |
-
.bolt-icon {
|
74 |
-
font-size: 1.1em;
|
75 |
-
}
|
76 |
</style>
|
77 |
""", unsafe_allow_html=True)
|
78 |
|
79 |
st.markdown('<div class="big-title">π§ Voice Agent Pro</div>', unsafe_allow_html=True)
|
80 |
-
st.markdown(
|
81 |
-
|
82 |
|
83 |
# Voice selection
|
84 |
st.sidebar.header("ποΈ Voice Settings")
|
@@ -90,17 +62,17 @@ font_class = "big-answer" if font_size == "Large" else ""
|
|
90 |
|
91 |
# One-liners per voice
|
92 |
preview_lines = {
|
93 |
-
"grandma GG": "Back in my day, we didn
|
94 |
"tech wizard": "System online. You may now enter your query, human.",
|
95 |
-
"perky sidekick": "You got this! Let
|
96 |
-
"bill the newscaster": "Breaking news β you
|
97 |
-
"spunky charlie": "Whoa! Is it story time already? Let
|
98 |
"sassy teen": "Seriously? You better ask something cool."
|
99 |
}
|
100 |
|
101 |
preview_line = preview_lines.get(voice_label, "Testing voice.")
|
102 |
st.markdown(f"π§ <b>{voice_label}</b> says:", unsafe_allow_html=True)
|
103 |
-
st.markdown(f"_
|
104 |
|
105 |
# Stream preview audio (no autoplay)
|
106 |
try:
|
@@ -229,14 +201,14 @@ if st.button("π Summarize"):
|
|
229 |
logger.exception("π₯ GPT/audio failed")
|
230 |
|
231 |
# Output
|
232 |
-
if st.session_state.answer:
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
if st.session_state.audio_key:
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
|
|
22 |
st.set_page_config(page_title="Voice Agent Pro", page_icon="π§")
|
23 |
logger.info("π¬ Streamlit app started")
|
24 |
|
25 |
+
# Inject large fonts + tips
|
26 |
st.markdown("""
|
27 |
<style>
|
28 |
.big-title {
|
|
|
46 |
border-radius: 0.5em;
|
47 |
margin-bottom: 1em;
|
48 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
</style>
|
50 |
""", unsafe_allow_html=True)
|
51 |
|
52 |
st.markdown('<div class="big-title">π§ Voice Agent Pro</div>', unsafe_allow_html=True)
|
53 |
+
st.markdown('<div class="instructions">Ask a question <b>OR</b> paste a URL <b>OR</b> upload a file β and Iβll summarize it in bullet points with expressive AI narration!</div>', unsafe_allow_html=True)
|
|
|
54 |
|
55 |
# Voice selection
|
56 |
st.sidebar.header("ποΈ Voice Settings")
|
|
|
62 |
|
63 |
# One-liners per voice
|
64 |
preview_lines = {
|
65 |
+
"grandma GG": "Back in my day, we didnβt need AI to sound this fabulous.",
|
66 |
"tech wizard": "System online. You may now enter your query, human.",
|
67 |
+
"perky sidekick": "You got this! Letβs answer that question together!",
|
68 |
+
"bill the newscaster": "Breaking news β youβve just selected the perfect voice.",
|
69 |
+
"spunky charlie": "Whoa! Is it story time already? Letβs go!",
|
70 |
"sassy teen": "Seriously? You better ask something cool."
|
71 |
}
|
72 |
|
73 |
preview_line = preview_lines.get(voice_label, "Testing voice.")
|
74 |
st.markdown(f"π§ <b>{voice_label}</b> says:", unsafe_allow_html=True)
|
75 |
+
st.markdown(f"_β{preview_line}β_", unsafe_allow_html=True)
|
76 |
|
77 |
# Stream preview audio (no autoplay)
|
78 |
try:
|
|
|
201 |
logger.exception("π₯ GPT/audio failed")
|
202 |
|
203 |
# Output
|
204 |
+
if st.session_state.answer:
|
205 |
+
st.subheader("π Answer")
|
206 |
+
st.success(st.session_state.answer)
|
207 |
+
|
208 |
+
if st.session_state.audio_key:
|
209 |
+
audio_path = os.path.join(AUDIO_DIR, f"{st.session_state.audio_key}.mp3")
|
210 |
+
if os.path.exists(audio_path):
|
211 |
+
st.audio(audio_path)
|
212 |
+
else:
|
213 |
+
st.error("β Audio file missing.")
|
214 |
+
logger.warning(f"β Missing audio file: {audio_path}")
|