Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -31,11 +31,16 @@ def summarize_text(url, percent):
31
 
32
  # Get transcript using youtube-transcript-api
33
  try:
34
- transcript = YouTubeTranscriptApi.get_transcript(youtube.video_id)
35
- Text = ' '.join([entry['text'] for entry in transcript])
 
 
 
 
36
  except Exception as e:
37
- raise gr.Error(f"Could not retrieve the video's transcript. Please try another video")
38
-
 
39
  # Clean text
40
 
41
  Cleaned_text = re.sub(r'[^a-zA-Z0-9\._-]', ' ', Text)
 
31
 
32
  # Get transcript using youtube-transcript-api
33
  try:
34
+ ytt_api = YouTubeTranscriptApi()
35
+ transcript = ytt_api.fetch(
36
+ youtube.video_id,
37
+ languages=['en']
38
+ )
39
+ Text = ' '.join(snippet.text for snippet in transcript)
40
  except Exception as e:
41
+ print(f"Transcript error: {e}")
42
+ raise gr.Error(f"Could not retrieve the video's transcript: {e}")
43
+
44
  # Clean text
45
 
46
  Cleaned_text = re.sub(r'[^a-zA-Z0-9\._-]', ' ', Text)