Spaces:
Runtime error
Runtime error
hillman2000hk
commited on
Commit
•
e6edfc7
1
Parent(s):
cb498de
Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ from langchain.llms import GooglePalm
|
|
10 |
|
11 |
load_dotenv(find_dotenv())
|
12 |
|
13 |
-
llm = GooglePalm(temperature=0.9, google_api_key=os.getenv("GOOGLE_API_KEY"))
|
14 |
|
15 |
# Iamge to Text
|
16 |
def image_to_text(url):
|
@@ -23,21 +23,7 @@ def image_to_text(url):
|
|
23 |
return text
|
24 |
|
25 |
# llm
|
26 |
-
|
27 |
-
template = """
|
28 |
-
you are a very good story teller and a very rude person:
|
29 |
-
you can generate a short fairy tail based on a single narrative, the story should take 5 seconds to read.
|
30 |
-
|
31 |
-
CONTEXT: {scenario}
|
32 |
-
STORY:
|
33 |
-
"""
|
34 |
-
|
35 |
-
prompt = PromptTemplate(template=template, input_variables=["scenario"])
|
36 |
-
story_llm = LLMChain(llm=llm, prompt=prompt, verbose=True)
|
37 |
-
story = story_llm.predict(scenario=scenario)
|
38 |
-
print(story)
|
39 |
-
return story
|
40 |
-
|
41 |
# text to speech
|
42 |
|
43 |
def text_to_speech(message):
|
@@ -62,15 +48,11 @@ def main():
|
|
62 |
file.write(bytes_data)
|
63 |
st.image(uploaded_file, caption='Uploaded Image.', use_column_width=True)
|
64 |
scenario = image_to_text(uploaded_file.name)
|
65 |
-
|
66 |
-
text_to_speech(story)
|
67 |
|
68 |
with st.expander("scenerio"):
|
69 |
st.write(scenario)
|
70 |
-
|
71 |
-
st.write(story)
|
72 |
-
|
73 |
-
st.audio("audio.mp3")
|
74 |
|
75 |
if __name__ == '__main__':
|
76 |
main()
|
|
|
10 |
|
11 |
load_dotenv(find_dotenv())
|
12 |
|
13 |
+
#llm = GooglePalm(temperature=0.9, google_api_key=os.getenv("GOOGLE_API_KEY"))
|
14 |
|
15 |
# Iamge to Text
|
16 |
def image_to_text(url):
|
|
|
23 |
return text
|
24 |
|
25 |
# llm
|
26 |
+
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
# text to speech
|
28 |
|
29 |
def text_to_speech(message):
|
|
|
48 |
file.write(bytes_data)
|
49 |
st.image(uploaded_file, caption='Uploaded Image.', use_column_width=True)
|
50 |
scenario = image_to_text(uploaded_file.name)
|
51 |
+
|
|
|
52 |
|
53 |
with st.expander("scenerio"):
|
54 |
st.write(scenario)
|
55 |
+
|
|
|
|
|
|
|
56 |
|
57 |
if __name__ == '__main__':
|
58 |
main()
|