ammansik commited on
Commit
2458b22
·
1 Parent(s): ffb62ba
Files changed (2) hide show
  1. app.py +8 -3
  2. text_summary.py +1 -0
app.py CHANGED
@@ -58,8 +58,8 @@ def retrieve_chapters(timestamped_text, yt_chapters, openai_api_key):
58
  @timing_decorator("Summarizing video")
59
  def summarize_youtube_chapters(chapters, openai_api_key):
60
  # Summarize chapters
61
- summarized_chapters = summarize_chapters(chapters, openai_api_key)
62
- return summarized_chapters
63
 
64
 
65
  def get_work_dir():
@@ -96,9 +96,11 @@ def summarize_video(youtube_url):
96
  start_time = convert_seconds(summarized_chapter["start"])
97
  end_time = convert_seconds(summarized_chapter["end"])
98
 
 
99
  timestamp = f"{start_time} - {end_time}"
100
  title = summarized_chapter["title"]
101
  summary = summarized_chapter["summary"]
 
102
 
103
  # Display the hyperlink with timestamp and title
104
  hyperlink = (
@@ -106,7 +108,10 @@ def summarize_video(youtube_url):
106
  )
107
  st.markdown(hyperlink, unsafe_allow_html=True)
108
 
109
- st.write(summary)
 
 
 
110
  rmtree(work_dir)
111
 
112
 
 
58
  @timing_decorator("Summarizing video")
59
  def summarize_youtube_chapters(chapters, openai_api_key):
60
  # Summarize chapters
61
+ summarized_chapters, overall_summary = summarize_chapters(chapters, openai_api_key)
62
+ return summarized_chapters, overall_summary
63
 
64
 
65
  def get_work_dir():
 
96
  start_time = convert_seconds(summarized_chapter["start"])
97
  end_time = convert_seconds(summarized_chapter["end"])
98
 
99
+
100
  timestamp = f"{start_time} - {end_time}"
101
  title = summarized_chapter["title"]
102
  summary = summarized_chapter["summary"]
103
+ transcript = summarized_chapter["text"]
104
 
105
  # Display the hyperlink with timestamp and title
106
  hyperlink = (
 
108
  )
109
  st.markdown(hyperlink, unsafe_allow_html=True)
110
 
111
+ st.write(f'Summary: {summary}')
112
+ # Use an expander for the transcript
113
+ with st.expander("Show Transcript"):
114
+ st.write(transcript)
115
  rmtree(work_dir)
116
 
117
 
text_summary.py CHANGED
@@ -196,6 +196,7 @@ def summarize_chapters(chapters, openai_api_key):
196
  {
197
  "start": chapter["start_time"],
198
  "end": chapter["end_time"],
 
199
  "title": chapter_title.strip(),
200
  "summary": chapter_summary.strip(),
201
  }
 
196
  {
197
  "start": chapter["start_time"],
198
  "end": chapter["end_time"],
199
+ "text": chapter["text"],
200
  "title": chapter_title.strip(),
201
  "summary": chapter_summary.strip(),
202
  }