Commit
·
1bcd797
1
Parent(s):
745a54d
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
from youtube_transcript_api import YouTubeTranscriptApi
|
| 3 |
+
from IPython.display import YouTubeVideo
|
| 4 |
+
|
| 5 |
+
def summarize(result)
|
| 6 |
+
summarizer = pipeline('summarization')
|
| 7 |
+
num_iters = int(len(result)/1000)
|
| 8 |
+
summarized_text = []
|
| 9 |
+
for i in range(0, num_iters + 1):
|
| 10 |
+
start = 0
|
| 11 |
+
start = i * 1000
|
| 12 |
+
end = (i + 1) * 1000
|
| 13 |
+
print("input text \n" + result[start:end])
|
| 14 |
+
out = summarizer(result[start:end])
|
| 15 |
+
out = out[0]
|
| 16 |
+
out = out['summary_text']
|
| 17 |
+
print("Summarized text\n"+out)
|
| 18 |
+
summarized_text.append(out)
|
| 19 |
+
st.write(summarized_text)
|
| 20 |
+
|
| 21 |
+
def get_transcript(video_id)
|
| 22 |
+
#youtube_video = "https://www.youtube.com/watch?v=A4OmtyaBHFE"
|
| 23 |
+
#video_id = youtube_video.split("=")[1]
|
| 24 |
+
#video_id
|
| 25 |
+
st.write(YouTubeVideo(video_id))
|
| 26 |
+
transcript = YouTubeTranscriptApi.get_transcript(video_id)
|
| 27 |
+
print(transcript[0:5])
|
| 28 |
+
|
| 29 |
+
result = ""
|
| 30 |
+
for i in transcript:
|
| 31 |
+
result += ' ' + i['text']
|
| 32 |
+
#print(result)
|
| 33 |
+
print(len(result))
|
| 34 |
+
st.write(result)
|
| 35 |
+
|
| 36 |
+
def main()
|
| 37 |
+
video_id=st.text_input("enter video id ")
|
| 38 |
+
if video_id:
|
| 39 |
+
get_transcript(video_id)
|
| 40 |
+
main()
|