Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,125 +4,119 @@ import feedparser
|
|
4 |
import streamlit as st
|
5 |
from functions import *
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
st.markdown(
|
10 |
-
"""
|
11 |
-
This app assists busy professionals with transcribing and summarizing Podcasts from [Listen Notes](https://www.listennotes.com/) website by following the below steps:
|
12 |
-
- Search for your desired podcast from the Listen Notes website and click on the "RSS" tab to generate a unique link to the podcast. Example shown below:
|
13 |
-
"""
|
14 |
-
)
|
15 |
-
|
16 |
-
col1, col2 = st.columns(2)
|
17 |
-
|
18 |
-
with col1:
|
19 |
-
|
20 |
-
st.image('RSS.png', caption = 'Click RSS')
|
21 |
-
|
22 |
-
with col2:
|
23 |
-
|
24 |
-
st.image('RSS_copy.png',caption='Copy RSS Link')
|
25 |
-
|
26 |
-
st.markdown(
|
27 |
-
"""
|
28 |
-
- Copy the generated link and paste in the sidebar on the left:
|
29 |
-
"""
|
30 |
-
)
|
31 |
-
|
32 |
-
pods = {}
|
33 |
-
|
34 |
-
# Left section - Input fields
|
35 |
-
st.sidebar.header("Podcast RSS Feeds")
|
36 |
-
|
37 |
-
# Input Box
|
38 |
-
podcast_url = st.sidebar.text_input('Please paste the podcast RSS feed link here')
|
39 |
-
|
40 |
-
latest_ep_button = st.sidebar.button("Get latest 5 Episodes")
|
41 |
-
|
42 |
-
# st.sidebar.markdown("**Note**: Podcast processing can take upto 5 mins, please be patient.")
|
43 |
-
|
44 |
-
if latest_ep_button is not False:
|
45 |
-
|
46 |
-
#Extract the list of episodes for the given podcast
|
47 |
-
podcast_feed = feedparser.parse(podcast_url)
|
48 |
-
|
49 |
-
for pod in podcast_feed.entries[:5]:
|
50 |
-
podcast_title = pod['title']
|
51 |
-
|
52 |
-
try:
|
53 |
-
podcast_image = pod['image']['href']
|
54 |
-
|
55 |
-
except:
|
56 |
-
podcast_image = ''
|
57 |
-
|
58 |
-
for i in pod['links']:
|
59 |
-
if i['type'] == 'audio/mpeg':
|
60 |
-
podcast_url = i['href']
|
61 |
-
|
62 |
-
pods.update({pod['title']:[podcast_url,podcast_image]})
|
63 |
-
|
64 |
-
#Get the most recent 5 episodes
|
65 |
-
podcast_five_titles = list(pods.keys())
|
66 |
-
|
67 |
-
# Dropdown box
|
68 |
-
st.sidebar.subheader("Available Podcasts Feeds")
|
69 |
-
|
70 |
-
selected_podcast = st.sidebar.selectbox("Select Podcast", options=podcast_five_titles,index=None,key='podcast_selection')
|
71 |
-
|
72 |
-
print(selected_podcast)
|
73 |
-
|
74 |
-
if selected_podcast is not None:
|
75 |
-
|
76 |
-
if 'podcast_selection' not in st.session_state:
|
77 |
-
st.session_state.podcast_selection = selected_podcast
|
78 |
-
|
79 |
-
print(selected_podcast)
|
80 |
-
|
81 |
-
st.sidebar.markdown("**Note**: Podcast processing can take upto 5 mins, please be patient.")
|
82 |
-
|
83 |
-
podcast_link = pods[st.session_state.podcast_selection][0]
|
84 |
-
podcast_image = pods[st.session_state.podcast_selection][1]
|
85 |
|
86 |
-
|
87 |
-
st.header("Newsletter Content")
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
92 |
|
93 |
-
|
94 |
-
col1, col2 = st.columns([7, 3])
|
95 |
|
96 |
-
|
97 |
-
podcast_info = process_podcast(podcast_link)
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
|
128 |
|
|
|
4 |
import streamlit as st
|
5 |
from functions import *
|
6 |
|
7 |
+
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
st.title("PodcastGPT Dashboard")
|
|
|
10 |
|
11 |
+
st.markdown(
|
12 |
+
"""
|
13 |
+
This app assists busy professionals with transcribing and summarizing Podcasts from [Listen Notes](https://www.listennotes.com/) website by following the below steps:
|
14 |
+
- Search for your desired podcast from the Listen Notes website and click on the "RSS" tab to generate a unique link to the podcast. Example shown below:
|
15 |
+
"""
|
16 |
+
)
|
17 |
|
18 |
+
col1, col2 = st.columns(2)
|
|
|
19 |
|
20 |
+
with col1:
|
|
|
21 |
|
22 |
+
st.image('RSS.png', caption = 'Click RSS')
|
23 |
+
|
24 |
+
with col2:
|
25 |
+
|
26 |
+
st.image('RSS_copy.png',caption='Copy RSS Link')
|
27 |
+
|
28 |
+
st.markdown(
|
29 |
+
"""
|
30 |
+
- Copy the generated link and paste in the sidebar on the left:
|
31 |
+
"""
|
32 |
+
)
|
33 |
+
|
34 |
+
pods = {}
|
35 |
+
|
36 |
+
# Left section - Input fields
|
37 |
+
st.sidebar.header("Podcast RSS Feeds")
|
38 |
+
|
39 |
+
# Input Box
|
40 |
+
podcast_url = st.sidebar.text_input('Please paste the podcast RSS feed link here')
|
41 |
+
|
42 |
+
latest_ep_button = st.sidebar.button("Get latest 5 Episodes")
|
43 |
+
|
44 |
+
# st.sidebar.markdown("**Note**: Podcast processing can take upto 5 mins, please be patient.")
|
45 |
+
|
46 |
+
if latest_ep_button:
|
47 |
+
# Extract the list of episodes for the given podcast
|
48 |
+
podcast_feed = feedparser.parse(podcast_url)
|
49 |
+
|
50 |
+
# Ensure you don't exceed the feed's length
|
51 |
+
num_episodes = min(len(podcast_feed.entries), 5)
|
52 |
+
|
53 |
+
for pod in podcast_feed.entries[:num_episodes]:
|
54 |
+
podcast_title = pod['title']
|
55 |
+
podcast_image = pod.get('image', {}).get('href', '')
|
56 |
+
|
57 |
+
episode_url = next((i['href'] for i in pod['links'] if i['type'] == 'audio/mpeg'), None)
|
58 |
+
|
59 |
+
pods[podcast_title] = [episode_url, podcast_image]
|
60 |
+
|
61 |
+
if pods:
|
62 |
+
# Dropdown box
|
63 |
+
st.sidebar.subheader("Available Podcasts Feeds")
|
64 |
+
podcast_five_titles = list(pods.keys())
|
65 |
+
selected_podcast = st.sidebar.selectbox("Select Podcast", options=podcast_five_titles)
|
66 |
+
|
67 |
+
if selected_podcast:
|
68 |
+
# Process selected podcast
|
69 |
+
podcast_link, podcast_image = pods[selected_podcast]
|
70 |
+
|
71 |
+
st.sidebar.markdown("**Note**: Podcast processing can take upto 5 mins, please be patient.")
|
72 |
+
|
73 |
+
podcast_link = pods[st.session_state.podcast_selection][0]
|
74 |
+
podcast_image = pods[st.session_state.podcast_selection][1]
|
75 |
+
|
76 |
+
# Right section - Newsletter content
|
77 |
+
st.header("Newsletter Content")
|
78 |
+
|
79 |
+
# Display the podcast title
|
80 |
+
st.subheader("Episode Title")
|
81 |
+
st.write(selected_podcast)
|
82 |
+
|
83 |
+
# Display the podcast summary and the cover image in a side-by-side layout
|
84 |
+
col1, col2 = st.columns([7, 3])
|
85 |
+
|
86 |
+
# Get podcast transcription and info
|
87 |
+
podcast_info = process_podcast(podcast_link)
|
88 |
+
|
89 |
+
with col1:
|
90 |
+
# Display the podcast episode summary
|
91 |
+
st.subheader("Podcast Episode Summary")
|
92 |
+
st.write(podcast_info['podcast_summary'])
|
93 |
+
|
94 |
+
if podcast_image:
|
95 |
+
with col2:
|
96 |
+
st.image(podcast_image, caption="Podcast Cover", width=300, use_column_width=True)
|
97 |
+
|
98 |
+
# Display the podcast guest and their details in a side-by-side layout
|
99 |
+
col3, col4 = st.columns([3, 7])
|
100 |
+
|
101 |
+
with col3:
|
102 |
+
st.subheader("Podcast Guest")
|
103 |
+
st.write(podcast_info['podcast_guest'])
|
104 |
+
|
105 |
+
with col4:
|
106 |
+
st.subheader("Podcast Guest Details")
|
107 |
+
st.write(podcast_info["podcast_guest_title"])
|
108 |
+
st.write(podcast_info["podcast_guest_org"])
|
109 |
+
|
110 |
+
# Display the five key moments
|
111 |
+
st.subheader("Key Moments")
|
112 |
+
key_moments = podcast_info['podcast_highlights']
|
113 |
+
for moment in key_moments.split('\n'):
|
114 |
+
st.markdown(
|
115 |
+
f"<p style='margin-bottom: 5px;'>{moment}</p>", unsafe_allow_html=True)
|
116 |
+
|
117 |
+
|
118 |
+
if __name__ == '__main__':
|
119 |
+
main()
|
120 |
|
121 |
|
122 |
|