Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -51,15 +51,18 @@ raw = storyer(
|
|
51 |
allowed_pattern = re.compile(r'[a-zA-Z0-9.,!?"\'-]+\b(?<!\b\w\b)')
|
52 |
clean_raw = ' '.join(word for word in re.findall(allowed_pattern, raw) if len(word) > 1)
|
53 |
|
54 |
-
|
55 |
-
words
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
-
story = clean_generated_story(raw)
|
59 |
-
st.write("**π Your funny story: π**")
|
60 |
-
st.write(story)
|
61 |
-
return story
|
62 |
-
|
63 |
# Generate audio from cleaned story
|
64 |
chunks = textwrap.wrap(story, width=200)
|
65 |
audio = np.concatenate([tts(chunk)["audio"].squeeze() for chunk in chunks])
|
|
|
51 |
allowed_pattern = re.compile(r'[a-zA-Z0-9.,!?"\'-]+\b(?<!\b\w\b)')
|
52 |
clean_raw = ' '.join(word for word in re.findall(allowed_pattern, raw) if len(word) > 1)
|
53 |
|
54 |
+
def generate_story(raw, caption, tts):
|
55 |
+
# Split into words and trim to 100 words
|
56 |
+
words = raw.split()
|
57 |
+
story = " ".join(words[:100])
|
58 |
+
|
59 |
+
# Clean the story using clean_generated_story
|
60 |
+
story = clean_generated_story(raw)
|
61 |
+
|
62 |
+
# Display story in Streamlit
|
63 |
+
st.write("**π Your funny story: π**")
|
64 |
+
st.write(story)
|
65 |
|
|
|
|
|
|
|
|
|
|
|
66 |
# Generate audio from cleaned story
|
67 |
chunks = textwrap.wrap(story, width=200)
|
68 |
audio = np.concatenate([tts(chunk)["audio"].squeeze() for chunk in chunks])
|