Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import re
|
|
|
3 |
from transformers import pipeline
|
4 |
|
5 |
def img2text(url):
|
@@ -17,6 +18,13 @@ def text2story(text):
|
|
17 |
if story_text.startswith(". "):
|
18 |
story_text = story_text[2:]
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
# Split into sentences
|
21 |
sentences = re.split(r'(?<=[.!?])\s+', story_text.strip())
|
22 |
|
@@ -43,7 +51,7 @@ def text2story(text):
|
|
43 |
return final_story
|
44 |
|
45 |
def text2audio(story_text):
|
46 |
-
audio_generator = pipeline("text-to-speech", model="
|
47 |
audio_output = audio_generator(story_text)
|
48 |
return audio_output
|
49 |
|
|
|
1 |
import streamlit as st
|
2 |
import re
|
3 |
+
import string
|
4 |
from transformers import pipeline
|
5 |
|
6 |
def img2text(url):
|
|
|
18 |
if story_text.startswith(". "):
|
19 |
story_text = story_text[2:]
|
20 |
|
21 |
+
# Capitalize the first alphabetic character if it's lowercase
|
22 |
+
for i, char in enumerate(story_text):
|
23 |
+
if char.isalpha():
|
24 |
+
if char.islower():
|
25 |
+
story_text = story_text[:i] + char.upper() + story_text[i+1:]
|
26 |
+
break
|
27 |
+
|
28 |
# Split into sentences
|
29 |
sentences = re.split(r'(?<=[.!?])\s+', story_text.strip())
|
30 |
|
|
|
51 |
return final_story
|
52 |
|
53 |
def text2audio(story_text):
|
54 |
+
audio_generator = pipeline("text-to-speech", model="microsoft/speecht5_tts")
|
55 |
audio_output = audio_generator(story_text)
|
56 |
return audio_output
|
57 |
|