printing srt will product a list of text , start and duration. how do i create a for loop to combine the text together?

!pip install youtube_transcript_api

from youtube_transcript_api import YouTubeTranscriptApi

srt = YouTubeTranscriptApi.get_transcript('vSEfLlKWDZs')

srt[1]['text']

How do i combine all the text in the list of srt ?

Answer

Try this:

from youtube_transcript_api import YouTubeTranscriptApi

srt = YouTubeTranscriptApi.get_transcript('vSEfLlKWDZs')

text_list = []
for i in srt:
  text_list.append(i['text'])

text = ' '.join(text_list)
print(text)

Leave a Reply

Your email address will not be published. Required fields are marked *