pragnakalp commited on
Commit
3428530
β€’
1 Parent(s): f868f9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
2
  import spaces
3
  import torch
4
  import subprocess
 
 
5
 
6
  zero = torch.Tensor([0]).cuda()
7
  print(zero.device) # <-- 'cpu' πŸ€”
@@ -11,10 +13,20 @@ def greet(n):
11
  print(zero.device) # <-- 'cuda:0' πŸ€—
12
  return f"Hello {zero + n} Tensor"
13
 
 
 
 
 
 
 
 
 
 
 
14
  def run_infrence(input_video,input_audio):
15
  audio = "sample_data/sir.mp3"
16
  video = "sample_data/spark_input.mp4"
17
- command = f'python3 inference.py --checkpoint_path checkpoints/wav2lip_gan.pth --face "{video}" --audio "{audio}"'
18
  print("running ")
19
  # Execute the command
20
  process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
@@ -22,7 +34,7 @@ def run_infrence(input_video,input_audio):
22
  # Get the output
23
  output, error = process.communicate()
24
 
25
- return output
26
 
27
  def run():
28
  with gr.Blocks(css=".gradio-container {background-color: lightgray} #radio_div {background-color: #FFD8B4; font-size: 40px;}") as demo:
@@ -37,7 +49,8 @@ def run():
37
  with gr.Row():
38
  btn = gr.Button("Generate")
39
 
40
- btn.click(run_infrence,inputs=[input_video,input_audio])
 
41
  demo.queue()
42
  demo.launch(server_name="0.0.0.0", server_port=7860)
43
 
 
2
  import spaces
3
  import torch
4
  import subprocess
5
+ import os
6
+ import ffmpeg
7
 
8
  zero = torch.Tensor([0]).cuda()
9
  print(zero.device) # <-- 'cpu' πŸ€”
 
13
  print(zero.device) # <-- 'cuda:0' πŸ€—
14
  return f"Hello {zero + n} Tensor"
15
 
16
+ def audio_video():
17
+ print("started =========================")
18
+ input_video = ffmpeg.input('results/result_voice.mp4')
19
+
20
+ input_audio = ffmpeg.input('sample_data/sir.mp3')
21
+ os.system(f"rm -rf results/final_output.mp4")
22
+ ffmpeg.concat(input_video, input_audio, v=1, a=1).output('results/final_output.mp4').run()
23
+
24
+ return "results/final_output.mp4"
25
+
26
  def run_infrence(input_video,input_audio):
27
  audio = "sample_data/sir.mp3"
28
  video = "sample_data/spark_input.mp4"
29
+ command = f'python3 inference.py --checkpoint_path checkpoints/wav2lip_gan.pth --face sample_data/spark.png --audio sample_data/sir.mp3'
30
  print("running ")
31
  # Execute the command
32
  process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
 
34
  # Get the output
35
  output, error = process.communicate()
36
 
37
+ return audio_video()
38
 
39
  def run():
40
  with gr.Blocks(css=".gradio-container {background-color: lightgray} #radio_div {background-color: #FFD8B4; font-size: 40px;}") as demo:
 
49
  with gr.Row():
50
  btn = gr.Button("Generate")
51
 
52
+ btn.click(run_infrence,inputs=[input_video,input_audio], outputs=[video_out])
53
+ # btn.click(run_infrence,inputs=[input_video,input_audio])
54
  demo.queue()
55
  demo.launch(server_name="0.0.0.0", server_port=7860)
56