Spaces:
Build error
Build error
Leo Liu commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,9 +23,9 @@ def text2audio(story_text):
|
|
| 23 |
|
| 24 |
|
| 25 |
def main():
|
| 26 |
-
st.set_page_config(page_title="Magic
|
| 27 |
-
|
| 28 |
-
#
|
| 29 |
st.markdown("""
|
| 30 |
<style>
|
| 31 |
@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@700&display=swap');
|
|
@@ -42,28 +42,24 @@ def main():
|
|
| 42 |
font-family: 'Comic Neue', cursive;
|
| 43 |
font-size: 2.5rem;
|
| 44 |
text-shadow: 2px 2px #FFF;
|
| 45 |
-
margin-bottom: 0.5rem !important;
|
| 46 |
}
|
| 47 |
|
| 48 |
</style>
|
| 49 |
""", unsafe_allow_html=True)
|
| 50 |
|
| 51 |
-
# 新版标题区
|
| 52 |
st.markdown("""
|
| 53 |
<div class="header">
|
| 54 |
-
<h1>🪄 Magic
|
| 55 |
</div>
|
| 56 |
""", unsafe_allow_html=True)
|
| 57 |
uploaded_file = st.file_uploader("🌈 Choose your magic picture...", type=["jpg", "png"])
|
| 58 |
|
| 59 |
if uploaded_file is not None:
|
| 60 |
-
# 保存上传文件(原有逻辑)
|
| 61 |
bytes_data = uploaded_file.getvalue()
|
| 62 |
with open(uploaded_file.name, "wb") as file:
|
| 63 |
file.write(bytes_data)
|
| 64 |
st.image(uploaded_file, caption="Your Magic Picture ✨", use_container_width=True)
|
| 65 |
-
|
| 66 |
-
# 初始化状态容器(修复点:移出if块)
|
| 67 |
status_container = st.empty()
|
| 68 |
progress_bar = st.progress(0)
|
| 69 |
|
|
@@ -85,7 +81,7 @@ def main():
|
|
| 85 |
with status_container.status("🎵 **Step 3/3**: Adding magic music...", expanded=True) as status:
|
| 86 |
progress_bar.progress(100)
|
| 87 |
audio_data = text2audio(story)
|
| 88 |
-
status.update(label="✅
|
| 89 |
|
| 90 |
# Auto-play the audio
|
| 91 |
st.audio(audio_data['audio'],
|
|
|
|
| 23 |
|
| 24 |
|
| 25 |
def main():
|
| 26 |
+
st.set_page_config(page_title="Magic Storyteller", page_icon="🧚")
|
| 27 |
+
|
| 28 |
+
# Optimize title area to attract children's attention
|
| 29 |
st.markdown("""
|
| 30 |
<style>
|
| 31 |
@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@700&display=swap');
|
|
|
|
| 42 |
font-family: 'Comic Neue', cursive;
|
| 43 |
font-size: 2.5rem;
|
| 44 |
text-shadow: 2px 2px #FFF;
|
| 45 |
+
margin-bottom: 0.5rem !important;
|
| 46 |
}
|
| 47 |
|
| 48 |
</style>
|
| 49 |
""", unsafe_allow_html=True)
|
| 50 |
|
|
|
|
| 51 |
st.markdown("""
|
| 52 |
<div class="header">
|
| 53 |
+
<h1>🪄 Magic Storyteller </h1>
|
| 54 |
</div>
|
| 55 |
""", unsafe_allow_html=True)
|
| 56 |
uploaded_file = st.file_uploader("🌈 Choose your magic picture...", type=["jpg", "png"])
|
| 57 |
|
| 58 |
if uploaded_file is not None:
|
|
|
|
| 59 |
bytes_data = uploaded_file.getvalue()
|
| 60 |
with open(uploaded_file.name, "wb") as file:
|
| 61 |
file.write(bytes_data)
|
| 62 |
st.image(uploaded_file, caption="Your Magic Picture ✨", use_container_width=True)
|
|
|
|
|
|
|
| 63 |
status_container = st.empty()
|
| 64 |
progress_bar = st.progress(0)
|
| 65 |
|
|
|
|
| 81 |
with status_container.status("🎵 **Step 3/3**: Adding magic music...", expanded=True) as status:
|
| 82 |
progress_bar.progress(100)
|
| 83 |
audio_data = text2audio(story)
|
| 84 |
+
status.update(label="✅ Playing the audio!", state="complete")
|
| 85 |
|
| 86 |
# Auto-play the audio
|
| 87 |
st.audio(audio_data['audio'],
|