add error checking for mvsep
Browse files
app.py
CHANGED
@@ -211,26 +211,32 @@ def mvsep_api_request(mvsep_key, audio_file, sep_int):
|
|
211 |
return f"Request sent successfully! Your hash is: {hash_val}.\n\nUse the next tab to check the status of your request."
|
212 |
|
213 |
def mvsep_check_request(hash_textbox):
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
|
|
|
|
|
|
223 |
|
224 |
def mvsep_download_separated_audio(hash_textbox):
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
|
|
|
|
|
|
234 |
|
235 |
|
236 |
with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") as app:
|
|
|
211 |
return f"Request sent successfully! Your hash is: {hash_val}.\n\nUse the next tab to check the status of your request."
|
212 |
|
213 |
def mvsep_check_request(hash_textbox):
|
214 |
+
try:
|
215 |
+
url = "https://mvsep.com/api/separation/get"
|
216 |
+
params = {
|
217 |
+
"hash": hash_textbox
|
218 |
+
}
|
219 |
+
r = requests.get(url, params=params)
|
220 |
+
rjson = r.json()
|
221 |
+
success = rjson['success']
|
222 |
+
status = rjson['status']
|
223 |
+
return f"Was successful? {str(success)}.\n Status: {status}."
|
224 |
+
except requests.exceptions.JSONDecodeError:
|
225 |
+
return gr.Info("Status not available or request not sent.")
|
226 |
|
227 |
def mvsep_download_separated_audio(hash_textbox):
|
228 |
+
try:
|
229 |
+
url = "https://mvsep.com/api/separation/get"
|
230 |
+
params = {
|
231 |
+
"hash": hash_textbox
|
232 |
+
}
|
233 |
+
r = requests.get(url, params=params)
|
234 |
+
rjson = r.json()
|
235 |
+
files = rjson.get('data', {}).get('files', [])
|
236 |
+
urls = [file['url'] for file in files]
|
237 |
+
return json.dumps(urls, indent=4)
|
238 |
+
except requests.exceptions.JSONDecodeError:
|
239 |
+
return gr.Info("Nothing to download yet. Check back later.")
|
240 |
|
241 |
|
242 |
with gr.Blocks(theme='sudeepshouche/minimalist', title="Global Dataset Maker") as app:
|