Spaces:
Build error
Build error
Paul Ke commited on
Update streamlit_app.py
Browse files- streamlit_app.py +14 -40
streamlit_app.py
CHANGED
|
@@ -164,46 +164,15 @@ if st.session_state["videos"]:
|
|
| 164 |
except Exception as e:
|
| 165 |
st.write("Couldn't show video")
|
| 166 |
|
| 167 |
-
try:
|
| 168 |
-
video_file = open(st.session_state["videos"], "rb")
|
| 169 |
-
st.download_button(
|
| 170 |
-
"**Download Video π**",
|
| 171 |
-
data=video_file,
|
| 172 |
-
file_name=f"{st.session_state['videos'].lower().translate(str.maketrans('', '', string.punctuation)).replace(' ', '_')}.mp4",
|
| 173 |
-
mime="video/mp4",
|
| 174 |
-
type="primary",
|
| 175 |
-
)
|
| 176 |
-
except Exception as e:
|
| 177 |
-
st.error("Failed downloading the video", icon="π")
|
| 178 |
-
|
| 179 |
-
# URL input for video
|
| 180 |
-
video_url = video_path
|
| 181 |
-
|
| 182 |
# Analysis prompt
|
| 183 |
analysis_prompt = st.sidebar.text_area("Enter analysis")
|
| 184 |
|
| 185 |
if st.button('Generate the story'):
|
| 186 |
-
|
| 187 |
-
st.sidebar.warning('PLEASE ENTER A VALID URL')
|
| 188 |
-
else:
|
| 189 |
-
# Download the video
|
| 190 |
-
with st.spinner("Retrieving video..."):
|
| 191 |
-
temp_video_path = os.path.join(tempfile.gettempdir(), 'video.mp4')
|
| 192 |
-
success, message = download_video(video_url, temp_video_path)
|
| 193 |
-
|
| 194 |
-
if not success:
|
| 195 |
-
st.sidebar.error(f"Error downloading video: {message}")
|
| 196 |
-
else:
|
| 197 |
-
st.sidebar.success(message)
|
| 198 |
-
|
| 199 |
-
# Display the video
|
| 200 |
-
st.sidebar.divider()
|
| 201 |
-
st.sidebar.video(temp_video_path, format="video/mp4", start_time=0, loop=True, autoplay=True)
|
| 202 |
-
|
| 203 |
try:
|
| 204 |
with st.spinner("Generating the story of the video"):
|
| 205 |
# Upload and process the video
|
| 206 |
-
processed_video = upload_file(
|
| 207 |
while processed_video.state.name == "PROCESSING":
|
| 208 |
time.sleep(1)
|
| 209 |
processed_video = get_file(processed_video.name)
|
|
@@ -216,10 +185,15 @@ if st.button('Generate the story'):
|
|
| 216 |
|
| 217 |
except Exception as error:
|
| 218 |
st.sidebar.error(f"An error occurred: {error}")
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
except Exception as e:
|
| 165 |
st.write("Couldn't show video")
|
| 166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
# Analysis prompt
|
| 168 |
analysis_prompt = st.sidebar.text_area("Enter analysis")
|
| 169 |
|
| 170 |
if st.button('Generate the story'):
|
| 171 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
try:
|
| 173 |
with st.spinner("Generating the story of the video"):
|
| 174 |
# Upload and process the video
|
| 175 |
+
processed_video = upload_file(st.session_state["videos"], "rb")
|
| 176 |
while processed_video.state.name == "PROCESSING":
|
| 177 |
time.sleep(1)
|
| 178 |
processed_video = get_file(processed_video.name)
|
|
|
|
| 185 |
|
| 186 |
except Exception as error:
|
| 187 |
st.sidebar.error(f"An error occurred: {error}")
|
| 188 |
+
|
| 189 |
+
try:
|
| 190 |
+
video_file = open(st.session_state["videos"], "rb")
|
| 191 |
+
st.download_button(
|
| 192 |
+
"**Download Video π**",
|
| 193 |
+
data=video_file,
|
| 194 |
+
file_name=f"{st.session_state['videos'].lower().translate(str.maketrans('', '', string.punctuation)).replace(' ', '_')}.mp4",
|
| 195 |
+
mime="video/mp4",
|
| 196 |
+
type="primary",
|
| 197 |
+
)
|
| 198 |
+
except Exception as e:
|
| 199 |
+
st.error("Failed downloading the video", icon="π")
|