-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui.py
More file actions
66 lines (50 loc) · 2.18 KB
/
gui.py
File metadata and controls
66 lines (50 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
import streamlit as st
from utils import fetch_topic_data, generate_podcast_script, generate_audio_file, logger
import datetime
st.set_page_config(page_title="WhisperCast - AI Podcast Generator")
st.markdown("""
<h2 style="text-align: center; margin: 0; padding: 0; margin-top: -2rem;">WhisperCast</h2>
<p style="text-align: center; margin: 0; padding: 0; margin-top: 10px; margin-left: -10px; margin-bottom: 3rem;">Turn your ideas into podcasts in no time!</p>
""", unsafe_allow_html=True)
topic = st.text_input("What's the topic for this podcast?", placeholder="e.g. 'The Future of Space Travel'")
generate = st.button("🚀 Generate Podcast")
log_area = st.empty()
if generate and topic:
log_buffer = []
def log(msg, level="info"):
log_buffer.append(f"> {msg}")
log_area.code("\n".join(log_buffer), language="bash")
try:
# Step 1: Fetch data
log("Fetching topic data")
content = fetch_topic_data(topic)
log("Topic data fetched")
# Step 2: Generate script
log("Generating podcast script...")
script = generate_podcast_script(topic, content)
if not script:
log("Script generation failed ❌", "error")
st.error("Script generation failed.")
st.stop()
log("Podcast script generated")
# Step 3: Generate audio
log("Generating audio file...")
audio_path = generate_audio_file(script, topic.capitalize())
if not audio_path:
log("Audio generation failed", "error")
st.error("Audio generation failed.")
st.stop()
log("Podcast audio ready")
# Step 4: Output results
st.success("🎧 Your podcast is ready!")
st.audio(audio_path)
with open(audio_path, "rb") as f:
st.download_button("Download MP3", f, file_name=os.path.basename(audio_path))
with st.expander("📜 View Transcript"):
st.markdown(script)
except Exception as e:
log(f"Something went wrong: {e}", "error")
st.error("Oops! Failed to generate podcast. Check logs above.")
elif generate and not topic:
st.warning("Please enter a topic to begin.")