Update app.py
Browse files
app.py
CHANGED
@@ -445,20 +445,38 @@ language_dict = {
|
|
445 |
}
|
446 |
}
|
447 |
|
|
|
|
|
448 |
def create_download_link(audio_path):
|
449 |
if audio_path is None:
|
450 |
return None
|
451 |
|
452 |
filename = Path(audio_path).name
|
453 |
-
base_url = "https://hivecorp-w-t-p-01.hf.space"
|
454 |
-
file_url = f"{base_url}/gradio_api/file={audio_path}"
|
455 |
|
456 |
return f"""
|
457 |
-
<a href="{file_url}"
|
458 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
</a>
|
460 |
"""
|
461 |
|
|
|
|
|
462 |
def cleanup_file(filepath, delay=300): # 300 seconds = 5 minutes
|
463 |
def delete_file():
|
464 |
try:
|
|
|
445 |
}
|
446 |
}
|
447 |
|
448 |
+
|
449 |
+
|
450 |
def create_download_link(audio_path):
|
451 |
if audio_path is None:
|
452 |
return None
|
453 |
|
454 |
filename = Path(audio_path).name
|
455 |
+
base_url = "https://hivecorp-w-t-p-01.hf.space"
|
456 |
+
file_url = f"{base_url}/gradio_api/file={audio_path}"
|
457 |
|
458 |
return f"""
|
459 |
+
<a href="{file_url}"
|
460 |
+
download="{filename}"
|
461 |
+
target="_blank"
|
462 |
+
rel="noopener noreferrer"
|
463 |
+
onclick="event.preventDefault(); fetch(this.href).then(resp => resp.blob()).then(blob => {{
|
464 |
+
const url = window.URL.createObjectURL(blob);
|
465 |
+
const a = document.createElement('a');
|
466 |
+
a.style.display = 'none';
|
467 |
+
a.href = url;
|
468 |
+
a.download = '{filename}';
|
469 |
+
document.body.appendChild(a);
|
470 |
+
a.click();
|
471 |
+
window.URL.revokeObjectURL(url);
|
472 |
+
document.body.removeChild(a);
|
473 |
+
}});">
|
474 |
+
Click here to download audio
|
475 |
</a>
|
476 |
"""
|
477 |
|
478 |
+
|
479 |
+
|
480 |
def cleanup_file(filepath, delay=300): # 300 seconds = 5 minutes
|
481 |
def delete_file():
|
482 |
try:
|