Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -63,31 +63,31 @@ def main():
|
|
63 |
with open(image_path, "wb") as f:
|
64 |
f.write(uploaded_file.getbuffer())
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
|
92 |
# Add a Python standard entry check so that the program starts with main() | ๅ ๅ
ฅ Python ๆจๆบๅ
ฅๅฃๆชขๆฅ๏ผ่ฎ็จๅผๅพ main() ้ๅงๅท่ก
|
93 |
if __name__ == "__main__":
|
|
|
63 |
with open(image_path, "wb") as f:
|
64 |
f.write(uploaded_file.getbuffer())
|
65 |
|
66 |
+
# Load and Display Image | ่ฎๅไธฆ้กฏ็คบๅ็
|
67 |
+
image = Image.open(image_path)
|
68 |
+
st.image(image, caption="Uploaded Image", use_container_width=True)
|
69 |
+
|
70 |
+
# Generate Image Caption | ็ๆๅ็ๆ่ฟฐ
|
71 |
+
st.text("๐ Generating image caption...")
|
72 |
+
caption = img2text(image_path)
|
73 |
+
st.write("**Image Description:**", caption)
|
74 |
+
|
75 |
+
# Generate Story | ็ๆๆ
ไบ
|
76 |
+
st.text("๐ Generating story...")
|
77 |
+
story = text2story(caption)
|
78 |
+
st.write("**Generated Story:**")
|
79 |
+
st.write(story)
|
80 |
+
|
81 |
+
# Generate Audio | ็ๆ่ช้ณ
|
82 |
+
st.text("๐ Generating audio...")
|
83 |
+
audio_file = text2audio_gtts(story)
|
84 |
+
|
85 |
+
# Play Audio | ๆญๆพ้ณ้ ป
|
86 |
+
st.audio(audio_file, format="audio/mp3")
|
87 |
+
|
88 |
+
# Download Audio | ไธ่ผๆ้ฎ
|
89 |
+
with open(audio_file, "rb") as file:
|
90 |
+
st.download_button("๐ฅ Download Audio", file, file_name="story.mp3")
|
91 |
|
92 |
# Add a Python standard entry check so that the program starts with main() | ๅ ๅ
ฅ Python ๆจๆบๅ
ฅๅฃๆชขๆฅ๏ผ่ฎ็จๅผๅพ main() ้ๅงๅท่ก
|
93 |
if __name__ == "__main__":
|