Spaces:
Runtime error
Runtime error
app.py
CHANGED
|
@@ -33,30 +33,35 @@ def resize(img_list):
|
|
| 33 |
# for img in resize_img_list
|
| 34 |
# if img.endswith(".jpg")]
|
| 35 |
#print(image_files)
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
| 39 |
#clip.write_videofile('/content/gdrive/My Drive/AI/my_vid_20apr.mp4')
|
| 40 |
|
| 41 |
|
| 42 |
-
def merge_audio_video(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
#convert flac to mp3 audio format
|
| 44 |
wav_audio = AudioSegment.from_file(speech, "flac") #("/content/gdrive/My Drive/AI/audio1.flac", "flac")
|
| 45 |
wav_audio.export("audio.mp3", format="mp3") #("/content/gdrive/My Drive/AI/audio1.mp3", format="mp3")
|
| 46 |
|
| 47 |
# loading video dsa gfg intro video
|
| 48 |
-
|
| 49 |
|
| 50 |
# loading audio file
|
| 51 |
audioclip = AudioFileClip('audio.mp3') #.subclip(0, 15)
|
| 52 |
|
| 53 |
# adding audio to the video clip
|
| 54 |
-
|
| 55 |
|
| 56 |
# showing video clip
|
| 57 |
#videoclip.ipython_display()
|
| 58 |
|
| 59 |
-
return
|
| 60 |
|
| 61 |
|
| 62 |
fastspeech = gr.Interface.load("huggingface/facebook/fastspeech2-en-ljspeech")
|
|
@@ -88,10 +93,10 @@ def engine(text_input):
|
|
| 88 |
fps= entities_num / 19 #length of audio file #13 / 19
|
| 89 |
|
| 90 |
#Convert string of images into a video
|
| 91 |
-
clip = images_to_video(fps, resize_img_list)
|
| 92 |
|
| 93 |
#Merge video and audio created above
|
| 94 |
-
|
| 95 |
#{'prompt':text_input,'steps':'50','width':'256','height':'256','images':'1','scale':10}).launch()
|
| 96 |
#img_intfc = gr.Interface.load("spaces/multimodalart/latentdiffusion", inputs=[gr.inputs.Textbox(lines=1, label="Input Text"), gr.inputs.Textbox(lines=1, label="Input Text"), gr.inputs.Textbox(lines=1, label="Input Text"), gr.inputs.Textbox(lines=1, label="Input Text"), gr.inputs.Textbox(lines=1, label="Input Text"), gr.inputs.Textbox(lines=1, label="Input Text")],
|
| 97 |
#outputs=[gr.outputs.Image(type="pil", label="output image"),gr.outputs.Carousel(label="Individual images",components=["image"]),gr.outputs.Textbox(label="Error")], )
|
|
@@ -108,7 +113,7 @@ def engine(text_input):
|
|
| 108 |
#run(prompt, steps, width, height, images, scale)
|
| 109 |
|
| 110 |
|
| 111 |
-
return
|
| 112 |
|
| 113 |
#image = gr.outputs.Image(type="pil", label="output image")
|
| 114 |
app = gr.Interface(engine,
|
|
|
|
| 33 |
# for img in resize_img_list
|
| 34 |
# if img.endswith(".jpg")]
|
| 35 |
#print(image_files)
|
| 36 |
+
|
| 37 |
+
#def images_to_video(fps, resize_img_list):
|
| 38 |
+
# clip = moviepy.video.io.ImageSequenceClip.ImageSequenceClip(resize_img_list, fps=fps)
|
| 39 |
+
# return clip
|
| 40 |
#clip.write_videofile('/content/gdrive/My Drive/AI/my_vid_20apr.mp4')
|
| 41 |
|
| 42 |
|
| 43 |
+
def merge_audio_video(fps, resize_img_list, speech):
|
| 44 |
+
#String a list of images into a video and write to memory
|
| 45 |
+
clip = moviepy.video.io.ImageSequenceClip.ImageSequenceClip(resize_img_list, fps=fps)
|
| 46 |
+
clip.write_videofile('my_vid_tmp.mp4')
|
| 47 |
+
|
| 48 |
#convert flac to mp3 audio format
|
| 49 |
wav_audio = AudioSegment.from_file(speech, "flac") #("/content/gdrive/My Drive/AI/audio1.flac", "flac")
|
| 50 |
wav_audio.export("audio.mp3", format="mp3") #("/content/gdrive/My Drive/AI/audio1.mp3", format="mp3")
|
| 51 |
|
| 52 |
# loading video dsa gfg intro video
|
| 53 |
+
videoclip = VideoFileClip('my_vid_tmp.mp4') #("/content/gdrive/My Drive/AI/my_video1.mp4")
|
| 54 |
|
| 55 |
# loading audio file
|
| 56 |
audioclip = AudioFileClip('audio.mp3') #.subclip(0, 15)
|
| 57 |
|
| 58 |
# adding audio to the video clip
|
| 59 |
+
mergedclip = videoclip.set_audio(audioclip)
|
| 60 |
|
| 61 |
# showing video clip
|
| 62 |
#videoclip.ipython_display()
|
| 63 |
|
| 64 |
+
return mergedclip
|
| 65 |
|
| 66 |
|
| 67 |
fastspeech = gr.Interface.load("huggingface/facebook/fastspeech2-en-ljspeech")
|
|
|
|
| 93 |
fps= entities_num / 19 #length of audio file #13 / 19
|
| 94 |
|
| 95 |
#Convert string of images into a video
|
| 96 |
+
#clip = images_to_video(fps, resize_img_list)
|
| 97 |
|
| 98 |
#Merge video and audio created above
|
| 99 |
+
mergedclip = merge_audio_video(fps, resize_img_list, speech)
|
| 100 |
#{'prompt':text_input,'steps':'50','width':'256','height':'256','images':'1','scale':10}).launch()
|
| 101 |
#img_intfc = gr.Interface.load("spaces/multimodalart/latentdiffusion", inputs=[gr.inputs.Textbox(lines=1, label="Input Text"), gr.inputs.Textbox(lines=1, label="Input Text"), gr.inputs.Textbox(lines=1, label="Input Text"), gr.inputs.Textbox(lines=1, label="Input Text"), gr.inputs.Textbox(lines=1, label="Input Text"), gr.inputs.Textbox(lines=1, label="Input Text")],
|
| 102 |
#outputs=[gr.outputs.Image(type="pil", label="output image"),gr.outputs.Carousel(label="Individual images",components=["image"]),gr.outputs.Textbox(label="Error")], )
|
|
|
|
| 113 |
#run(prompt, steps, width, height, images, scale)
|
| 114 |
|
| 115 |
|
| 116 |
+
return mergedclip #img, entities, speech
|
| 117 |
|
| 118 |
#image = gr.outputs.Image(type="pil", label="output image")
|
| 119 |
app = gr.Interface(engine,
|