Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -1241,20 +1241,39 @@ def get_audio_download_link(file_path):
|
|
1241 |
|
1242 |
|
1243 |
|
1244 |
-
|
1245 |
-
|
1246 |
# π΅ Wav Audio files - Transcription History in Wav
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1250 |
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
|
|
|
|
|
|
|
|
1254 |
os.remove(file)
|
1255 |
st.rerun()
|
1256 |
|
1257 |
-
|
|
|
1258 |
col1, col2 = st.sidebar.columns([6, 1]) # adjust the ratio as needed
|
1259 |
with col1:
|
1260 |
st.markdown(file)
|
@@ -1262,8 +1281,33 @@ for file in all_files:
|
|
1262 |
audio_file = open(file, 'rb')
|
1263 |
audio_bytes = audio_file.read()
|
1264 |
st.audio(audio_bytes, format='audio/wav')
|
1265 |
-
|
1266 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1267 |
with col2:
|
1268 |
if st.button("π", key="delete_" + file):
|
1269 |
os.remove(file)
|
|
|
1241 |
|
1242 |
|
1243 |
|
|
|
|
|
1244 |
# π΅ Wav Audio files - Transcription History in Wav
|
1245 |
+
audio_files = glob.glob("*.wav")
|
1246 |
+
audio_files = [file for file in audio_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
|
1247 |
+
audio_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
|
1248 |
+
|
1249 |
+
# πΌ PNG Image files
|
1250 |
+
image_files = glob.glob("*.png")
|
1251 |
+
image_files = [file for file in image_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
|
1252 |
+
image_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
|
1253 |
+
|
1254 |
+
# π₯ MP4 Video files
|
1255 |
+
video_files = glob.glob("*.mp4")
|
1256 |
+
video_files = [file for file in video_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
|
1257 |
+
video_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
|
1258 |
+
|
1259 |
+
# Delete All button for each file type
|
1260 |
+
if st.sidebar.button("π Delete All Audio"):
|
1261 |
+
for file in audio_files:
|
1262 |
+
os.remove(file)
|
1263 |
+
st.rerun()
|
1264 |
|
1265 |
+
if st.sidebar.button("π Delete All Images"):
|
1266 |
+
for file in image_files:
|
1267 |
+
os.remove(file)
|
1268 |
+
st.rerun()
|
1269 |
+
|
1270 |
+
if st.sidebar.button("π Delete All Videos"):
|
1271 |
+
for file in video_files:
|
1272 |
os.remove(file)
|
1273 |
st.rerun()
|
1274 |
|
1275 |
+
# Display and handle audio files
|
1276 |
+
for file in audio_files:
|
1277 |
col1, col2 = st.sidebar.columns([6, 1]) # adjust the ratio as needed
|
1278 |
with col1:
|
1279 |
st.markdown(file)
|
|
|
1281 |
audio_file = open(file, 'rb')
|
1282 |
audio_bytes = audio_file.read()
|
1283 |
st.audio(audio_bytes, format='audio/wav')
|
1284 |
+
with col2:
|
1285 |
+
if st.button("π", key="delete_" + file):
|
1286 |
+
os.remove(file)
|
1287 |
+
st.rerun()
|
1288 |
+
|
1289 |
+
# Display and handle image files
|
1290 |
+
for file in image_files:
|
1291 |
+
col1, col2 = st.sidebar.columns([6, 1]) # adjust the ratio as needed
|
1292 |
+
with col1:
|
1293 |
+
st.markdown(file)
|
1294 |
+
if st.button("πΌ", key="show_" + file): # show emoji button
|
1295 |
+
image = open(file, 'rb').read()
|
1296 |
+
st.image(image)
|
1297 |
+
with col2:
|
1298 |
+
if st.button("π", key="delete_" + file):
|
1299 |
+
os.remove(file)
|
1300 |
+
st.rerun()
|
1301 |
+
|
1302 |
+
# Display and handle video files
|
1303 |
+
for file in video_files:
|
1304 |
+
col1, col2 = st.sidebar.columns([6, 1]) # adjust the ratio as needed
|
1305 |
+
with col1:
|
1306 |
+
st.markdown(file)
|
1307 |
+
if st.button("π₯", key="play_" + file): # play emoji button
|
1308 |
+
video_file = open(file, 'rb')
|
1309 |
+
video_bytes = video_file.read()
|
1310 |
+
st.video(video_bytes)
|
1311 |
with col2:
|
1312 |
if st.button("π", key="delete_" + file):
|
1313 |
os.remove(file)
|