Spaces:
Runtime error
Runtime error
Commit
·
9622ab6
1
Parent(s):
5d80bfb
Update app.py
Browse files
app.py
CHANGED
@@ -35,13 +35,18 @@ def image_to_text(url, use_api=True):
|
|
35 |
|
36 |
# LLM
|
37 |
def generate_story(story_idea):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
template = """
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
STORY:
|
44 |
-
"""
|
45 |
prompt = PromptTemplate(input_variables=["story_idea"], template=template)
|
46 |
|
47 |
story_llm = LLMChain(llm=OpenAI(model_name='gpt-3.5-turbo-0301', temperature=1), prompt=prompt, verbose=True)
|
@@ -50,7 +55,7 @@ def generate_story(story_idea):
|
|
50 |
|
51 |
# text to speech
|
52 |
def text_to_speech(story):
|
53 |
-
API_URL = "https://api-inference.huggingface.co/models/
|
54 |
headers = {"Authorization": f"Bearer {HUGGINGFACEHUB_API_TOKEN}"}
|
55 |
|
56 |
payloads = {
|
@@ -86,7 +91,8 @@ def main():
|
|
86 |
st.write(image_description)
|
87 |
|
88 |
story = generate_story(story_idea=image_description)
|
89 |
-
story_starter_text = "Yo ho Radio Nepal, prastut xa sun nai parne katha: "
|
|
|
90 |
story = story_starter_text + story
|
91 |
|
92 |
# Display story text on FE
|
|
|
35 |
|
36 |
# LLM
|
37 |
def generate_story(story_idea):
|
38 |
+
# template = """
|
39 |
+
# You are a professional song writter;
|
40 |
+
# Generate a song based on a simple narrative, the song should be no more than 100 words.
|
41 |
+
# Song should be in Nepali language
|
42 |
+
# CONTEXT: {story_idea}
|
43 |
+
# STORY:
|
44 |
+
# """
|
45 |
template = """
|
46 |
+
you are a song writer, write a song using following context:
|
47 |
+
{story_idea}.
|
48 |
+
Song should not be more than 100 words. Write in Nepali language
|
49 |
+
"""
|
|
|
|
|
50 |
prompt = PromptTemplate(input_variables=["story_idea"], template=template)
|
51 |
|
52 |
story_llm = LLMChain(llm=OpenAI(model_name='gpt-3.5-turbo-0301', temperature=1), prompt=prompt, verbose=True)
|
|
|
55 |
|
56 |
# text to speech
|
57 |
def text_to_speech(story):
|
58 |
+
API_URL = "https://api-inference.huggingface.co/models/espnet/kan-bayashi_ljspeech_vits"
|
59 |
headers = {"Authorization": f"Bearer {HUGGINGFACEHUB_API_TOKEN}"}
|
60 |
|
61 |
payloads = {
|
|
|
91 |
st.write(image_description)
|
92 |
|
93 |
story = generate_story(story_idea=image_description)
|
94 |
+
# story_starter_text = "Yo ho Radio Nepal, prastut xa sun nai parne katha: "
|
95 |
+
story_starter_text = ""
|
96 |
story = story_starter_text + story
|
97 |
|
98 |
# Display story text on FE
|