Bonosa2 commited on
Commit
3819c76
Β·
verified Β·
1 Parent(s): 52fef7a

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -50,7 +50,8 @@ st.markdown("""
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")
@@ -60,6 +61,11 @@ tone_prompt = get_voice_prompt_style(voice_label)
60
  font_size = st.sidebar.radio("Font Size", ["Normal", "Large"])
61
  font_class = "big-answer" if font_size == "Large" else ""
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.",
@@ -72,20 +78,22 @@ preview_lines = {
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:
79
- stream = client.text_to_speech.convert_as_stream(
80
  text=preview_line,
81
  voice_id=voice_id,
82
  model_id="eleven_multilingual_v2"
83
  )
84
- preview_audio = BytesIO()
85
- for chunk in stream:
86
- if isinstance(chunk, bytes):
87
- preview_audio.write(chunk)
88
- st.audio(preview_audio.getvalue())
 
 
89
  except Exception as e:
90
  st.warning("Voice preview unavailable.")
91
  logger.exception("🎧 Voice preview error")
@@ -211,4 +219,4 @@ if st.button("πŸ” Summarize"):
211
  st.audio(audio_path)
212
  else:
213
  st.error("❗ Audio file missing.")
214
- logger.warning(f"❌ Missing audio file: {audio_path}")
 
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
 
56
  # Voice selection
57
  st.sidebar.header("🎚️ Voice Settings")
 
61
  font_size = st.sidebar.radio("Font Size", ["Normal", "Large"])
62
  font_class = "big-answer" if font_size == "Large" else ""
63
 
64
+ # Add Bolt attribution to sidebar
65
+ st.sidebar.markdown("---")
66
+ st.sidebar.markdown("⚑ Made with [bolt.new](https://bolt.new)")
67
+
68
+
69
  # One-liners per voice
70
  preview_lines = {
71
  "grandma GG": "Back in my day, we didn’t need AI to sound this fabulous.",
 
78
 
79
  preview_line = preview_lines.get(voice_label, "Testing voice.")
80
  st.markdown(f"🎧 <b>{voice_label}</b> says:", unsafe_allow_html=True)
81
+ st.markdown(f"_{preview_line}_", unsafe_allow_html=True)
82
 
83
  # Stream preview audio (no autoplay)
84
  try:
85
+ audio_stream = client.text_to_speech.convert(
86
  text=preview_line,
87
  voice_id=voice_id,
88
  model_id="eleven_multilingual_v2"
89
  )
90
+
91
+ full_audio_content = b""
92
+ for chunk in audio_stream:
93
+ full_audio_content += chunk
94
+
95
+ st.audio(full_audio_content)
96
+
97
  except Exception as e:
98
  st.warning("Voice preview unavailable.")
99
  logger.exception("🎧 Voice preview error")
 
219
  st.audio(audio_path)
220
  else:
221
  st.error("❗ Audio file missing.")
222
+ logger.warning(f"❌ Missing audio file: {audio_path}")