Upload 7 files
Browse files- .gitattributes +3 -0
- .gitignore +24 -0
- data_audio_sun_5s.wav +3 -0
- data_audio_sun_5sv1.wav +3 -0
- estructura_proyecto.txt +34 -0
- requirements.txt +31 -0
- result_voice_ania.mp4 +3 -0
- setup.py +287 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
data_audio_sun_5s.wav filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
data_audio_sun_5sv1.wav filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
result_voice_ania.mp4 filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#Ignorar entorno virtual
|
| 2 |
+
env/
|
| 3 |
+
|
| 4 |
+
#Ignorar archivos y carpetas de compilacion
|
| 5 |
+
__pycache__/
|
| 6 |
+
*.pyc
|
| 7 |
+
*.pyo
|
| 8 |
+
*.py[cod]
|
| 9 |
+
.vscode/
|
| 10 |
+
.DS_Store
|
| 11 |
+
|
| 12 |
+
#Ignorar archivos de log y salida de pruebas
|
| 13 |
+
*.log
|
| 14 |
+
*.out
|
| 15 |
+
*.tmp
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
#Ignorar modelos y checkpoints
|
| 19 |
+
models/
|
| 20 |
+
checkpoints/
|
| 21 |
+
src/Wav2Lip/
|
| 22 |
+
assets/
|
| 23 |
+
data/
|
| 24 |
+
#Archivos temporales y de sistema
|
data_audio_sun_5s.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f03a2544c5a6e1e7246bd56e22426dd8d48ccd348bfda38b99c502c7972ea1fe
|
| 3 |
+
size 779308
|
data_audio_sun_5sv1.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:52842ddd3638a3f53144dd4dd4a7663c17e5827f275f422caa6fc9fb8b882fa5
|
| 3 |
+
size 446542
|
estructura_proyecto.txt
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
proyecto_root/
|
| 2 |
+
│
|
| 3 |
+
├── assets/
|
| 4 |
+
├── video/
|
| 5 |
+
│ │ ├──data_video_sun_5s.mp4
|
| 6 |
+
│ └── audio/
|
| 7 |
+
│ └──data_audio_sun_5s.wav
|
| 8 |
+
│ └── # Archivos de datos, audio y video de prueba, como `data_audio_sun_5s.wav`
|
| 9 |
+
│
|
| 10 |
+
├── checkpoints/
|
| 11 |
+
│ └── # Modelos y checkpoints preentrenados, como `wav2lip_gan.pth`
|
| 12 |
+
│
|
| 13 |
+
├── models/
|
| 14 |
+
│ └── # Modelos convertidos a OpenVINO IR, como `face_detection.xml` y `wav2lip.xml`
|
| 15 |
+
│
|
| 16 |
+
├── src/
|
| 17 |
+
| ├── utils/
|
| 18 |
+
| ├── Wav2Lip/
|
| 19 |
+
│ ├── convert_models.py
|
| 20 |
+
│ ├── gradio_helper.py
|
| 21 |
+
│ ├── ov_inference.py
|
| 22 |
+
│ ├── ov_wav2lip_helper.py
|
| 23 |
+
│ └── run_inference
|
| 24 |
+
│
|
| 25 |
+
├── tests/
|
| 26 |
+
│ └── # Scripts de pruebas para verificar la funcionalidad de tu código
|
| 27 |
+
│
|
| 28 |
+
├── results/
|
| 29 |
+
│ └── result_voice.mp4
|
| 30 |
+
│
|
| 31 |
+
├── requirements.txt # Lista de dependencias del proyecto
|
| 32 |
+
├── setup.py # Script de configuración del proyecto
|
| 33 |
+
├── estructura_proyecto.py # Script de configuración del proyecto
|
| 34 |
+
└── README.md # Documentación del proyecto
|
requirements.txt
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
openvino>=2024.4.0
|
| 2 |
+
huggingface_hub
|
| 3 |
+
torch>=2.1
|
| 4 |
+
gradio>=4.19
|
| 5 |
+
librosa==0.9.2
|
| 6 |
+
opencv-contrib-python
|
| 7 |
+
opencv-python
|
| 8 |
+
IPython
|
| 9 |
+
tqdm
|
| 10 |
+
numba
|
| 11 |
+
numpy
|
| 12 |
+
|
| 13 |
+
openai-whisper
|
| 14 |
+
sounddevice
|
| 15 |
+
scipy
|
| 16 |
+
|
| 17 |
+
transformers>=4.35
|
| 18 |
+
torchvision>=0.18.1
|
| 19 |
+
onnx>=1.16.1
|
| 20 |
+
optimum-intel @ git+https://github.com/huggingface/optimum-intel.git
|
| 21 |
+
openvino
|
| 22 |
+
openvino-tokenizers
|
| 23 |
+
openvino-genai
|
| 24 |
+
datasets
|
| 25 |
+
soundfile>=0.12
|
| 26 |
+
python-ffmpeg<=1.0.16
|
| 27 |
+
nncf>=2.13.0
|
| 28 |
+
jiwer
|
| 29 |
+
|
| 30 |
+
gtts
|
| 31 |
+
|
result_voice_ania.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a2956d59ea7b7f0771d0fa10f4dd6d2ff04b0f4708f139f361de67919c418fc9
|
| 3 |
+
size 996888
|
setup.py
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 2024/03/11 setup.py
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
import subprocess
|
| 5 |
+
import sys
|
| 6 |
+
import requests
|
| 7 |
+
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
# Definición de las carpetas del proyecto
|
| 11 |
+
PROJECT_DIRECTORIES = [
|
| 12 |
+
"assets",
|
| 13 |
+
"assets/audio",
|
| 14 |
+
"assets/video",
|
| 15 |
+
"checkpoints",
|
| 16 |
+
"models",
|
| 17 |
+
"src",
|
| 18 |
+
"src/utils",
|
| 19 |
+
"tests",
|
| 20 |
+
"results"
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
# URLs de las utilidades de OpenVINO Notebooks
|
| 24 |
+
OPENVINO_UTILS = {
|
| 25 |
+
"notebook_utils.py": "https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py",
|
| 26 |
+
"pip_helper.py": "https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/pip_helper.py"
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
# URLs de los archivos de ayuda de Wav2Lip
|
| 30 |
+
WAV2LIP_HELPERS = {
|
| 31 |
+
"gradio_helper.py": "https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/wav2lip/gradio_helper.py",
|
| 32 |
+
"ov_inference.py": "https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/wav2lip/ov_inference.py",
|
| 33 |
+
"ov_wav2lip_helper.py": "https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/wav2lip/ov_wav2lip_helper.py"
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
WAV2LIP_HELPERS_DIR = Path("src")
|
| 37 |
+
OPENVINO_UTILS_DIR = Path("src/utils")
|
| 38 |
+
|
| 39 |
+
# URLs de los archivos de ejemplo de entrada
|
| 40 |
+
EXAMPLE_FILES = {
|
| 41 |
+
"audio_example": {
|
| 42 |
+
"filename": "data_audio_sun_5s.wav",
|
| 43 |
+
"url": "https://github.com/sammysun0711/openvino_aigc_samples/blob/main/Wav2Lip/data_audio_sun_5s.wav?raw=true",
|
| 44 |
+
"folder": "assets/audio"
|
| 45 |
+
},
|
| 46 |
+
"video_example": {
|
| 47 |
+
"filename": "data_video_sun_5s.mp4",
|
| 48 |
+
"url": "https://github.com/sammysun0711/openvino_aigc_samples/blob/main/Wav2Lip/data_video_sun_5s.mp4?raw=true",
|
| 49 |
+
"folder": "assets/video"
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
# Función para crear la estructura general del proyecto
|
| 54 |
+
def create_project_structure():
|
| 55 |
+
"""
|
| 56 |
+
Crea la estructura de las carpetas del proyecto
|
| 57 |
+
"""
|
| 58 |
+
for directory in PROJECT_DIRECTORIES:
|
| 59 |
+
path = Path(directory)
|
| 60 |
+
if not path.exists():
|
| 61 |
+
path.mkdir(parents=True, exist_ok=True)
|
| 62 |
+
print(f"Carpeta '{directory}' creada.")
|
| 63 |
+
else:
|
| 64 |
+
print(f"Carpeta '{directory}' ya existe.")
|
| 65 |
+
|
| 66 |
+
# Función para crear el entorno virtual
|
| 67 |
+
def create_virtual_environment():
|
| 68 |
+
"""
|
| 69 |
+
Crea el entorno virtual si no existe.
|
| 70 |
+
"""
|
| 71 |
+
env_path = Path("env")
|
| 72 |
+
if not env_path.exists():
|
| 73 |
+
print("Creando el entorno virtual...")
|
| 74 |
+
subprocess.check_call([sys.executable, "-m", "venv", "env"])
|
| 75 |
+
print(f"Entorno virtual creado en '{env_path}'.")
|
| 76 |
+
else:
|
| 77 |
+
print(f"El entorno virtual '{env_path}' ya existe.")
|
| 78 |
+
|
| 79 |
+
# Función que activa y define pip y python
|
| 80 |
+
def activate_virtual_environment():
|
| 81 |
+
"""
|
| 82 |
+
Activa el entorno virtual y devuelve las rutas de pip y python.
|
| 83 |
+
"""
|
| 84 |
+
if os.name == 'nt': # Windows
|
| 85 |
+
python_path = str(Path("env") / "Scripts" / "python.exe")
|
| 86 |
+
pip_path = str(Path("env") / "Scripts" / "pip.exe")
|
| 87 |
+
else: # Unix/MacOS
|
| 88 |
+
python_path = str(Path("env") / "bin" / "python")
|
| 89 |
+
pip_path = str(Path("env") / "bin" / "pip")
|
| 90 |
+
|
| 91 |
+
# Actualizar pip a la última versión en el entorno virtual usando python -m pip
|
| 92 |
+
try:
|
| 93 |
+
subprocess.check_call([python_path, "-m", "pip", "install", "--upgrade", "pip"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 94 |
+
print("pip actualizado a la última versión.")
|
| 95 |
+
except subprocess.CalledProcessError:
|
| 96 |
+
print("Error al actualizar pip.")
|
| 97 |
+
try:
|
| 98 |
+
subprocess.check_call([pip_path, "install", "tqdm"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 99 |
+
except subprocess.CalledProcessError:
|
| 100 |
+
print("Error al instalar tqdm.")
|
| 101 |
+
|
| 102 |
+
return python_path, pip_path
|
| 103 |
+
|
| 104 |
+
# Funcion para instalar las dependencias desde requirements.txt con barra de progreso
|
| 105 |
+
def install_requirements(pip_path):
|
| 106 |
+
"""
|
| 107 |
+
Instala las dependencias de requirements.txt con una barra de progreso.
|
| 108 |
+
"""
|
| 109 |
+
print("Instalando dependencias...")
|
| 110 |
+
# Instalar tqdm en el entorno virtual si no está instalado
|
| 111 |
+
try:
|
| 112 |
+
subprocess.check_call([pip_path, "install", "tqdm"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 113 |
+
except subprocess.CalledProcessError:
|
| 114 |
+
print("Error al instalar tqdm.")
|
| 115 |
+
|
| 116 |
+
from tqdm import tqdm # Importar tqdm para la barra de progreso
|
| 117 |
+
|
| 118 |
+
# Leer requirements.txt y mostrar barra de progreso
|
| 119 |
+
requirements_path = Path("requirements.txt")
|
| 120 |
+
if not requirements_path.exists():
|
| 121 |
+
print("Archivo requirements.txt no encontrado.")
|
| 122 |
+
return
|
| 123 |
+
|
| 124 |
+
with open(requirements_path, "r") as f:
|
| 125 |
+
dependencies = f.read().splitlines()
|
| 126 |
+
|
| 127 |
+
# Instalar cada dependencia con barra de progreso
|
| 128 |
+
for dependency in tqdm(dependencies, desc="Instalando dependencias", unit="paquete"):
|
| 129 |
+
try:
|
| 130 |
+
subprocess.check_call([pip_path, "install", dependency], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 131 |
+
except subprocess.CalledProcessError:
|
| 132 |
+
print(f"\nError al instalar {dependency}.")
|
| 133 |
+
|
| 134 |
+
print("Todas las dependencias fueron instaladas correctamente.")
|
| 135 |
+
|
| 136 |
+
# Funcion para descargar los archivos de utilidades de OpenVINO Notebooks
|
| 137 |
+
def download_openvino_utils(pip_path):
|
| 138 |
+
"""
|
| 139 |
+
Descarga los archivos de utilidades de OpenVINO Notebooks en src/utils si no existen.
|
| 140 |
+
"""
|
| 141 |
+
# Crear la carpeta de utilidades si no existe
|
| 142 |
+
OPENVINO_UTILS_DIR.mkdir(parents=True, exist_ok=True)
|
| 143 |
+
|
| 144 |
+
# Instalar requests en el entorno virtual si no está instalado
|
| 145 |
+
try:
|
| 146 |
+
subprocess.check_call([pip_path, "install", "requests"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 147 |
+
except subprocess.CalledProcessError:
|
| 148 |
+
print("Error al instalar requests.")
|
| 149 |
+
|
| 150 |
+
# Instalar tqdm en el entorno virtual si no está instalado
|
| 151 |
+
try:
|
| 152 |
+
subprocess.check_call([pip_path, "install", "tqdm"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 153 |
+
except subprocess.CalledProcessError:
|
| 154 |
+
print("Error al instalar tqdm.")
|
| 155 |
+
|
| 156 |
+
from tqdm import tqdm # Importar tqdm para la barra de progreso
|
| 157 |
+
|
| 158 |
+
for filename, url in tqdm(OPENVINO_UTILS.items(), desc="Descargando utilidades de OpenVINO", unit="archivo"):
|
| 159 |
+
file_path = OPENVINO_UTILS_DIR / filename
|
| 160 |
+
if not file_path.exists():
|
| 161 |
+
response = requests.get(url)
|
| 162 |
+
if response.status_code == 200:
|
| 163 |
+
with open(file_path, "wb") as f:
|
| 164 |
+
f.write(response.content)
|
| 165 |
+
else:
|
| 166 |
+
print(f"Error al descargar {filename} desde {url}")
|
| 167 |
+
|
| 168 |
+
# Función para descargar los archivos de ayuda específicos de Wav2Lip
|
| 169 |
+
def download_wav2lip_helpers(pip_path):
|
| 170 |
+
"""
|
| 171 |
+
Descarga los archivos de ayuda específicos de Wav2Lip si no existen.
|
| 172 |
+
"""
|
| 173 |
+
WAV2LIP_HELPERS_DIR.mkdir(parents=True, exist_ok=True) # Crea `src` si no existe
|
| 174 |
+
|
| 175 |
+
# Instalar requests en el entorno virtual si no está instalado
|
| 176 |
+
try:
|
| 177 |
+
subprocess.check_call([pip_path, "install", "requests"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 178 |
+
except subprocess.CalledProcessError:
|
| 179 |
+
print("Error al instalar requests.")
|
| 180 |
+
|
| 181 |
+
try:
|
| 182 |
+
subprocess.check_call([pip_path, "install", "tqdm"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 183 |
+
except subprocess.CalledProcessError:
|
| 184 |
+
print("Error al instalar tqdm.")
|
| 185 |
+
|
| 186 |
+
from tqdm import tqdm # Importar tqdm para la barra de progreso
|
| 187 |
+
for filename, url in tqdm(WAV2LIP_HELPERS.items(), desc="Descargando ayudas de Wav2Lip", unit="archivo"):
|
| 188 |
+
file_path = WAV2LIP_HELPERS_DIR / filename
|
| 189 |
+
if not file_path.exists():
|
| 190 |
+
response = requests.get(url)
|
| 191 |
+
if response.status_code == 200:
|
| 192 |
+
with open(file_path, "wb") as f:
|
| 193 |
+
f.write(response.content)
|
| 194 |
+
|
| 195 |
+
# Función para descargar los archivos de ejemplo de entrada (audio y video)
|
| 196 |
+
def download_example_files():
|
| 197 |
+
"""
|
| 198 |
+
Descarga los archivos de ejemplo de entrada (audio y video) en sus carpetas correspondientes.
|
| 199 |
+
"""
|
| 200 |
+
# Instalar requests en el entorno virtual si no está instalado
|
| 201 |
+
try:
|
| 202 |
+
subprocess.check_call([pip_path, "install", "requests"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 203 |
+
except subprocess.CalledProcessError:
|
| 204 |
+
print("Error al instalar requests.")
|
| 205 |
+
|
| 206 |
+
try:
|
| 207 |
+
subprocess.check_call([pip_path, "install", "tqdm"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 208 |
+
except subprocess.CalledProcessError:
|
| 209 |
+
print("Error al instalar tqdm.")
|
| 210 |
+
|
| 211 |
+
from tqdm import tqdm # Importar tqdm para la barra de progreso
|
| 212 |
+
|
| 213 |
+
for example_name, example_info in tqdm(EXAMPLE_FILES.items(), desc="Descargando archivos de ejemplo", unit="archivo"):
|
| 214 |
+
folder_path = Path(example_info["folder"])
|
| 215 |
+
file_path = folder_path / example_info["filename"]
|
| 216 |
+
|
| 217 |
+
# Crear la carpeta si no existe
|
| 218 |
+
folder_path.mkdir(parents=True, exist_ok=True)
|
| 219 |
+
|
| 220 |
+
# Descargar el archivo si no existe
|
| 221 |
+
if not file_path.exists():
|
| 222 |
+
response = requests.get(example_info["url"])
|
| 223 |
+
if response.status_code == 200:
|
| 224 |
+
with open(file_path, "wb") as f:
|
| 225 |
+
f.write(response.content)
|
| 226 |
+
|
| 227 |
+
def clone_wav2lip_repo():
|
| 228 |
+
"""
|
| 229 |
+
Clona el repositorio oficial de Wav2Lip, ocultando el progreso mediante tqdm.
|
| 230 |
+
"""
|
| 231 |
+
repo_url = "https://github.com/Rudrabha/Wav2Lip"
|
| 232 |
+
clone_path = "src/Wav2Lip"
|
| 233 |
+
|
| 234 |
+
try:
|
| 235 |
+
subprocess.check_call([pip_path, "install", "requests"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 236 |
+
except subprocess.CalledProcessError:
|
| 237 |
+
print("Error al instalar requests.")
|
| 238 |
+
|
| 239 |
+
try:
|
| 240 |
+
subprocess.check_call([pip_path, "install", "tqdm"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 241 |
+
except subprocess.CalledProcessError:
|
| 242 |
+
print("Error al instalar tqdm.")
|
| 243 |
+
|
| 244 |
+
from tqdm import tqdm # Importar tqdm para la barra de progreso
|
| 245 |
+
|
| 246 |
+
# Verifica si el repositorio ya existe para evitar clonarlo nuevamente
|
| 247 |
+
if os.path.exists(clone_path):
|
| 248 |
+
print(f"El repositorio '{clone_path}' ya existe.")
|
| 249 |
+
return
|
| 250 |
+
|
| 251 |
+
# Inicia el proceso de clonación con tqdm para ocultar el progreso
|
| 252 |
+
print("Clonando el repositorio de Wav2Lip...")
|
| 253 |
+
with tqdm(total=100, desc="Clonación en progreso", ncols=100, bar_format="{l_bar}{bar}") as pbar:
|
| 254 |
+
# Ejecuta el comando de clonación
|
| 255 |
+
exit_code = subprocess.call(["git", "clone", repo_url, clone_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 256 |
+
|
| 257 |
+
if exit_code != 0:
|
| 258 |
+
raise Exception("Error: La clonación del repositorio ha fallado.")
|
| 259 |
+
else:
|
| 260 |
+
pbar.update(100)
|
| 261 |
+
print("Repositorio clonado exitosamente en 'Wav2Lip'.")
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
if __name__ == "__main__":
|
| 265 |
+
create_project_structure()
|
| 266 |
+
create_virtual_environment()
|
| 267 |
+
python_path, pip_path = activate_virtual_environment()
|
| 268 |
+
|
| 269 |
+
download_openvino_utils(pip_path)
|
| 270 |
+
download_wav2lip_helpers(pip_path)
|
| 271 |
+
download_example_files()
|
| 272 |
+
install_requirements(pip_path)
|
| 273 |
+
clone_wav2lip_repo()
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
|
| 287 |
+
|