Spaces:
Sleeping
Sleeping
Leo Liu
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -23,9 +23,15 @@ def text2audio(story_text):
|
|
23 |
|
24 |
|
25 |
def main():
|
26 |
-
st.set_page_config(page_title="
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
if uploaded_file is not None:
|
31 |
print(uploaded_file)
|
@@ -36,25 +42,32 @@ def main():
|
|
36 |
|
37 |
|
38 |
#Stage 1: Image to Text
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
42 |
|
43 |
#Stage 2: Text to Story
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
47 |
|
48 |
#Stage 3: Story to Audio data
|
49 |
-
|
50 |
-
|
|
|
|
|
51 |
|
52 |
-
|
53 |
-
|
54 |
st.audio(audio_data['audio'],
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
58 |
|
59 |
|
60 |
if __name__ == "__main__":
|
|
|
23 |
|
24 |
|
25 |
def main():
|
26 |
+
st.set_page_config(page_title="Magic Story Box", page_icon="๐ง")
|
27 |
+
# ๆฐ็ๆ ้ขๅบ
|
28 |
+
st.markdown("""
|
29 |
+
<div class="header">
|
30 |
+
<h1>๐ช Magic Picture Story Box ๐ง</h1>
|
31 |
+
<h4 style="color:#4ECDC4;">Upload any photo โ Get a fairy tale!</h4>
|
32 |
+
</div>
|
33 |
+
""", unsafe_allow_html=True)
|
34 |
+
uploaded_file = st.file_uploader("๐ Choose your magic picture...", type=["jpg", "png"])
|
35 |
|
36 |
if uploaded_file is not None:
|
37 |
print(uploaded_file)
|
|
|
42 |
|
43 |
|
44 |
#Stage 1: Image to Text
|
45 |
+
with status_container.status("๐ฎ **Step 1/3**: Decoding picture magic...", expanded=True) as status:
|
46 |
+
progress_bar.progress(33)
|
47 |
+
scenario = img2text(uploaded_file.name)
|
48 |
+
status.update(label="โ
Picture decoded!", state="complete")
|
49 |
+
st.write(f"**What I see:** {scenario}")
|
50 |
|
51 |
#Stage 2: Text to Story
|
52 |
+
with status_container.status("๐ **Step 2/3**: Writing your fairy tale...", expanded=True) as status:
|
53 |
+
progress_bar.progress(66)
|
54 |
+
story = text2story(scenario)
|
55 |
+
status.update(label="โ
Story created!", state="complete")
|
56 |
+
st.write(f"**Your Story:**\n{story}")
|
57 |
|
58 |
#Stage 3: Story to Audio data
|
59 |
+
with status_container.status("๐ต **Step 3/3**: Adding magic music...", expanded=True) as status:
|
60 |
+
progress_bar.progress(100)
|
61 |
+
audio_data = text2audio(story)
|
62 |
+
status.update(label="โ
All ready!", state="complete")
|
63 |
|
64 |
+
|
65 |
+
# ่ชๅจๆญๆพ๏ผ็งป้คๆ้ฎ๏ผ
|
66 |
st.audio(audio_data['audio'],
|
67 |
+
format="audio/wav",
|
68 |
+
start_time=0,
|
69 |
+
sample_rate=audio_data['sampling_rate'],
|
70 |
+
autoplay=True) # ๆฐๅข่ชๅจๆญๆพๅๆฐ
|
71 |
|
72 |
|
73 |
if __name__ == "__main__":
|