Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,15 +9,14 @@ st.set_page_config(
|
|
| 9 |
layout="centered"
|
| 10 |
)
|
| 11 |
|
| 12 |
-
#
|
| 13 |
st.markdown("<h1 style='text-align: center; color: #FF69B4;'>🎨 Picture to Story 🎤</h1>", unsafe_allow_html=True)
|
| 14 |
st.markdown("<h3 style='text-align: center;'>Upload your picture and hear a magical story! 🧚</h3>", unsafe_allow_html=True)
|
| 15 |
|
| 16 |
-
#
|
| 17 |
uploaded_file = st.file_uploader("📸 Choose a picture of your drawing, pet, or toy!", type=["jpg", "png", "jpeg"])
|
| 18 |
|
| 19 |
if uploaded_file is not None:
|
| 20 |
-
# ✅ 保存到临时路径
|
| 21 |
temp_path = os.path.join("/tmp", uploaded_file.name)
|
| 22 |
with open(temp_path, "wb") as f:
|
| 23 |
f.write(uploaded_file.getvalue())
|
|
@@ -37,13 +36,12 @@ if uploaded_file is not None:
|
|
| 37 |
with st.spinner("🔊 Turning story into voice..."):
|
| 38 |
audio_file = text2audio(story)
|
| 39 |
|
| 40 |
-
# ✅ 直接展示播放器而不是按钮
|
| 41 |
if audio_file:
|
| 42 |
st.success("✨ All done! Here's your magical story!")
|
| 43 |
st.markdown("▶️ **Click the play button below to listen!**")
|
| 44 |
st.audio(audio_file, format="audio/wav")
|
| 45 |
|
| 46 |
-
#
|
| 47 |
st.markdown("""
|
| 48 |
<hr>
|
| 49 |
<p style='text-align:center; color: grey; font-size: 0.9em'>
|
|
|
|
| 9 |
layout="centered"
|
| 10 |
)
|
| 11 |
|
| 12 |
+
# title
|
| 13 |
st.markdown("<h1 style='text-align: center; color: #FF69B4;'>🎨 Picture to Story 🎤</h1>", unsafe_allow_html=True)
|
| 14 |
st.markdown("<h3 style='text-align: center;'>Upload your picture and hear a magical story! 🧚</h3>", unsafe_allow_html=True)
|
| 15 |
|
| 16 |
+
# upload picture
|
| 17 |
uploaded_file = st.file_uploader("📸 Choose a picture of your drawing, pet, or toy!", type=["jpg", "png", "jpeg"])
|
| 18 |
|
| 19 |
if uploaded_file is not None:
|
|
|
|
| 20 |
temp_path = os.path.join("/tmp", uploaded_file.name)
|
| 21 |
with open(temp_path, "wb") as f:
|
| 22 |
f.write(uploaded_file.getvalue())
|
|
|
|
| 36 |
with st.spinner("🔊 Turning story into voice..."):
|
| 37 |
audio_file = text2audio(story)
|
| 38 |
|
|
|
|
| 39 |
if audio_file:
|
| 40 |
st.success("✨ All done! Here's your magical story!")
|
| 41 |
st.markdown("▶️ **Click the play button below to listen!**")
|
| 42 |
st.audio(audio_file, format="audio/wav")
|
| 43 |
|
| 44 |
+
# bottom
|
| 45 |
st.markdown("""
|
| 46 |
<hr>
|
| 47 |
<p style='text-align:center; color: grey; font-size: 0.9em'>
|