Spaces:
Runtime error
Runtime error
Upload subtitles.py
Browse files- subtitles.py +16 -0
subtitles.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from youtube_transcript_api import YouTubeTranscriptApi
|
2 |
+
import pytube as py
|
3 |
+
|
4 |
+
def Get_Video_Id(url):
|
5 |
+
id=py.extract.video_id(url)
|
6 |
+
return id
|
7 |
+
|
8 |
+
def Video_To_Text(video_url):
|
9 |
+
video_text=" "
|
10 |
+
i=0
|
11 |
+
video_id=Get_Video_Id(video_url)
|
12 |
+
video_data=YouTubeTranscriptApi.get_transcript(video_id)
|
13 |
+
for data in video_data:
|
14 |
+
video_text=video_text+" "+video_data[i].get("text")
|
15 |
+
i=i+1
|
16 |
+
return video_text
|