Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ import os
|
|
6 |
from transformers import pipeline
|
7 |
import subprocess
|
8 |
import moviepy.editor as mp
|
|
|
9 |
|
10 |
token = AutoTokenizer.from_pretrained('distilroberta-base')
|
11 |
|
@@ -53,9 +54,18 @@ def summary(text):
|
|
53 |
|
54 |
return summ
|
55 |
|
56 |
-
def classify(vid):
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
clip.audio.write_audiofile(r"audio.wav")
|
60 |
|
61 |
full_text = video_identity(r"audio.wav")
|
@@ -73,7 +83,7 @@ text2 = gr.Textbox(label="Summary")
|
|
73 |
|
74 |
|
75 |
iface = gr.Interface(fn=classify,
|
76 |
-
inputs='video',
|
77 |
outputs = [text1,text2,gr.outputs.Label(num_top_classes=3)],
|
78 |
examples = ['the-life-of-a-star-explained-in-1-minute.mp4'])
|
79 |
iface.launch(inline=False)
|
|
|
6 |
from transformers import pipeline
|
7 |
import subprocess
|
8 |
import moviepy.editor as mp
|
9 |
+
import base64
|
10 |
|
11 |
token = AutoTokenizer.from_pretrained('distilroberta-base')
|
12 |
|
|
|
54 |
|
55 |
return summ
|
56 |
|
57 |
+
def classify(vid,encoded_video):
|
58 |
+
|
59 |
+
if encoded_video != "":
|
60 |
+
|
61 |
+
decoded_file_data = base64.b64decode(encoded_video)
|
62 |
+
|
63 |
+
with open("temp_video.mp4", "wb") as f:
|
64 |
+
f.write(decoded_file_data)
|
65 |
+
|
66 |
+
video_file = "temp_video.mp4"
|
67 |
+
|
68 |
+
clip = mp.VideoFileClip(video_file)
|
69 |
clip.audio.write_audiofile(r"audio.wav")
|
70 |
|
71 |
full_text = video_identity(r"audio.wav")
|
|
|
83 |
|
84 |
|
85 |
iface = gr.Interface(fn=classify,
|
86 |
+
inputs=['video','text'],
|
87 |
outputs = [text1,text2,gr.outputs.Label(num_top_classes=3)],
|
88 |
examples = ['the-life-of-a-star-explained-in-1-minute.mp4'])
|
89 |
iface.launch(inline=False)
|