Update app.py
Browse files
app.py
CHANGED
@@ -127,7 +127,23 @@ def split_by_dur(file_upload, dur_to_cut):
|
|
127 |
return f"Trimmed to {ms_to_min} minutes successfully.", temp_file.name
|
128 |
except Exception as e:
|
129 |
return gr.Error(traceback.format_exc())
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
with gr.Blocks(theme='bethecloud/storj_theme', title="Global Dataset Maker") as app:
|
133 |
gr.HTML(
|
@@ -284,8 +300,21 @@ with gr.Blocks(theme='bethecloud/storj_theme', title="Global Dataset Maker") as
|
|
284 |
[hash_textbox],
|
285 |
[gr.Text(label="Link(s)")]
|
286 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
|
288 |
with gr.TabItem("Changelog"):
|
|
|
289 |
gr.Markdown("v1 - Not the most exciting v1 release. **Removed yt functions as they are no longer working.**")
|
290 |
gr.Markdown("v0.99.9 - Added new tool: Split audio file by duration.")
|
291 |
|
|
|
127 |
return f"Trimmed to {ms_to_min} minutes successfully.", temp_file.name
|
128 |
except Exception as e:
|
129 |
return gr.Error(traceback.format_exc())
|
130 |
+
|
131 |
+
def zip_to_many(zip_upload):
|
132 |
+
temp_dir = "temp_audio_files"
|
133 |
+
os.makedirs(temp_dir, exist_ok=True)
|
134 |
+
with zipfile.ZipFile(zip_upload, 'r') as zip_ref:
|
135 |
+
zip_ref.extractall(temp_dir)
|
136 |
+
audio_files = [os.path.join(temp_dir, f) for f in os.listdir(temp_dir) if f.endswith(('.mp3', '.wav', '.ogg'))]
|
137 |
+
combined_audio = AudioSegment.empty()
|
138 |
+
for audio_file in audio_files:
|
139 |
+
audio = AudioSegment.from_file(audio_file)
|
140 |
+
combined_audio += audio
|
141 |
+
output_path = "combined_audio.mp3"
|
142 |
+
combined_audio.export(output_path, format="mp3")
|
143 |
+
for audio_file in audio_files:
|
144 |
+
os.remove(audio_file)
|
145 |
+
os.rmdir(temp_dir)
|
146 |
+
return "Done.", output_path
|
147 |
|
148 |
with gr.Blocks(theme='bethecloud/storj_theme', title="Global Dataset Maker") as app:
|
149 |
gr.HTML(
|
|
|
300 |
[hash_textbox],
|
301 |
[gr.Text(label="Link(s)")]
|
302 |
)
|
303 |
+
with gr.Tab("Convert many audio files to one file"):
|
304 |
+
gr.Markdown("Upload a ZIP full of many audio files and this will attempt to convert it to one long audio file.")
|
305 |
+
with gr.Row():
|
306 |
+
with gr.Column():
|
307 |
+
with gr.Row():
|
308 |
+
zip_upload = gr.File(file_count='single', file_types=[".zip"], label="Zip file")
|
309 |
+
combine_btn = gr.Button("Combine", variant='primary')
|
310 |
+
combine_btn.click(
|
311 |
+
zip_to_many,
|
312 |
+
[zip_upload],
|
313 |
+
[gr.Text(label="Status"), gr.File(label="Combined file")]
|
314 |
+
)
|
315 |
|
316 |
with gr.TabItem("Changelog"):
|
317 |
+
gr.Markdown("v1.1 - Added new tool: Convert many audio files to one file.")
|
318 |
gr.Markdown("v1 - Not the most exciting v1 release. **Removed yt functions as they are no longer working.**")
|
319 |
gr.Markdown("v0.99.9 - Added new tool: Split audio file by duration.")
|
320 |
|