Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -133,6 +133,7 @@ def main():
|
|
| 133 |
layout="wide",
|
| 134 |
initial_sidebar_state="collapsed"
|
| 135 |
)
|
|
|
|
| 136 |
|
| 137 |
# Title and description
|
| 138 |
st.title("π§ββοΈ Fantasy Adventure Story Generator")
|
|
@@ -142,6 +143,17 @@ def main():
|
|
| 142 |
- AI-generated adventure story
|
| 143 |
- Audio version of the story
|
| 144 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
# File uploader
|
| 147 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
|
@@ -162,26 +174,20 @@ def main():
|
|
| 162 |
# Generate outputs and Display results
|
| 163 |
with col2:
|
| 164 |
st.subheader("π Scene Description")
|
| 165 |
-
|
| 166 |
-
|
|
|
|
| 167 |
|
| 168 |
st.subheader("π Generated Story")
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
|
|
|
| 172 |
|
| 173 |
st.subheader("π Audio Playback")
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
with open(speech["audio"], "rb") as audio_file:
|
| 179 |
-
st.download_button(
|
| 180 |
-
label="π₯ Download Audio",
|
| 181 |
-
data=audio_file,
|
| 182 |
-
file_name="fantasy_adventure.wav",
|
| 183 |
-
mime="audio/wav"
|
| 184 |
-
)
|
| 185 |
-
|
| 186 |
if __name__ == "__main__":
|
| 187 |
main()
|
|
|
|
| 133 |
layout="wide",
|
| 134 |
initial_sidebar_state="collapsed"
|
| 135 |
)
|
| 136 |
+
|
| 137 |
|
| 138 |
# Title and description
|
| 139 |
st.title("π§ββοΈ Fantasy Adventure Story Generator")
|
|
|
|
| 143 |
- AI-generated adventure story
|
| 144 |
- Audio version of the story
|
| 145 |
""")
|
| 146 |
+
|
| 147 |
+
# Help section
|
| 148 |
+
st.markdown("---")
|
| 149 |
+
st.subheader("π How to Use:")
|
| 150 |
+
st.info("""
|
| 151 |
+
1. Upload any picture (animals, nature, or people work best!)
|
| 152 |
+
2. Choose your favorite story style
|
| 153 |
+
3. Click the confirmation button
|
| 154 |
+
4. Wait for image analysis to complete
|
| 155 |
+
5. Enjoy your personalized story and audio!
|
| 156 |
+
""")
|
| 157 |
|
| 158 |
# File uploader
|
| 159 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
|
|
|
| 174 |
# Generate outputs and Display results
|
| 175 |
with col2:
|
| 176 |
st.subheader("π Scene Description")
|
| 177 |
+
with st.spinner("Preparing story caption..."):
|
| 178 |
+
caption = generate_image_caption(image)
|
| 179 |
+
st.write(caption)
|
| 180 |
|
| 181 |
st.subheader("π Generated Story")
|
| 182 |
+
with st.spinner("Preparing story..."):
|
| 183 |
+
sys_prompt = "You are a fantasy writer. Create a 100-word adventure story about "
|
| 184 |
+
story = generate_story_content(sys_prompt, caption)
|
| 185 |
+
st.write(story)
|
| 186 |
|
| 187 |
st.subheader("π Audio Playback")
|
| 188 |
+
with st.spinner("Preparing speech..."):
|
| 189 |
+
speech = generate_audio_from_story(story)
|
| 190 |
+
st.audio(speech["audio"], sample_rate=speech["sampling_rate"], format='audio/wav')
|
| 191 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
if __name__ == "__main__":
|
| 193 |
main()
|