Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,21 @@
|
|
| 1 |
import os
|
| 2 |
-
import openai
|
| 3 |
import streamlit as st
|
| 4 |
import subprocess
|
| 5 |
from gtts import gTTS
|
| 6 |
import cv2
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
|
| 10 |
def generate_output(name, birth_date):
|
| 11 |
if not birth_date:
|
| 12 |
return None, "El campo de fecha de nacimiento es obligatorio."
|
| 13 |
|
| 14 |
prompt = f"T煤 hor贸scopo de hoy, si naciste el {birth_date}, es:"
|
| 15 |
-
response =
|
| 16 |
-
|
| 17 |
-
prompt=prompt,
|
| 18 |
-
max_tokens=180,
|
| 19 |
-
temperature=0.6,
|
| 20 |
-
n=1,
|
| 21 |
-
stop=None,
|
| 22 |
-
)
|
| 23 |
-
gpt3_output = response.choices[0].text.strip()
|
| 24 |
personalized_response = f"Tu hor贸scopo {name} nacido el {birth_date} es: {gpt3_output}"
|
| 25 |
|
| 26 |
-
if len(response.choices) == 0 or 'text' not in response.choices[0]:
|
| 27 |
-
return None, "No se pudo generar el texto."
|
| 28 |
-
|
| 29 |
try:
|
| 30 |
tts = gTTS(personalized_response, lang='es')
|
| 31 |
audio_path = "audio.mp3"
|
|
@@ -54,5 +44,5 @@ if st.button("Generar Video"):
|
|
| 54 |
if error_message:
|
| 55 |
st.error(f"Error: {error_message}")
|
| 56 |
else:
|
| 57 |
-
|
| 58 |
-
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
import subprocess
|
| 4 |
from gtts import gTTS
|
| 5 |
import cv2
|
| 6 |
+
from huggingface_hub import InferenceClient
|
| 7 |
|
| 8 |
+
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 9 |
|
| 10 |
def generate_output(name, birth_date):
|
| 11 |
if not birth_date:
|
| 12 |
return None, "El campo de fecha de nacimiento es obligatorio."
|
| 13 |
|
| 14 |
prompt = f"T煤 hor贸scopo de hoy, si naciste el {birth_date}, es:"
|
| 15 |
+
response = client.text_generation(prompt, max_new_tokens=180, temperature=0.6)
|
| 16 |
+
gpt3_output = response[0]['generated_text'].strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
personalized_response = f"Tu hor贸scopo {name} nacido el {birth_date} es: {gpt3_output}"
|
| 18 |
|
|
|
|
|
|
|
|
|
|
| 19 |
try:
|
| 20 |
tts = gTTS(personalized_response, lang='es')
|
| 21 |
audio_path = "audio.mp3"
|
|
|
|
| 44 |
if error_message:
|
| 45 |
st.error(f"Error: {error_message}")
|
| 46 |
else:
|
| 47 |
+
video_file = open(video_path, "rb").read()
|
| 48 |
+
st.video(video_file)
|