HarshanaLF commited on
Commit
ac54f8d
·
verified ·
1 Parent(s): ff1d636

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -43,6 +43,12 @@ def summarize_youtube_video(url, model_name):
43
  transcript = get_youtube_transcript(url)
44
  if "An error occurred" in transcript:
45
  return transcript
 
 
 
 
 
 
46
  summarization_pipeline = create_summarization_pipeline(model_name)
47
  summary = summarization_pipeline(transcript, min_length=10, max_length=1000, do_sample=False)
48
  return summary[0]['summary_text']
@@ -61,3 +67,4 @@ iface = gr.Interface(
61
 
62
  if __name__ == "__main__":
63
  iface.launch()
 
 
43
  transcript = get_youtube_transcript(url)
44
  if "An error occurred" in transcript:
45
  return transcript
46
+
47
+ # Truncate the transcript if necessary
48
+ max_length = 1024 # Adjust according to the model's maximum sequence length
49
+ if len(transcript) > max_length:
50
+ transcript = transcript[:max_length]
51
+
52
  summarization_pipeline = create_summarization_pipeline(model_name)
53
  summary = summarization_pipeline(transcript, min_length=10, max_length=1000, do_sample=False)
54
  return summary[0]['summary_text']
 
67
 
68
  if __name__ == "__main__":
69
  iface.launch()
70
+