tiennlu commited on
Commit
e3aef30
·
verified ·
1 Parent(s): 0f28ae7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -226,9 +226,10 @@ def get_video_id(youtube_url):
226
 
227
  def get_transcript(video_id):
228
  tran = []
229
- transcript = YouTubeTranscriptApi.get_transcript(video_id,languages=['en'])
230
- print(transcript)
231
- tran += [t['text'] for t in transcript if t['text'] != '[music]']
 
232
  return ' '.join(tran)
233
 
234
 
 
226
 
227
  def get_transcript(video_id):
228
  tran = []
229
+ transcript_list = YouTubeTranscriptApi.list_transcripts(video_id)
230
+ transcript = transcript_list.find_transcript(['en'])
231
+ translated_transcript = transcript.translate('en')
232
+ tran += [t['text'] for t in translated_transcript.fetch() if t['text'] != '[music]']
233
  return ' '.join(tran)
234
 
235