Integrate tested Seed-VC GPU conversion into Stimmatelier

This commit is contained in:
Mikei386 committed 2026-10-19 17:36:11 +02:00
1 parent 73e803e943
commit 1445152fec
22 files changed
+688 -17

No files matched your search

+4 -4
View File
@@ -15,7 +15,7 @@ def wav_input(audio):
except (wave.Error,EOFError,ZeroDivisionError):raise ValueError('Ungültige WAV-Datei.') from None
return audio
def read_upload(handler,field='profile_id'):
def read_upload(handler,field='profile_id',validator=wav_input,reference_required=True,auto_default=False):
if handler.headers.get('Transfer-Encoding'):raise ValueError('Chunked Upload wird nicht unterstützt.')
try:length=int(handler.headers.get('Content-Length','0'))
except ValueError:raise ValueError('Ungültige Upload-Länge.') from None
@@ -29,15 +29,15 @@ def read_upload(handler,field='profile_id'):
name=part.get_param('name',header='content-disposition');data=part.get_payload(decode=True)
if name not in (field,'source','reference','pitch_auto','pitch_semitones') or name in parts or part.is_multipart() or not isinstance(data,bytes):raise ValueError('Unbekanntes oder doppeltes Feld.')
parts[name]=data
if not {field,'source','reference'}<=set(parts) or not 1<=len(parts[field])<=128:raise ValueError('Profil, Quellaufnahme und Referenz erforderlich.')
if not ({field,'source','reference'} if reference_required else {field,'source'})<=set(parts) or not 1<=len(parts[field])<=128:raise ValueError('Profil, Quellaufnahme und Referenz erforderlich.')
try:name=parts[field].decode('utf-8')
except UnicodeError:raise ValueError('Ungültiger Profilname.') from None
try:
auto=parts.get('pitch_auto',b'false').decode('ascii');manual=parts.get('pitch_semitones',b'0').decode('ascii')
auto=parts.get('pitch_auto',b'true' if auto_default else b'false').decode('ascii');manual=parts.get('pitch_semitones',b'0').decode('ascii')
if len(auto)>5 or len(manual)>16 or auto not in ('true','false'):raise ValueError()
options=pitch_options(auto=='true',float(manual))
except (UnicodeError,ValueError):raise ValueError('Tonhöhe: pitch_auto=true/false und pitch_semitones zwischen -12 und12 erforderlich.') from None
return name,wav_input(parts['source']),wav_input(parts['reference']),options
return name,validator(parts['source']),validator(parts['reference']) if 'reference' in parts else None,options
def pitch_options(pitch_auto=False,pitch_semitones=0):
if not isinstance(pitch_auto,bool) or isinstance(pitch_semitones,bool) or not isinstance(pitch_semitones,(int,float)) or not math.isfinite(pitch_semitones) or not -12<=pitch_semitones<=12:raise ValueError('Ungültige Tonhöhenkorrektur.')