Spaces:
Sleeping
Sleeping
Commit
路
296785f
1
Parent(s):
cc06a8a
Update app.py
Browse files
app.py
CHANGED
@@ -7,9 +7,9 @@ from pydub import AudioSegment
|
|
7 |
|
8 |
openai.api_key = os.environ.get("openai_api_key")
|
9 |
|
10 |
-
def generate_output(name, horoscope_type):
|
11 |
image_filename = f"{horoscope_type.lower()}.jpg" # Construye el nombre de la imagen
|
12 |
-
prompt = f"
|
13 |
response = openai.Completion.create(
|
14 |
engine="text-davinci-003",
|
15 |
prompt=prompt,
|
@@ -19,12 +19,12 @@ def generate_output(name, horoscope_type):
|
|
19 |
stop=None,
|
20 |
)
|
21 |
gpt3_output = response.choices[0].text.strip()
|
22 |
-
generated_text = gpt3_output.
|
23 |
if len(response.choices) == 0 or 'text' not in response.choices[0]:
|
24 |
return None, "No se pudo generar el texto."
|
25 |
|
26 |
try:
|
27 |
-
tts = gTTS(generated_text, lang='es')
|
28 |
temp_audio_path = "temp_audio.mp3"
|
29 |
tts.save(temp_audio_path)
|
30 |
audio_path = "audio.wav"
|
@@ -49,10 +49,11 @@ def generate_output(name, horoscope_type):
|
|
49 |
|
50 |
name_input = gr.inputs.Textbox(lines=1, placeholder="Escribe tu Nombre Completo")
|
51 |
horoscope_type_radio = gr.inputs.Radio(["Griego", "Egipcio", "Maya", "Chino", "Celta", "Hindu"], label="Tipo de Hor贸scopo")
|
|
|
52 |
output = gr.outputs.Video(label=None)
|
53 |
|
54 |
-
def generate_and_display_output(name, horoscope_type):
|
55 |
-
video_path, error_message = generate_output(name, horoscope_type)
|
56 |
if error_message:
|
57 |
print(f"Error: {error_message}")
|
58 |
else:
|
@@ -60,10 +61,10 @@ def generate_and_display_output(name, horoscope_type):
|
|
60 |
|
61 |
iface = gr.Interface(
|
62 |
fn=generate_and_display_output,
|
63 |
-
inputs=[name_input, horoscope_type_radio],
|
64 |
outputs=output,
|
65 |
title="Hor贸scopo con Inteligencia Artificial v2.1",
|
66 |
-
description="Ingresa tu nombre
|
67 |
layout="vertical",
|
68 |
theme="dark"
|
69 |
)
|
|
|
7 |
|
8 |
openai.api_key = os.environ.get("openai_api_key")
|
9 |
|
10 |
+
def generate_output(name, horoscope_type, birth_date):
|
11 |
image_filename = f"{horoscope_type.lower()}.jpg" # Construye el nombre de la imagen
|
12 |
+
prompt = f"Tu hor贸scopo {horoscope_type} y or谩culo de hoy para {name} nacido el {birth_date} es:"
|
13 |
response = openai.Completion.create(
|
14 |
engine="text-davinci-003",
|
15 |
prompt=prompt,
|
|
|
19 |
stop=None,
|
20 |
)
|
21 |
gpt3_output = response.choices[0].text.strip()
|
22 |
+
generated_text = gpt3_output.strip()
|
23 |
if len(response.choices) == 0 or 'text' not in response.choices[0]:
|
24 |
return None, "No se pudo generar el texto."
|
25 |
|
26 |
try:
|
27 |
+
tts = gTTS(f"Tu hor贸scopo {horoscope_type} para {name} nacido el {birth_date} es: {generated_text}", lang='es')
|
28 |
temp_audio_path = "temp_audio.mp3"
|
29 |
tts.save(temp_audio_path)
|
30 |
audio_path = "audio.wav"
|
|
|
49 |
|
50 |
name_input = gr.inputs.Textbox(lines=1, placeholder="Escribe tu Nombre Completo")
|
51 |
horoscope_type_radio = gr.inputs.Radio(["Griego", "Egipcio", "Maya", "Chino", "Celta", "Hindu"], label="Tipo de Hor贸scopo")
|
52 |
+
birth_date_input = gr.inputs.Date(label="Fecha de Nacimiento")
|
53 |
output = gr.outputs.Video(label=None)
|
54 |
|
55 |
+
def generate_and_display_output(name, horoscope_type, birth_date):
|
56 |
+
video_path, error_message = generate_output(name, horoscope_type, birth_date)
|
57 |
if error_message:
|
58 |
print(f"Error: {error_message}")
|
59 |
else:
|
|
|
61 |
|
62 |
iface = gr.Interface(
|
63 |
fn=generate_and_display_output,
|
64 |
+
inputs=[name_input, horoscope_type_radio, birth_date_input],
|
65 |
outputs=output,
|
66 |
title="Hor贸scopo con Inteligencia Artificial v2.1",
|
67 |
+
description="Ingresa tu nombre, tipo de hor贸scopo y fecha de nacimiento.",
|
68 |
layout="vertical",
|
69 |
theme="dark"
|
70 |
)
|