Spaces:
Sleeping
Sleeping
salomonsky
commited on
Commit
路
972a12b
1
Parent(s):
fdbf59c
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,28 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import subprocess
|
4 |
from gtts import gTTS
|
5 |
from pydub import AudioSegment
|
6 |
-
from transformers import GPT2LMHeadModel, GPT2Tokenizer, pipeline
|
7 |
from PIL import Image
|
8 |
|
9 |
-
|
10 |
-
|
11 |
os.environ["TOKENIZERS_PARALLELISM"] = "true"
|
12 |
|
13 |
def generate_output(name, date_of_birth, progress=gr.Progress()):
|
14 |
-
prompt = f"
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
21 |
return None, "No se pudo generar el texto."
|
22 |
|
23 |
def _progress(generated, to_generate):
|
|
|
1 |
+
import openai
|
2 |
import gradio as gr
|
3 |
import os
|
4 |
import subprocess
|
5 |
from gtts import gTTS
|
6 |
from pydub import AudioSegment
|
|
|
7 |
from PIL import Image
|
8 |
|
9 |
+
openai.api_key = "openai_key" # Reemplaza "openai_key" con el nombre de tu clave de API de OpenAI
|
10 |
+
|
11 |
os.environ["TOKENIZERS_PARALLELISM"] = "true"
|
12 |
|
13 |
def generate_output(name, date_of_birth, progress=gr.Progress()):
|
14 |
+
prompt = f"{name}, tu mi or谩culo astrol贸gico de hoy es:"
|
15 |
+
response = openai.Completion.create(
|
16 |
+
engine="text-davinci-003",
|
17 |
+
prompt=prompt,
|
18 |
+
max_tokens=60,
|
19 |
+
temperature=0.6,
|
20 |
+
n=1,
|
21 |
+
stop=None,
|
22 |
+
)
|
23 |
+
gpt3_output = response.choices[0].text.strip()
|
24 |
+
generated_text = gpt3_output.replace(prompt, "").strip()
|
25 |
+
if len(response.choices) == 0 or 'text' not in response.choices[0]:
|
26 |
return None, "No se pudo generar el texto."
|
27 |
|
28 |
def _progress(generated, to_generate):
|