Update app.py
Browse files
app.py
CHANGED
@@ -45,18 +45,6 @@ def generate_story(caption):
|
|
45 |
else:
|
46 |
story = full_text.strip()
|
47 |
|
48 |
-
words = story.split()
|
49 |
-
if len(words) > 100:
|
50 |
-
trimmed = " ".join(words[:100])
|
51 |
-
last_period = trimmed.rfind(".")
|
52 |
-
last_exclam = trimmed.rfind("!")
|
53 |
-
last_question = trimmed.rfind("?")
|
54 |
-
end_index = max(last_period, last_exclam, last_question)
|
55 |
-
if end_index != -1:
|
56 |
-
trimmed = trimmed[:end_index+1]
|
57 |
-
story = trimmed
|
58 |
-
if story and story[-1] not in ".!?":
|
59 |
-
story += "."
|
60 |
return story
|
61 |
|
62 |
def text_to_speech(text, output_file="output.mp3"):
|
|
|
45 |
else:
|
46 |
story = full_text.strip()
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
return story
|
49 |
|
50 |
def text_to_speech(text, output_file="output.mp3"):
|