Bonosa2 commited on
Commit
52fef7a
Β·
verified Β·
1 Parent(s): 284d850

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -46
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 + bolt badge
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("""<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)
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't need AI to sound this fabulous.",
94
  "tech wizard": "System online. You may now enter your query, human.",
95
- "perky sidekick": "You got this! Let's answer that question together!",
96
- "bill the newscaster": "Breaking news β€” you've just selected the perfect voice.",
97
- "spunky charlie": "Whoa! Is it story time already? Let's go!",
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"_"{preview_line}"_", unsafe_allow_html=True)
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
- st.subheader("πŸ“œ Answer")
234
- st.success(st.session_state.answer)
235
-
236
- if st.session_state.audio_key:
237
- audio_path = os.path.join(AUDIO_DIR, f"{st.session_state.audio_key}.mp3")
238
- if os.path.exists(audio_path):
239
- st.audio(audio_path)
240
- else:
241
- st.error("❗ Audio file missing.")
242
- logger.warning(f"❌ Missing audio file: {audio_path}")
 
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}")