JSY8 commited on
Commit
be244f0
Β·
verified Β·
1 Parent(s): 6f34278

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
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
- # Split into words and trim to 100 words
55
- words = clean_raw.split()
56
- story = " ".join(words[:100])
 
 
 
 
 
 
 
 
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])