Leo Liu commited on
Commit
6adb3a5
ยท
verified ยท
1 Parent(s): 76b5990

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -16
app.py CHANGED
@@ -23,9 +23,15 @@ def text2audio(story_text):
23
 
24
 
25
  def main():
26
- st.set_page_config(page_title="Your Image to Audio Story", page_icon="๐Ÿฆœ")
27
- st.header("Turn Your Image to Audio Story")
28
- uploaded_file = st.file_uploader("Select an Image...")
 
 
 
 
 
 
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
- st.text('๐Ÿ” Analyzing image...')
40
- scenario = img2text(uploaded_file.name)
41
- st.write(scenario)
 
 
42
 
43
  #Stage 2: Text to Story
44
- st.text('๐Ÿ“– Generating story...')
45
- story = text2story(scenario)
46
- st.write(story)
 
 
47
 
48
  #Stage 3: Story to Audio data
49
- st.text('๐ŸŽง Converting to audio...')
50
- audio_data =text2audio(story)
 
 
51
 
52
- # Play button
53
- if st.button("Play Audio Story"):
54
  st.audio(audio_data['audio'],
55
- format="audio/wav",
56
- start_time=0,
57
- sample_rate = audio_data['sampling_rate'])
 
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__":