Spaces:
Runtime error
Runtime error
Commit
·
7cb0035
1
Parent(s):
f925fd2
Update app_multi.py
Browse files- app_multi.py +20 -3
app_multi.py
CHANGED
@@ -13,6 +13,7 @@ import numpy as np
|
|
13 |
from PIL import Image, ImageDraw, ImageFont
|
14 |
from moviepy.editor import *
|
15 |
from moviepy.video.io.VideoFileClip import VideoFileClip
|
|
|
16 |
|
17 |
import asyncio
|
18 |
import json
|
@@ -63,7 +64,17 @@ def ref_video_fn(path_of_ref_video):
|
|
63 |
return gr.update(value=False)
|
64 |
|
65 |
sad_talker = SadTalker("checkpoints", "src/config", lazy_load=True)
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
# Reference: https://huggingface.co/spaces/zomehwh/rvc-models/blob/main/app.py#L21 # noqa
|
68 |
in_hf_space = getenv('SYSTEM') == 'spaces'
|
69 |
|
@@ -783,7 +794,13 @@ with app:
|
|
783 |
|
784 |
|
785 |
with gr.Tabs(elem_id="sadtalker_driven_audio"):
|
786 |
-
with gr.TabItem('
|
|
|
|
|
|
|
|
|
|
|
|
|
787 |
|
788 |
with gr.Row():
|
789 |
driven_audio = output_audio
|
@@ -827,11 +844,11 @@ with app:
|
|
827 |
batch_size = gr.Slider(label="Batch size (数值越大,生成速度越快;若显卡性能好,可增大数值)", step=1, maximum=32, value=2)
|
828 |
enhancer = gr.Checkbox(label="GFPGAN as Face enhancer", value=True, visible=False)
|
829 |
|
830 |
-
submit = gr.Button('想把我唱给你听', elem_id="sadtalker_generate", variant='primary')
|
831 |
|
832 |
with gr.Tabs(elem_id="sadtalker_genearted"):
|
833 |
gen_video = gr.Video(label="为您生成的专属视频", format="mp4").style(width=256)
|
834 |
|
|
|
835 |
|
836 |
submit.click(
|
837 |
fn=sad_talker.test,
|
|
|
13 |
from PIL import Image, ImageDraw, ImageFont
|
14 |
from moviepy.editor import *
|
15 |
from moviepy.video.io.VideoFileClip import VideoFileClip
|
16 |
+
import moviepy.editor as mpe
|
17 |
|
18 |
import asyncio
|
19 |
import json
|
|
|
64 |
return gr.update(value=False)
|
65 |
|
66 |
sad_talker = SadTalker("checkpoints", "src/config", lazy_load=True)
|
67 |
+
|
68 |
+
|
69 |
+
# combine video with music
|
70 |
+
|
71 |
+
def combine_music(video, audio):
|
72 |
+
my_clip = mpe.VideoFileClip(video)
|
73 |
+
audio_background = mpe.AudioFileClip(audio)
|
74 |
+
final_audio = mpe.CompositeAudioClip([my_clip.audio, audio_background])
|
75 |
+
final_clip = my_clip.set_audio(final_audio)
|
76 |
+
return final_clip
|
77 |
+
|
78 |
# Reference: https://huggingface.co/spaces/zomehwh/rvc-models/blob/main/app.py#L21 # noqa
|
79 |
in_hf_space = getenv('SYSTEM') == 'spaces'
|
80 |
|
|
|
794 |
|
795 |
|
796 |
with gr.Tabs(elem_id="sadtalker_driven_audio"):
|
797 |
+
with gr.TabItem('💡 完整视频'):
|
798 |
+
|
799 |
+
submit = gr.Button('想把我唱给你听', elem_id="sadtalker_generate", variant='primary')
|
800 |
+
|
801 |
+
gen_mv = gr.Button('添加歌曲伴奏吧', variant='primary')
|
802 |
+
|
803 |
+
music_video = gr.Video(label="视频+伴奏", format="mp4").style(width=256)
|
804 |
|
805 |
with gr.Row():
|
806 |
driven_audio = output_audio
|
|
|
844 |
batch_size = gr.Slider(label="Batch size (数值越大,生成速度越快;若显卡性能好,可增大数值)", step=1, maximum=32, value=2)
|
845 |
enhancer = gr.Checkbox(label="GFPGAN as Face enhancer", value=True, visible=False)
|
846 |
|
|
|
847 |
|
848 |
with gr.Tabs(elem_id="sadtalker_genearted"):
|
849 |
gen_video = gr.Video(label="为您生成的专属视频", format="mp4").style(width=256)
|
850 |
|
851 |
+
gen_mv.click(fn=combine_music, inputs=[gen_video, as_audio_no_vocals], outputs=[music_video])
|
852 |
|
853 |
submit.click(
|
854 |
fn=sad_talker.test,
|