Restore readable vocals and instrumental ZIP filenames
This commit is contained in:
1 parent
932284a831
commit
96c394cd6c
3 files changed
+10
-2
No files matched your search
@@ -7,6 +7,10 @@ from email.parser import BytesParser
|
||||
BASE='http://127.0.0.1:8108'
|
||||
CONFIG=Path('/data/deck-connection.json')
|
||||
TARGETS={'vocals':'model_bs_roformer_ep_317_sdr_12.9755.ckpt','drums':'htdemucs_ft.yaml','bass':'htdemucs_ft.yaml','guitar':'htdemucs_6s.yaml','piano':'htdemucs_6s.yaml','other':'htdemucs_6s.yaml'}
|
||||
def archive_name(target,filename):
|
||||
if target not in TARGETS:raise ValueError('Unbekannte Zielspur.')
|
||||
if Path(filename).name=='rest.wav':return 'Instrumental.wav' if target=='vocals' else 'Rest.wav'
|
||||
return {'vocals':'Vocals','drums':'Drums','bass':'Bass','guitar':'Guitar','piano':'Piano','other':'Other'}[target]+'.wav'
|
||||
def request(path,body=None,ctype='application/json',token=None):
|
||||
if token is None:token=json.loads(CONFIG.read_text())['token'] if CONFIG.exists() else ''
|
||||
if not token:raise ValueError('Zuerst die Deck-Verbindung einrichten.')
|
||||
@@ -71,7 +75,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if current['state']!='complete':raise ValueError(current['phase'])
|
||||
result=io.BytesIO()
|
||||
with zipfile.ZipFile(result,'w',zipfile.ZIP_STORED) as bundle:
|
||||
for f in current['files']:bundle.writestr(Path(f['name']).name,request(f"/api/v1/separator-tests/audio?id={ident}&index={f['index']}"))
|
||||
for f in current['files']:bundle.writestr(archive_name(target,f['name']),request(f"/api/v1/separator-tests/audio?id={ident}&index={f['index']}"))
|
||||
return self.send(result.getvalue(),mime='application/zip')
|
||||
raise ValueError('Trennauftrag hat das Zeitlimit überschritten.')
|
||||
except Exception as exc:return self.send({'detail':str(exc) if isinstance(exc,ValueError) else 'Verarbeitung fehlgeschlagen; Verbindung und Audioformat prüfen.'},400)
|
||||
|
||||
Reference in new issue
Block a user