Spaces:
Running
Running
Commit
·
55866b4
1
Parent(s):
e5cd103
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,6 @@ from gtts import gTTS
|
|
5 |
from pydub import AudioSegment
|
6 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer, pipeline
|
7 |
from PIL import Image
|
8 |
-
import random
|
9 |
|
10 |
generator = pipeline('text-generation', model="checkpoints")
|
11 |
tokenizer = GPT2Tokenizer.from_pretrained('checkpoints')
|
@@ -32,8 +31,7 @@ def generate_output(name, date_of_birth):
|
|
32 |
except Exception as e:
|
33 |
return None, f"No se pudo generar el audio: {str(e)}"
|
34 |
|
35 |
-
|
36 |
-
command = f"python3 inference.py --checkpoint_path checkpoints/wav2lip_gan.pth --face {random_image} --audio audio.wav --outfile video.mp4 --nosmooth"
|
37 |
process = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
38 |
if process.returncode != 0:
|
39 |
error_message = process.stderr.decode("utf-8")
|
@@ -46,15 +44,6 @@ def generate_output(name, date_of_birth):
|
|
46 |
return output_video_path, None
|
47 |
return None, "No se pudo generar el video"
|
48 |
|
49 |
-
def select_random_image():
|
50 |
-
return random.choice([f"{i}.jpg" for i in range(1, 3)])
|
51 |
-
|
52 |
-
def error_message_fn(error_message):
|
53 |
-
if error_message is not None:
|
54 |
-
return gr.outputs.Textbox(text=error_message, placeholder="Error")
|
55 |
-
else:
|
56 |
-
return None
|
57 |
-
|
58 |
iface = gr.Interface(
|
59 |
fn=generate_output,
|
60 |
inputs=[
|
@@ -69,4 +58,4 @@ iface = gr.Interface(
|
|
69 |
description="Por favor, ingresa tu nombre y fecha de nacimiento."
|
70 |
)
|
71 |
|
72 |
-
iface.launch()
|
|
|
5 |
from pydub import AudioSegment
|
6 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer, pipeline
|
7 |
from PIL import Image
|
|
|
8 |
|
9 |
generator = pipeline('text-generation', model="checkpoints")
|
10 |
tokenizer = GPT2Tokenizer.from_pretrained('checkpoints')
|
|
|
31 |
except Exception as e:
|
32 |
return None, f"No se pudo generar el audio: {str(e)}"
|
33 |
|
34 |
+
command = f"python3 inference.py --checkpoint_path checkpoints/wav2lip_gan.pth --face oraculo.jpg --audio audio.wav --outfile video.mp4 --nosmooth"
|
|
|
35 |
process = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
36 |
if process.returncode != 0:
|
37 |
error_message = process.stderr.decode("utf-8")
|
|
|
44 |
return output_video_path, None
|
45 |
return None, "No se pudo generar el video"
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
iface = gr.Interface(
|
48 |
fn=generate_output,
|
49 |
inputs=[
|
|
|
58 |
description="Por favor, ingresa tu nombre y fecha de nacimiento."
|
59 |
)
|
60 |
|
61 |
+
iface.launch()
|