Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ global openai_api_key
|
|
16 |
|
17 |
#openai_api_key = os.environ.get("OPENAI_API_KEY")
|
18 |
|
19 |
-
|
20 |
|
21 |
def split_text_into_sentences(text):
|
22 |
sentences = []
|
@@ -49,7 +49,9 @@ def join_wav_files(input_files, output_file):
|
|
49 |
with wave.open(input_file, 'rb') as input:
|
50 |
output.writeframes(input.readframes(input.getnframes()))
|
51 |
|
52 |
-
def generate_story(text, lang, age):
|
|
|
|
|
53 |
"""Generate a story using the langchain library and OpenAI's GPT-3 model."""
|
54 |
prompt = PromptTemplate(
|
55 |
input_variables=["text", "lang", "age"],
|
@@ -96,8 +98,7 @@ def generate_story(text, lang, age):
|
|
96 |
return story_result, 'output.mp3'
|
97 |
|
98 |
def app(text, lang, age, openai_key):
|
99 |
-
|
100 |
-
story = generate_story(text, lang, age)
|
101 |
return story
|
102 |
|
103 |
css = """
|
|
|
16 |
|
17 |
#openai_api_key = os.environ.get("OPENAI_API_KEY")
|
18 |
|
19 |
+
|
20 |
|
21 |
def split_text_into_sentences(text):
|
22 |
sentences = []
|
|
|
49 |
with wave.open(input_file, 'rb') as input:
|
50 |
output.writeframes(input.readframes(input.getnframes()))
|
51 |
|
52 |
+
def generate_story(text, lang, age, openai_key):
|
53 |
+
openai_api_key = openai_key
|
54 |
+
llm = OpenAI(temperature=0.9, max_tokens=-1)
|
55 |
"""Generate a story using the langchain library and OpenAI's GPT-3 model."""
|
56 |
prompt = PromptTemplate(
|
57 |
input_variables=["text", "lang", "age"],
|
|
|
98 |
return story_result, 'output.mp3'
|
99 |
|
100 |
def app(text, lang, age, openai_key):
|
101 |
+
story = generate_story(text, lang, age, openai_key)
|
|
|
102 |
return story
|
103 |
|
104 |
css = """
|