Spaces:
Sleeping
Sleeping
add first files
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import copy
|
|
|
2 |
|
3 |
from pytube import YouTube
|
4 |
from scipy.signal import resample
|
@@ -15,6 +16,7 @@ from transformers import pipeline, BertTokenizer, BertForNextSentencePrediction
|
|
15 |
import torch
|
16 |
import whisper
|
17 |
|
|
|
18 |
|
19 |
transcriber = whisper.load_model("medium")
|
20 |
sentence_transformer = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
|
@@ -22,12 +24,14 @@ tokenizer = BertTokenizer.from_pretrained("bert-base-cased")
|
|
22 |
next_sentence_predict = BertForNextSentencePrediction.from_pretrained("bert-base-cased").eval()
|
23 |
summarizer = pipeline("summarization", model="philschmid/bart-large-cnn-samsum")
|
24 |
|
|
|
|
|
25 |
|
26 |
def get_youtube(video_url):
|
27 |
# YouTubeの動画をダウンロード
|
28 |
print("Start download video")
|
29 |
yt = YouTube(video_url)
|
30 |
-
abs_video_path = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download(filename='download.mp4', output_path='
|
31 |
print("Success download video")
|
32 |
print(abs_video_path)
|
33 |
|
@@ -147,7 +151,7 @@ def summarize_video(video_path, ratio_sum, playback_speed):
|
|
147 |
end_time = movie_clip.duration
|
148 |
clip = movie_clip.subclip(start_time, end_time)
|
149 |
clip = clip.set_pos("center").set_duration(end_time-start_time)
|
150 |
-
txt_clip = TextClip(clip_sentences[i]['sentences'][j], fontsize=int(movie_clip.w/40), color='white', bg_color='black', font='
|
151 |
txt_clip = txt_clip.set_duration(end_time-start_time).set_position(("center", "bottom"))
|
152 |
clip = CompositeVideoClip([clip, txt_clip])
|
153 |
tmp_clips.append(clip)
|
|
|
1 |
import copy
|
2 |
+
import subprocess
|
3 |
|
4 |
from pytube import YouTube
|
5 |
from scipy.signal import resample
|
|
|
16 |
import torch
|
17 |
import whisper
|
18 |
|
19 |
+
subprocess.run(['apt-get', '-y', 'install', 'imagemagick'])
|
20 |
|
21 |
transcriber = whisper.load_model("medium")
|
22 |
sentence_transformer = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
|
|
|
24 |
next_sentence_predict = BertForNextSentencePrediction.from_pretrained("bert-base-cased").eval()
|
25 |
summarizer = pipeline("summarization", model="philschmid/bart-large-cnn-samsum")
|
26 |
|
27 |
+
root_dir = '/home/user/app/video'
|
28 |
+
|
29 |
|
30 |
def get_youtube(video_url):
|
31 |
# YouTubeの動画をダウンロード
|
32 |
print("Start download video")
|
33 |
yt = YouTube(video_url)
|
34 |
+
abs_video_path = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download(filename='download.mp4', output_path='movies/')
|
35 |
print("Success download video")
|
36 |
print(abs_video_path)
|
37 |
|
|
|
151 |
end_time = movie_clip.duration
|
152 |
clip = movie_clip.subclip(start_time, end_time)
|
153 |
clip = clip.set_pos("center").set_duration(end_time-start_time)
|
154 |
+
txt_clip = TextClip(clip_sentences[i]['sentences'][j], fontsize=int(movie_clip.w/40), color='white', bg_color='black', font=os.path.join(root_dir, '/fonts/Muller-Trial-Medium.ttf'))
|
155 |
txt_clip = txt_clip.set_duration(end_time-start_time).set_position(("center", "bottom"))
|
156 |
clip = CompositeVideoClip([clip, txt_clip])
|
157 |
tmp_clips.append(clip)
|