Spaces:
Sleeping
Sleeping
Upload ui.html
Browse files- templates/ui.html +13 -3
templates/ui.html
CHANGED
@@ -47,14 +47,24 @@ $(document).ready(function() {
|
|
47 |
data: formData,
|
48 |
success: function(data) {
|
49 |
if (data.audio_id) {
|
50 |
-
// Assuming your Flask route returns a JSON with an 'audio_id' key
|
51 |
// Update the source of the processed audio element
|
52 |
$('#processedAudio source').attr('src', '/get_processed_audio/' + data.audio_id);
|
53 |
$('#processedAudio')[0].load();
|
54 |
$('#processedAudio')[0].play();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
} else {
|
56 |
-
//
|
57 |
-
alert("
|
58 |
}
|
59 |
},
|
60 |
cache: false,
|
|
|
47 |
data: formData,
|
48 |
success: function(data) {
|
49 |
if (data.audio_id) {
|
|
|
50 |
// Update the source of the processed audio element
|
51 |
$('#processedAudio source').attr('src', '/get_processed_audio/' + data.audio_id);
|
52 |
$('#processedAudio')[0].load();
|
53 |
$('#processedAudio')[0].play();
|
54 |
+
} else if (data.error) {
|
55 |
+
// Display error message from the server
|
56 |
+
alert(data.error);
|
57 |
+
}
|
58 |
+
},
|
59 |
+
error: function(xhr, status, error) {
|
60 |
+
// Handle different types of error status codes
|
61 |
+
if(xhr.status === 429) {
|
62 |
+
alert("Too many requests, please try again later.");
|
63 |
+
} else if(xhr.status === 400) {
|
64 |
+
alert("Bad request. Please check the input and try again.");
|
65 |
} else {
|
66 |
+
// Generic error message for other statuses
|
67 |
+
alert("An error occurred: " + xhr.status + " " + error);
|
68 |
}
|
69 |
},
|
70 |
cache: false,
|