Spaces:
Runtime error
Runtime error
Commit
·
e283e85
1
Parent(s):
feb8f3f
Update components/utils.py
Browse files- components/utils.py +17 -3
components/utils.py
CHANGED
@@ -3,6 +3,15 @@ from moviepy.editor import AudioFileClip, CompositeAudioClip, TextClip,
|
|
3 |
from moviepy.video.tools.subtitles import SubtitlesClip
|
4 |
import os
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
def combine_videos(folder_name, length_speech):
|
7 |
|
8 |
length = len(os.listdir(folder_name))
|
@@ -31,6 +40,11 @@ def combine_audio_video(folder_name, vid, speech, sentences, length_speech):
|
|
31 |
videoclip = VideoFileClip(vid)
|
32 |
audioclip = AudioFileClip(speech)
|
33 |
|
|
|
|
|
|
|
|
|
|
|
34 |
generator = lambda txt: TextClip(txt, font='Arial', fontsize=24, color='white')
|
35 |
# subs = [((0, 4), 'subs1'),
|
36 |
# ((4, 9), 'subs2'),
|
@@ -45,7 +59,7 @@ def combine_audio_video(folder_name, vid, speech, sentences, length_speech):
|
|
45 |
|
46 |
videoclip = CompositeVideoClip([videoclip, subtitles.set_pos(('center','bottom'))])
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
videoclip.write_videofile(os.path.join(folder_name,"new_filename.mp4"))
|
|
|
3 |
from moviepy.video.tools.subtitles import SubtitlesClip
|
4 |
import os
|
5 |
|
6 |
+
# import torch
|
7 |
+
# import soundfile as sf
|
8 |
+
# from transformers import pipeline
|
9 |
+
|
10 |
+
# synthesiser = pipeline("text-to-audio", "facebook/musicgen-stereo-small")
|
11 |
+
# sampling_rate = model.config.audio_encoder.sampling_rate
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
def combine_videos(folder_name, length_speech):
|
16 |
|
17 |
length = len(os.listdir(folder_name))
|
|
|
40 |
videoclip = VideoFileClip(vid)
|
41 |
audioclip = AudioFileClip(speech)
|
42 |
|
43 |
+
# music = synthesiser("lo-fi music with a soothing melody", forward_params={"max_new_tokens": sampling_rate//sum(length_speech)})
|
44 |
+
|
45 |
+
# sf.write("musicgen_out.wav", music["audio"][0].T, music["sampling_rate"])
|
46 |
+
|
47 |
+
|
48 |
generator = lambda txt: TextClip(txt, font='Arial', fontsize=24, color='white')
|
49 |
# subs = [((0, 4), 'subs1'),
|
50 |
# ((4, 9), 'subs2'),
|
|
|
59 |
|
60 |
videoclip = CompositeVideoClip([videoclip, subtitles.set_pos(('center','bottom'))])
|
61 |
|
62 |
+
new_audioclip = CompositeAudioClip([audioclip])
|
63 |
+
videoclip.audio = new_audioclip
|
64 |
+
# videoclip.audio = CompositeAudioClip([audioclip, AudioFileClip("musicgen_out.wav")])
|
65 |
videoclip.write_videofile(os.path.join(folder_name,"new_filename.mp4"))
|