Eason918 commited on
Commit
fab3813
ยท
verified ยท
1 Parent(s): 083ac07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -25
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
- # 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__":
 
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__":