Spaces:
Runtime error
Runtime error
app.py
CHANGED
@@ -7,6 +7,8 @@ from pydub import AudioSegment
|
|
7 |
# Import everything needed to edit video clips
|
8 |
from moviepy.editor import *
|
9 |
import numpy as np
|
|
|
|
|
10 |
|
11 |
#path = "/content/gdrive/My Drive/AI/sample_imgs/"
|
12 |
#dirs = os.listdir( path )
|
@@ -55,17 +57,19 @@ def merge_audio_video(fps, resize_img_list, speech):
|
|
55 |
|
56 |
#convert flac to mp3 audio format
|
57 |
wav_audio = AudioSegment.from_file(speech, "flac") #("/content/gdrive/My Drive/AI/audio1.flac", "flac")
|
|
|
58 |
wav_audio.export("audio.mp3", format="mp3") #("/content/gdrive/My Drive/AI/audio1.mp3", format="mp3")
|
|
|
59 |
|
60 |
# loading video dsa gfg intro video
|
61 |
videoclip = VideoFileClip('my_vid_tmp.mp4') #("/content/gdrive/My Drive/AI/my_video1.mp4")
|
62 |
-
|
63 |
# loading audio file
|
64 |
audioclip = AudioFileClip('audio.mp3') #.subclip(0, 15)
|
65 |
-
|
66 |
# adding audio to the video clip
|
67 |
mergedclip = videoclip.set_audio(audioclip)
|
68 |
-
|
69 |
# showing video clip
|
70 |
#videoclip.ipython_display()
|
71 |
|
@@ -98,9 +102,12 @@ def engine(text_input):
|
|
98 |
|
99 |
#Convert text to speech using facebook's latest model from HF hub
|
100 |
speech = text2speech(text_input)
|
101 |
-
|
|
|
|
|
|
|
102 |
#Calculate the desired frame per second based on given audio length and entities identified
|
103 |
-
fps= entities_num / 19 #length of audio file #13 / 19
|
104 |
fps = float(format(fps, '.5f'))
|
105 |
print('fps is: ',fps)
|
106 |
|
|
|
7 |
# Import everything needed to edit video clips
|
8 |
from moviepy.editor import *
|
9 |
import numpy as np
|
10 |
+
import mutagen
|
11 |
+
from mutagen.wave import WAVE
|
12 |
|
13 |
#path = "/content/gdrive/My Drive/AI/sample_imgs/"
|
14 |
#dirs = os.listdir( path )
|
|
|
57 |
|
58 |
#convert flac to mp3 audio format
|
59 |
wav_audio = AudioSegment.from_file(speech, "flac") #("/content/gdrive/My Drive/AI/audio1.flac", "flac")
|
60 |
+
print('flac audio read', type(wav_audio))
|
61 |
wav_audio.export("audio.mp3", format="mp3") #("/content/gdrive/My Drive/AI/audio1.mp3", format="mp3")
|
62 |
+
print('flac audio converted to mp3 audio' )
|
63 |
|
64 |
# loading video dsa gfg intro video
|
65 |
videoclip = VideoFileClip('my_vid_tmp.mp4') #("/content/gdrive/My Drive/AI/my_video1.mp4")
|
66 |
+
print('video clip loaded in first time')
|
67 |
# loading audio file
|
68 |
audioclip = AudioFileClip('audio.mp3') #.subclip(0, 15)
|
69 |
+
print('mp3 format audio clip loaded in')
|
70 |
# adding audio to the video clip
|
71 |
mergedclip = videoclip.set_audio(audioclip)
|
72 |
+
print('video and audio merged')
|
73 |
# showing video clip
|
74 |
#videoclip.ipython_display()
|
75 |
|
|
|
102 |
|
103 |
#Convert text to speech using facebook's latest model from HF hub
|
104 |
speech = text2speech(text_input)
|
105 |
+
|
106 |
+
#getting audio clip's duration
|
107 |
+
audio_length = int(WAVE("alarm.wav").info.length)
|
108 |
+
|
109 |
#Calculate the desired frame per second based on given audio length and entities identified
|
110 |
+
fps= entities_num / audio_length #19 #length of audio file #13 / 19
|
111 |
fps = float(format(fps, '.5f'))
|
112 |
print('fps is: ',fps)
|
113 |
|