HarshanaLF commited on
Commit
ed408a8
1 Parent(s): 60a521e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -59,7 +59,6 @@ def get_subtitles_with_pytube(video_url):
59
  except Exception as e:
60
  return f"An error occurred while retrieving subtitles with pytube: {str(e)}"
61
 
62
-
63
  # Function to summarize YouTube video with selected model
64
  def summarize_youtube_video(url, model_name):
65
  transcript = get_youtube_transcript(url)
@@ -72,8 +71,11 @@ def summarize_youtube_video(url, model_name):
72
  transcript = transcript[:max_length]
73
 
74
  summarization_pipeline = create_summarization_pipeline(model_name)
75
- summary = summarization_pipeline(transcript, min_length=10, max_length=1000, do_sample=False)
76
- return summary[0]['summary_text']
 
 
 
77
 
78
  # Define the Gradio interface
79
  iface = gr.Interface(
@@ -89,4 +91,3 @@ iface = gr.Interface(
89
 
90
  if __name__ == "__main__":
91
  iface.launch()
92
-
 
59
  except Exception as e:
60
  return f"An error occurred while retrieving subtitles with pytube: {str(e)}"
61
 
 
62
  # Function to summarize YouTube video with selected model
63
  def summarize_youtube_video(url, model_name):
64
  transcript = get_youtube_transcript(url)
 
71
  transcript = transcript[:max_length]
72
 
73
  summarization_pipeline = create_summarization_pipeline(model_name)
74
+ try:
75
+ summary = summarization_pipeline(transcript, min_length=10, max_length=1000, do_sample=False)
76
+ return summary[0]['summary_text']
77
+ except Exception as e:
78
+ return f"An error occurred while summarizing: {str(e)}"
79
 
80
  # Define the Gradio interface
81
  iface = gr.Interface(
 
91
 
92
  if __name__ == "__main__":
93
  iface.launch()