fffiloni commited on
Commit
e5d255d
1 Parent(s): 10e0303

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -45,13 +45,14 @@ def join_wav_files(input_files, output_file):
45
  with wave.open(input_file, 'rb') as input:
46
  output.writeframes(input.readframes(input.getnframes()))
47
 
48
- def generate_story(text):
49
  """Generate a story using the langchain library and OpenAI's GPT-3 model."""
50
  prompt = PromptTemplate(
51
  input_variables=["text"],
52
  template="""
53
  You are a fun and seasoned storyteller.
54
  Generate a short bedtime story for a 5 years old audience about {text}.
 
55
  Use short sentences. The story is not too long, but not too short either.
56
  Always finish your story with "The End".
57
  """
@@ -72,7 +73,7 @@ def generate_story(text):
72
  result = eleven.predict(
73
  chunk, # str representing input in 'Input Text (250 characters max)' Textbox component
74
  "Bella", # str representing input in 'Voice' Dropdown component
75
- "eleven_monolingual_v1", # str representing input in 'Model' Radio component
76
  fn_index=0
77
  )
78
  print(result)
@@ -94,10 +95,11 @@ a {text-decoration-line: underline; font-weight: 600;}
94
  with gr.Blocks(css=css) as demo:
95
  with gr.Column(elem_id="col-container"):
96
  text = gr.Textbox(label="Subject", info="Will generate and tell a story about {your text input}")
 
97
  submit_btn = gr.Button('Submit')
98
  audio = gr.Audio(label="The story audio told")
99
  story = gr.Textbox(label="The story text")
100
 
101
- submit_btn.click(fn=app, inputs=[text], outputs=[story, audio])
102
 
103
  demo.launch()
 
45
  with wave.open(input_file, 'rb') as input:
46
  output.writeframes(input.readframes(input.getnframes()))
47
 
48
+ def generate_story(text, lang):
49
  """Generate a story using the langchain library and OpenAI's GPT-3 model."""
50
  prompt = PromptTemplate(
51
  input_variables=["text"],
52
  template="""
53
  You are a fun and seasoned storyteller.
54
  Generate a short bedtime story for a 5 years old audience about {text}.
55
+ Your story must be written in {lang}.
56
  Use short sentences. The story is not too long, but not too short either.
57
  Always finish your story with "The End".
58
  """
 
73
  result = eleven.predict(
74
  chunk, # str representing input in 'Input Text (250 characters max)' Textbox component
75
  "Bella", # str representing input in 'Voice' Dropdown component
76
+ "eleven_multilingual_v1", # str representing input in 'Model' Radio component
77
  fn_index=0
78
  )
79
  print(result)
 
95
  with gr.Blocks(css=css) as demo:
96
  with gr.Column(elem_id="col-container"):
97
  text = gr.Textbox(label="Subject", info="Will generate and tell a story about {your text input}")
98
+ lang = gr.Dropdown(label="Pick a language", choices=["English", "French", "German", "Hindi", "Italian", "Polish", "Portuguese", "Spanish"], value="English")
99
  submit_btn = gr.Button('Submit')
100
  audio = gr.Audio(label="The story audio told")
101
  story = gr.Textbox(label="The story text")
102
 
103
+ submit_btn.click(fn=app, inputs=[text, lang], outputs=[story, audio])
104
 
105
  demo.launch()