File size: 1,821 Bytes
a16a4f0
ab14faa
a16a4f0
 
ab14faa
460b461
a16a4f0
460b461
a16a4f0
 
 
 
 
3a26773
460b461
3a26773
 
a16a4f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a26773
a16a4f0
3a26773
ab14faa
 
 
a16a4f0
 
ab14faa
a16a4f0
460b461
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import streamlit as st
import subprocess
from gtts import gTTS
import cv2
from huggingface_hub import InferenceClient

client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")

def generate_output(name, birth_date):
    if not birth_date:
        return None, "El campo de fecha de nacimiento es obligatorio."

    prompt = f"Tu hor贸scopo de hoy, si naciste el {birth_date}, es:"
    response = client.text_generation(prompt, max_new_tokens=180, temperature=0.6)
    gpt3_output = response.strip()  # Acceso directo al texto generado
    personalized_response = f"Tu hor贸scopo {name}, nacido el {birth_date}, es: {gpt3_output}"
    
    try:
        tts = gTTS(personalized_response, lang='es')
        audio_path = "audio.mp3"
        tts.save(audio_path)
    except Exception as e:
        return None, f"No se pudo generar el audio: {str(e)}"

    video_path = "video.mp4"
    command = f"python3 inference.py --checkpoint_path checkpoints/wav2lip_gan.pth --face face.jpg --audio {audio_path} --outfile {video_path} --nosmooth"
    process = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
    if process.returncode != 0:
        error_message = process.stderr
        return None, f"No se pudo generar el video: {error_message}"

    if os.path.isfile(video_path):
        return video_path, None
    return None, "No se pudo generar el video"

st.title("Or谩culo del Hor贸scopo")

name = st.text_input("Nombre", "Escribe tu nick")
birth_date = st.text_input("Fecha de Nacimiento", "DD/MM/AAAA")

if st.button("Generar Video"):
    video_path, error_message = generate_output(name, birth_date)
    if error_message:
        st.error(f"Error: {error_message}")
    else:
        video_file = open(video_path, "rb").read()
        st.video(video_file)