Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
st.set_page_config(page_title="Your Image to Audio Story",
|
5 |
+
page_icon="🦜")
|
6 |
+
st.header("Turn Your Image to Audio Story")
|
7 |
+
uploaded_file = st.file_uploader("Select an Image...")
|
8 |
+
|
9 |
+
if uploaded_file is not None:
|
10 |
+
print(uploaded_file)
|
11 |
+
bytes_data = uploaded_file.getvalue()
|
12 |
+
with open(uploaded_file.name, "wb") as file:
|
13 |
+
file.write(bytes_data)
|
14 |
+
st.image(uploaded_file, caption="Uploaded Image",
|
15 |
+
use_column_width=True)
|
16 |
+
|
17 |
+
#Stage 1: Image to Text
|
18 |
+
st.text('Processing img2text...')
|
19 |
+
scenario = img2text(uploaded_file.name)
|
20 |
+
st.write(scenario)
|
21 |
+
|
22 |
+
#Stage 2: Text to Story
|
23 |
+
st.text('Generating a story...')
|
24 |
+
#story = text2story(scenario)
|
25 |
+
#st.write(story)
|
26 |
+
|
27 |
+
#Stage 3: Story to Audio data
|
28 |
+
#st.text('Generating audio data...')
|
29 |
+
#audio_data =text2audio(story)
|
30 |
+
|
31 |
+
# Play button
|
32 |
+
if st.button("Play Audio"):
|
33 |
+
#st.audio(audio_data['audio'],
|
34 |
+
# format="audio/wav",
|
35 |
+
# start_time=0,
|
36 |
+
# sample_rate = audio_data['sampling_rate'])
|
37 |
+
st.audio("kids_playing_audio.wav")
|