Show direct audio stem download links in OpenWebUI chat
This commit is contained in:
1 parent
34b63bedeb
commit
0c6037868b
3 files changed
+21
-8
No files matched your search
@@ -15,7 +15,9 @@ Audio **als Datei in OpenWebUI hochladen**, dann zum Beispiel:
|
||||
- „Bereinige die Sprachaufnahme.“ → `Speech.wav` und `Background.wav`
|
||||
|
||||
Die Dateieinträge erscheinen im Chat. Anklicken öffnet OpenWebUIs Audio-Vorschau
|
||||
mit Player und Download. Die Dateien bleiben nach einem Browser-Refresh verfügbar.
|
||||
mit Player. Zusätzlich schreibt das Plugin für jede Spur einen direkten
|
||||
Downloadlink in den Chat, unabhängig von der Modellantwort. Die Dateien bleiben
|
||||
nach einem Browser-Refresh verfügbar. Keine zusätzliche Workspace-Kopie nötig.
|
||||
Gitarre/Piano sind experimentelle Demucs-6s-Spuren, keine perfekte Isolation.
|
||||
Unterstützt: Gesang, Schlagzeug, Bass, Gitarre, Piano, übrige Instrumente und Sprache.
|
||||
Maximal 20 Minuten und 256 MiB Eingabe; MP3/FLAC/M4A/WAV und andere von FFmpeg
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
title: Athena Audio-Trennung
|
||||
author: Athena Deck
|
||||
description: Trennt hochgeladene Audiodateien auf Athena und liefert einzelne WAV-Spuren mit Vorschau und Download.
|
||||
version: 1.0.0
|
||||
version: 1.0.1
|
||||
"""
|
||||
import asyncio
|
||||
import tempfile
|
||||
@@ -35,6 +35,16 @@ class Tools:
|
||||
def __init__(self):
|
||||
self.valves = self.Valves()
|
||||
|
||||
@staticmethod
|
||||
async def _publish_results(attachments, emitter):
|
||||
links = ['[' + item['name'] + ' herunterladen](' + item['url'] + '?attachment=true)' for item in attachments]
|
||||
content = '\n\n**Audio herunterladen:**\n\n' + '\n'.join('- ' + link for link in links) + '\n\n'
|
||||
if emitter:
|
||||
await emitter({'type': 'chat:message:files', 'data': {'files': attachments}})
|
||||
# Emit ourselves: the model may omit download links from its summary.
|
||||
await emitter({'type': 'message', 'data': {'content': content}})
|
||||
return content
|
||||
|
||||
@staticmethod
|
||||
def _attachment(files, filename):
|
||||
candidates = {}
|
||||
@@ -160,7 +170,6 @@ class Tools:
|
||||
raise ValueError(job.get('phase') or 'Audio-Trennung fehlgeschlagen.')
|
||||
await status('WAV-Spuren im Chat bereitstellen')
|
||||
attachments = []
|
||||
links = []
|
||||
for item in job['files']:
|
||||
is_rest = item['name'] == 'rest.wav'
|
||||
if output == 'isolated' and is_rest or output == 'rest' and not is_rest:
|
||||
@@ -184,13 +193,11 @@ class Tools:
|
||||
url = '/api/v1/files/' + file_id + '/content'
|
||||
attachments.append({'id': file_id, 'type': 'file', 'name': name, 'url': url,
|
||||
'size': size, 'content_type': 'audio/wav', 'file': data})
|
||||
links.append('[' + name + '](' + url + '?attachment=true)')
|
||||
if not attachments:
|
||||
raise ValueError('Keine passende Ergebnisspur vorhanden.')
|
||||
if __event_emitter__:
|
||||
await __event_emitter__({'type': 'chat:message:files', 'data': {'files': attachments}})
|
||||
downloads = await self._publish_results(attachments, __event_emitter__)
|
||||
await status('Audio-Trennung fertig', done=True)
|
||||
return 'Fertig: ' + ' · '.join(links) + '. Die WAV-Dateien sind im Chat angehängt. Zum Anhören einen Dateieintrag öffnen. Keine ZIP erforderlich.'
|
||||
return 'Fertig. Die WAV-Dateien sind im Chat angehängt. Downloadlinks wurden direkt im Chat angezeigt; nicht nochmals wiederholen. Zum Anhören einen Dateieintrag öffnen.' if __event_emitter__ else 'Fertig.' + downloads
|
||||
except asyncio.CancelledError:
|
||||
# Deck owns the job independently. Do not cancel a potentially shared/finished GPU job.
|
||||
raise
|
||||
|
||||
@@ -53,6 +53,9 @@ async def main():
|
||||
files = [f for e in events if e['type'] == 'chat:message:files' for f in e['data']['files']]
|
||||
file_ids.extend(f['id'] for f in files)
|
||||
assert sorted(f['name'] for f in files) == ['Instrumental.wav', 'Vocals.wav'], result
|
||||
downloads = ''.join(e['data']['content'] for e in events if e['type'] == 'message')
|
||||
for file in files:
|
||||
assert '[' + file['name'] + ' herunterladen](' + file['url'] + '?attachment=true)' in downloads
|
||||
async with aiohttp.ClientSession(headers={'Authorization': 'Bearer ' + token}) as session:
|
||||
for file in files:
|
||||
async with session.get('http://127.0.0.1:8080' + file['url']) as response:
|
||||
@@ -60,8 +63,9 @@ async def main():
|
||||
payload = await response.read()
|
||||
assert payload[:4] == b'RIFF'
|
||||
# Native FileItem audio preview authenticates with the existing login cookie.
|
||||
async with session.get('http://127.0.0.1:8080' + files[0]['url'], headers={'Authorization': ''}, cookies={'token': token}) as response:
|
||||
async with session.get('http://127.0.0.1:8080' + files[0]['url'] + '?attachment=true', headers={'Authorization': ''}, cookies={'token': token}) as response:
|
||||
assert response.status == 200
|
||||
assert response.headers.get('Content-Disposition', '').startswith('attachment;')
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get('http://127.0.0.1:8080' + files[0]['url']) as response:
|
||||
assert response.status == 401
|
||||
|
||||
Reference in new issue
Block a user