EmmaL1 commited on
Commit
04fe24c
·
verified ·
1 Parent(s): 733173b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -12,11 +12,17 @@ def img2text(img):
12
 
13
  # text2story
14
  def text2story(text):
 
 
15
  text_generation_model = pipeline("text-generation",
16
- model="distilbert/distilgpt2")
17
- story_text = text_generation_model + " Once upon a time, in a faraway land, there lived a magical creature. This creature had the power to..."
18
- while len(story_text.split()) < 100:
19
- story_text += " additional content to make the story longer."
 
 
 
 
20
 
21
  # text2audio
22
  def text2audio(story_text):
@@ -48,7 +54,7 @@ if uploaded_file is not None:
48
  # stage 2
49
  st.text('Generating a story...')
50
  scenario = text2story(scenario)
51
- st.write(story_text)
52
 
53
  # stage 3
54
  st.text('Generating audio data...')
 
12
 
13
  # text2story
14
  def text2story(text):
15
+ prompt = "Once upon a time in a land far, far away"
16
+
17
  text_generation_model = pipeline("text-generation",
18
+ model="distilbert/distilgpt2")
19
+
20
+ generated_story = text_generation_model(prompt,
21
+ max_length=100,
22
+ num_return_sequences=1)
23
+
24
+ print("The story is here......")
25
+ print(generated_story[0]['generated_text'])
26
 
27
  # text2audio
28
  def text2audio(story_text):
 
54
  # stage 2
55
  st.text('Generating a story...')
56
  scenario = text2story(scenario)
57
+ st.write(generated_story)
58
 
59
  # stage 3
60
  st.text('Generating audio data...')