Spaces:
Runtime error
Runtime error
ver 1.5
Browse files- __pycache__/app.cpython-38.pyc +0 -0
- app.py +27 -3
__pycache__/app.cpython-38.pyc
CHANGED
Binary files a/__pycache__/app.cpython-38.pyc and b/__pycache__/app.cpython-38.pyc differ
|
|
app.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2 |
import re
|
3 |
import io
|
4 |
import torch
|
|
|
5 |
import requests
|
6 |
import torchaudio
|
7 |
import numpy as np
|
@@ -207,10 +208,21 @@ def srt_to_audio_multi(srt_files):
|
|
207 |
output_paths.append(result)
|
208 |
|
209 |
if invalid_files:
|
210 |
-
raise
|
211 |
|
212 |
return output_paths
|
213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
# Initialize model
|
215 |
model = Model(
|
216 |
model_name=default_model_name,
|
@@ -229,12 +241,24 @@ with gr.Blocks(css=css) as demo:
|
|
229 |
elem_id="title",
|
230 |
)
|
231 |
with gr.Row(elem_id="container"):
|
232 |
-
inp = gr.File(
|
233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
|
235 |
btn = gr.Button("Generate")
|
|
|
236 |
|
237 |
btn.click(fn=srt_to_audio_multi, inputs=inp, outputs=out)
|
|
|
238 |
|
239 |
if __name__ == "__main__":
|
240 |
demo.launch()
|
|
|
2 |
import re
|
3 |
import io
|
4 |
import torch
|
5 |
+
import shutil
|
6 |
import requests
|
7 |
import torchaudio
|
8 |
import numpy as np
|
|
|
208 |
output_paths.append(result)
|
209 |
|
210 |
if invalid_files:
|
211 |
+
raise gr.Warning(f"Invalid SRT files: {', '.join(invalid_files)}")
|
212 |
|
213 |
return output_paths
|
214 |
|
215 |
+
def download_all(outputs):
|
216 |
+
# If no outputs, return None
|
217 |
+
if not outputs:
|
218 |
+
raise gr.Warning("No files available for download.")
|
219 |
+
|
220 |
+
zip_path = os.path.join(cache_dir, "all_outputs.zip")
|
221 |
+
with shutil.ZipFile(zip_path, 'w') as zipf:
|
222 |
+
for file_path in outputs:
|
223 |
+
zipf.write(file_path, os.path.basename(file_path))
|
224 |
+
return zip_path
|
225 |
+
|
226 |
# Initialize model
|
227 |
model = Model(
|
228 |
model_name=default_model_name,
|
|
|
241 |
elem_id="title",
|
242 |
)
|
243 |
with gr.Row(elem_id="container"):
|
244 |
+
inp = gr.File(
|
245 |
+
label="Upload SRT files",
|
246 |
+
file_count="multiple",
|
247 |
+
type="filepath",
|
248 |
+
height=600
|
249 |
+
)
|
250 |
+
out = gr.File(
|
251 |
+
label="Generated Audio Files",
|
252 |
+
file_count="multiple",
|
253 |
+
type="filepath",
|
254 |
+
height=600
|
255 |
+
)
|
256 |
|
257 |
btn = gr.Button("Generate")
|
258 |
+
download_btn = gr.Button("Download All")
|
259 |
|
260 |
btn.click(fn=srt_to_audio_multi, inputs=inp, outputs=out)
|
261 |
+
download_btn.click(fn=download_all, inputs=out, outputs="file")
|
262 |
|
263 |
if __name__ == "__main__":
|
264 |
demo.launch()
|