Spaces:
Build error
Build error
updated a bug for uploaded video
Browse files
app.py
CHANGED
|
@@ -22,8 +22,10 @@ def generate_transcripts(in_video): #generate_gifs(in_video, gif_transcript):
|
|
| 22 |
#convert video to audio
|
| 23 |
print(f" input video is : {in_video}")
|
| 24 |
|
|
|
|
| 25 |
video_path = Path("./ShiaLaBeouf.mp4")
|
| 26 |
-
audio_memory, _ = ffmpeg.input(
|
|
|
|
| 27 |
|
| 28 |
#Getting transcripts using wav2Vec2 huggingface hosted accelerated inference
|
| 29 |
#sending audio file in request along with stride and chunk length information
|
|
@@ -46,7 +48,7 @@ def generate_transcripts(in_video): #generate_gifs(in_video, gif_transcript):
|
|
| 46 |
return transcription, words, words_timestamp
|
| 47 |
|
| 48 |
|
| 49 |
-
def generate_gifs(gif_transcript, words, words_timestamp):
|
| 50 |
print("********* Inside generate_gifs() **********")
|
| 51 |
|
| 52 |
#creating list from input gif transcript
|
|
@@ -70,7 +72,7 @@ def generate_gifs(gif_transcript, words, words_timestamp):
|
|
| 70 |
start_seconds, end_seconds = get_gif_timestamps(giflist_indxs, words_timestamp)
|
| 71 |
print(f"start_seconds, end_seconds are : ({start_seconds}, {end_seconds})")
|
| 72 |
#generated .gif image
|
| 73 |
-
gif_out, vid_out = gen_moviepy_gif(start_seconds, end_seconds)
|
| 74 |
|
| 75 |
return gif_out
|
| 76 |
|
|
@@ -157,10 +159,13 @@ def get_gif_timestamps(giflist_indxs, words_timestamp):
|
|
| 157 |
|
| 158 |
|
| 159 |
#extracting the video and building and serving a .gif image
|
| 160 |
-
def gen_moviepy_gif(start_seconds, end_seconds):
|
| 161 |
print("******** inside moviepy_gif () ***************")
|
|
|
|
| 162 |
video_path = "./ShiaLaBeouf.mp4"
|
| 163 |
-
video = mp.VideoFileClip(
|
|
|
|
|
|
|
| 164 |
final_clip = video.subclip(start_seconds, end_seconds)
|
| 165 |
|
| 166 |
#writing to RAM
|
|
@@ -316,7 +321,7 @@ with demo:
|
|
| 316 |
""")
|
| 317 |
|
| 318 |
button_transcript.click(generate_transcripts, input_video, [text_transcript, text_words, text_wordstimestamps ])
|
| 319 |
-
button_gifs.click(generate_gifs, [text_gif_transcript, text_words, text_wordstimestamps], out_gif )
|
| 320 |
|
| 321 |
|
| 322 |
demo.launch(debug=True)
|
|
|
|
| 22 |
#convert video to audio
|
| 23 |
print(f" input video is : {in_video}")
|
| 24 |
|
| 25 |
+
#sample
|
| 26 |
video_path = Path("./ShiaLaBeouf.mp4")
|
| 27 |
+
audio_memory, _ = ffmpeg.input(in_video).output('-', format="wav", ac=1, ar='16k').overwrite_output().global_args('-loglevel', 'quiet').run(capture_stdout=True)
|
| 28 |
+
#audio_memory, _ = ffmpeg.input(video_path).output('-', format="wav", ac=1, ar='16k').overwrite_output().global_args('-loglevel', 'quiet').run(capture_stdout=True)
|
| 29 |
|
| 30 |
#Getting transcripts using wav2Vec2 huggingface hosted accelerated inference
|
| 31 |
#sending audio file in request along with stride and chunk length information
|
|
|
|
| 48 |
return transcription, words, words_timestamp
|
| 49 |
|
| 50 |
|
| 51 |
+
def generate_gifs(in_video, gif_transcript, words, words_timestamp):
|
| 52 |
print("********* Inside generate_gifs() **********")
|
| 53 |
|
| 54 |
#creating list from input gif transcript
|
|
|
|
| 72 |
start_seconds, end_seconds = get_gif_timestamps(giflist_indxs, words_timestamp)
|
| 73 |
print(f"start_seconds, end_seconds are : ({start_seconds}, {end_seconds})")
|
| 74 |
#generated .gif image
|
| 75 |
+
gif_out, vid_out = gen_moviepy_gif(in_video, start_seconds, end_seconds)
|
| 76 |
|
| 77 |
return gif_out
|
| 78 |
|
|
|
|
| 159 |
|
| 160 |
|
| 161 |
#extracting the video and building and serving a .gif image
|
| 162 |
+
def gen_moviepy_gif(in_video, start_seconds, end_seconds):
|
| 163 |
print("******** inside moviepy_gif () ***************")
|
| 164 |
+
#sample
|
| 165 |
video_path = "./ShiaLaBeouf.mp4"
|
| 166 |
+
video = mp.VideoFileClip(in_video)
|
| 167 |
+
#video = mp.VideoFileClip(video_path)
|
| 168 |
+
|
| 169 |
final_clip = video.subclip(start_seconds, end_seconds)
|
| 170 |
|
| 171 |
#writing to RAM
|
|
|
|
| 321 |
""")
|
| 322 |
|
| 323 |
button_transcript.click(generate_transcripts, input_video, [text_transcript, text_words, text_wordstimestamps ])
|
| 324 |
+
button_gifs.click(generate_gifs, [input_video, text_gif_transcript, text_words, text_wordstimestamps], out_gif )
|
| 325 |
|
| 326 |
|
| 327 |
demo.launch(debug=True)
|