Matt09Miao commited on
Commit
ebd8530
·
verified ·
1 Parent(s): 62bc815

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
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="Generate Your Tweet and Toxicity Analysis",
5
+ page_icon="![image/png](https://cdn-uploads.huggingface.co/production/uploads/66f6b4f934e277e391ccbf93/F7rRfSUX7xBPfmUzG3Mn5.png)")
6
+
7
+ st.header("Please writedown the first word of a Tweet")
8
+ uploaded_file = st.file_uploader("Select an Image...")
9
+
10
+ if uploaded_file is not None:
11
+ print(uploaded_file)
12
+ bytes_data = uploaded_file.getvalue()
13
+ with open(uploaded_file.name, "wb") as file:
14
+ file.write(bytes_data)
15
+ st.image(uploaded_file, caption="Uploaded Image",
16
+ use_column_width=True)
17
+
18
+ #Stage 1: Image to Text
19
+ st.text('Processing img2text...')
20
+ scenario = img2text(uploaded_file.name)
21
+ st.write(scenario)
22
+
23
+ #Stage 2: Text to Story
24
+ st.text('Generating a story...')
25
+ story = text2story(scenario)
26
+ st.write(story)
27
+
28
+ #Stage 3: Story to Audio data
29
+ st.text('Generating audio data...')
30
+ audio_data =text2audio(story)
31
+
32
+ # Play button
33
+ if st.button("Play Audio"):
34
+ st.audio(audio_data['audio'],
35
+ format="audio/wav",
36
+ start_time=0,
37
+ sample_rate = audio_data['sampling_rate'])