-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (33 loc) · 1.21 KB
/
main.py
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
import streamlit as st
import glob, json
from api_communication import save_transcript
st.image('homepage.jpg')
st.title("Podcast Summarizer")
json_files = glob.glob('*.json')
episode_id = st.sidebar.text_input("Episode ID")
button = st.sidebar.button("Download Episode Summary", on_click=save_transcript, args=(episode_id,))
def get_clean_time(start_ms):
seconds = int((start_ms / 1000) % 60)
minutes = int((start_ms / (1000 * 60)) % 60)
hours = int((start_ms / (1000 * 60 * 60)) % 24)
if hours > 0:
start_t = f'{hours:02d}:{minutes:02d}:{seconds:02d}'
else:
start_t = f'{minutes:02d}:{seconds:02d}'
return start_t
if button:
filename = episode_id + '_chapters.json'
print(filename)
with open(filename, 'r') as f:
data = json.load(f)
chapters = data['chapters']
episode_title = data['episode_title']
thumbnail = data['thumbnail']
podcast_title = data['podcast_title']
audio = data['audio_url']
st.header(f'{podcast_title} - {episode_title}')
st.image(thumbnail, width=200)
st.markdown(f'#### {episode_title}')
for chp in chapters:
with st.expander(chp['gist'] + '-' + get_clean_time(chp['start'])):
chp['summary']