Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -36,24 +36,13 @@ def text2story(text):
|
|
36 |
Returns:
|
37 |
str: Generated story suitable for kids aged 3-10, within 100 words.
|
38 |
"""
|
39 |
-
|
40 |
-
prompt = f"Write a kids story based on below scenario :{text}."
|
41 |
-
|
42 |
# Load the text generation model
|
43 |
story_generator = pipeline("text-generation", model="pranavpsv/gpt2-genre-story-generator")
|
44 |
|
45 |
# Generate the story
|
46 |
-
story = story_generator(
|
47 |
-
|
48 |
-
# Remove the prompt from the generated story
|
49 |
-
story = story.replace(prompt, "").strip()
|
50 |
-
|
51 |
-
# Ensure the story is within 100 words
|
52 |
-
story_words = story.split()
|
53 |
-
if len(story_words) > 100:
|
54 |
-
story = " ".join(story_words[:100])
|
55 |
|
56 |
-
return story
|
57 |
|
58 |
# Function to convert text to audio using gTTS
|
59 |
def text2audio(story_text):
|
|
|
36 |
Returns:
|
37 |
str: Generated story suitable for kids aged 3-10, within 100 words.
|
38 |
"""
|
39 |
+
|
|
|
|
|
40 |
# Load the text generation model
|
41 |
story_generator = pipeline("text-generation", model="pranavpsv/gpt2-genre-story-generator")
|
42 |
|
43 |
# Generate the story
|
44 |
+
story = story_generator(f"<BOS> <superhero> {text}"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
|
|
46 |
|
47 |
# Function to convert text to audio using gTTS
|
48 |
def text2audio(story_text):
|