Rivalcoder commited on
Commit
ab498f8
·
1 Parent(s): 3befc55
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -14,13 +14,14 @@ ytt_api = YouTubeTranscriptApi(
14
  def fetch_transcript(video_id: str):
15
  try:
16
  # Fetch transcript
17
- transcript = ytt_api.fetch(video_id)
18
- # Extract and join only the text fields
19
- full_text = " ".join([entry['text'] for entry in transcript])
20
  return full_text
21
  except Exception as e:
22
  return f"Error fetching transcript: {str(e)}"
23
 
 
24
  # Gradio Interface
25
  iface = gr.Interface(
26
  fn=fetch_transcript,
 
14
  def fetch_transcript(video_id: str):
15
  try:
16
  # Fetch transcript
17
+ transcript_obj = ytt_api.fetch(video_id)
18
+ # Extract and join only the text fields from FetchedTranscriptSnippet objects
19
+ full_text = " ".join([snippet.text for snippet in transcript_obj.snippets])
20
  return full_text
21
  except Exception as e:
22
  return f"Error fetching transcript: {str(e)}"
23
 
24
+
25
  # Gradio Interface
26
  iface = gr.Interface(
27
  fn=fetch_transcript,