Add voice control mode, OmniVoice worker and managed voice studios
This commit is contained in:
1 parent
260740994f
commit
5fa8e6de90
33 files changed
+411
-64
No files matched your search
@@ -10,6 +10,7 @@ from http.cookies import SimpleCookie, CookieError
|
||||
from auth import CredentialStore, verify_password
|
||||
from catalog import Catalog
|
||||
from voxcpm_runtime import VoxCPMRuntime
|
||||
from omnivoice_runtime import OmniVoiceRuntime
|
||||
from tts_runtime import TTSRuntime
|
||||
from stt import STT,read_upload
|
||||
from audio_policy import AudioPolicy
|
||||
@@ -87,6 +88,8 @@ class Server(ThreadingHTTPServer):
|
||||
self.profiles.prompt_enhancer_ready=lambda task:bool(self.prompt_enhancer.installed(task))
|
||||
self.profiles.image_runtime_ready=lambda:self.image_tests.status()["runtime_installed"]
|
||||
self.voxcpm_runtime=VoxCPMRuntime(self.catalog.root.parent/'voxcpm-runtime',self.image_runtime)
|
||||
self.omnivoice_runtime=OmniVoiceRuntime(self.catalog.root.parent/'omnivoice-runtime',self.image_runtime)
|
||||
self.profiles.omnivoice_runtime_ready=lambda:self.omnivoice_runtime.status()['installed']
|
||||
self.profiles.voxcpm_runtime_ready=lambda:self.voxcpm_runtime.status()['installed']
|
||||
self.tts_runtime=TTSRuntime(self.catalog.root.parent/'tts-runtime')
|
||||
self.tts_tests=TTSTests(self.catalog.root.parent/'tts-tests',self.profiles,self.tts_runtime)
|
||||
@@ -106,6 +109,7 @@ class Server(ThreadingHTTPServer):
|
||||
self.worker=LlamaWorker(self.catalog.root.parent/'llama-worker',self.catalog,self.runtime)
|
||||
self.scheduler=Scheduler(self.worker)
|
||||
self.voxcpm_tests=VoxCPMTests(self.catalog.root.parent/'voice-tests',self.profiles,self.voxcpm_runtime)
|
||||
self.voxcpm_tests.omni_runtime=self.omnivoice_runtime
|
||||
self.voxcpm_tests.acquire=lambda wait=False:self.scheduler.image_reservation(wait,kind='voice')
|
||||
self.separator_runtime=SeparatorRuntime(self.catalog.root.parent/'separator-runtime')
|
||||
self.separator_tests=SeparatorTests(self.catalog.root.parent/'separator-tests',self.separator_runtime,self.scheduler)
|
||||
@@ -144,6 +148,7 @@ class Server(ThreadingHTTPServer):
|
||||
self.video=VideoRuntimes(self.scheduler,stop_gpu_work,self.docker,self.catalog.root.parent/'video',self.catalog,self.profiles,self.image_runtime,original_runtime=self.ltx_original_runtime)
|
||||
self.endpoint.video=self.video
|
||||
self.video.separator_status=lambda:dict(self.separator_runtime.status(),worker=self.separator_tests.status())
|
||||
self.video.voice_profiles=lambda:[dict(id=p['id'],name=p['name']) for p in self.endpoint.rows() if p['kind']=='voice' and p['enabled'] and p['runnable']]
|
||||
self.video.music_profiles=lambda:[dict(id=p['id'],name=p['name']) for p in self.endpoint.rows() if p['kind']=='music' and p['enabled'] and p['runnable']]
|
||||
self.profiles.video_runtime_ready=lambda:self.image_runtime.status().get("installed",False)
|
||||
from dashboard_data import Dashboard
|
||||
@@ -216,7 +221,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
return secrets.compare_digest(actual,record['api_token_hash'])
|
||||
|
||||
def token_route(self):
|
||||
return (self.command == 'GET' and (self.path in ('/api/v1/status','/api/v1/hardware','/api/v1/separator-runtime','/api/v1/separator-tests') or urlsplit(self.path).path=='/api/v1/separator-tests/audio')) or (self.command=='POST' and self.path in ('/api/v1/separator-jobs/start','/api/v1/separator-tests/cancel'))
|
||||
return (self.command == 'GET' and (self.path in ('/api/v1/status','/api/v1/hardware','/api/v1/separator-runtime','/api/v1/separator-tests','/api/v1/voice','/api/v1/voice/profiles') or urlsplit(self.path).path in ('/api/v1/separator-tests/audio','/api/v1/voice/audio'))) or (self.command=='POST' and self.path in ('/api/v1/separator-jobs/start','/api/v1/separator-tests/cancel','/api/v1/voice/start','/api/v1/voice/cancel'))
|
||||
|
||||
def session_token(self):
|
||||
try:
|
||||
@@ -333,7 +338,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
'audio':self.server.tts_runtime.status().get('installed',False),
|
||||
'video':video_runtime.status().get('installed',False),
|
||||
'audio_cpp':self.server.audio_cpp_runtime.status()['installed'],
|
||||
'voxcpm':self.server.voxcpm_runtime.status()['installed'],'music_worker':True,'separator':self.server.separator_runtime.status()['installed']}
|
||||
'omnivoice':self.server.omnivoice_runtime.status()['installed'],'voxcpm':self.server.voxcpm_runtime.status()['installed'],'music_worker':True,'separator':self.server.separator_runtime.status()['installed']}
|
||||
|
||||
def execution_setup(self, model, profile=None, installed=None):
|
||||
return execution_assess(model, self.execution_runtime_snapshot() if installed is None else installed, profile)
|
||||
@@ -363,7 +368,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if self.path == '/api/v1/endpoint':return self.respond(self.server.endpoint.status())
|
||||
if self.path == '/api/v1/docker':return self.respond(self.server.docker.status())
|
||||
if self.path == '/api/v1/stt':return self.respond(self.server.stt.status())
|
||||
if self.path == '/api/v1/voice':return self.respond(self.server.voxcpm_tests.status())
|
||||
if self.path == '/api/v1/voice/profiles':return self.respond({'profiles':[dict(id=p['id'],name=p['name'],repo=p['model']['repo'],enabled=p['enabled'],runnable=p['runnable']) for p in self.server.endpoint.rows() if p['kind']=='voice' and p.get('model')]})
|
||||
if self.path == '/api/v1/voice':return self.respond(dict(self.server.voxcpm_tests.status(),mode=self.server.scheduler.gpu_mode))
|
||||
if urlsplit(self.path).path == '/api/v1/voice/audio':
|
||||
try:return self.respond(self.server.voxcpm_tests.audio(parse_qs(urlsplit(self.path).query).get('id',[''])[0]),mime='audio/wav')
|
||||
except (ValueError,OSError) as exc:return self.respond({'error':str(exc)},400)
|
||||
@@ -376,6 +382,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if urlsplit(self.path).path == '/api/v1/music/audio':
|
||||
try:return self.respond(self.server.music.audio(parse_qs(urlsplit(self.path).query).get('id',[''])[0]),mime='audio/wav')
|
||||
except (OSError,ValueError):return self.respond({'error':'Musik nicht verfügbar.'},404)
|
||||
if self.path == '/api/v1/omnivoice-runtime':return self.respond(self.server.omnivoice_runtime.status())
|
||||
if self.path == '/api/v1/omnivoice-runtime/log':return self.respond(self.server.omnivoice_runtime.log())
|
||||
if self.path == '/api/v1/voxcpm-runtime':return self.respond(self.server.voxcpm_runtime.status())
|
||||
if self.path == '/api/v1/voxcpm-runtime/log':return self.respond(self.server.voxcpm_runtime.log())
|
||||
if self.path == '/api/v1/separator-runtime':return self.respond(self.server.separator_runtime.status())
|
||||
@@ -578,6 +586,11 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if self.path == '/api/v1/separator-profiles/save':
|
||||
try:return self.respond(self.server.separator_tests.configure(self.read_json()))
|
||||
except (ValueError,OSError) as exc:return self.respond({'error':str(exc)},400)
|
||||
if self.path in ('/api/v1/omnivoice-runtime/install','/api/v1/omnivoice-runtime/cancel'):
|
||||
try:
|
||||
if self.read_json():raise ValueError('Keine Installationsparameter erwartet.')
|
||||
return self.respond(self.server.omnivoice_runtime.stop() if self.path.endswith('/cancel') else self.server.omnivoice_runtime.start())
|
||||
except (ValueError,OSError) as exc:return self.respond({'error':str(exc)},400)
|
||||
if self.path in ('/api/v1/voxcpm-runtime/install','/api/v1/voxcpm-runtime/cancel'):
|
||||
try:
|
||||
if self.read_json():raise ValueError('Keine Parameter erwartet.')
|
||||
@@ -658,13 +671,21 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if self.read_json():raise ValueError('Keine Abbruchparameter erwartet.')
|
||||
return self.respond(self.server.voxcpm_tests.stop())
|
||||
if self.headers.get('Content-Type','').startswith('multipart/form-data'):
|
||||
fields,audio=read_upload(self,validate=False,allowed_fields=('profile_id','text','device','cfg','steps','seed'),max_field=4096)
|
||||
fields,audio=read_upload(self,validate=False,allowed_fields=('profile_id','text','device','cfg','steps','seed','reference_text','language','instruct','speed','duration','denoise','preprocess_prompt','postprocess_output'),max_field=4096)
|
||||
fields['reference']=audio
|
||||
for key in ('steps','seed'):
|
||||
if key in fields:fields[key]=int(fields[key])
|
||||
if 'cfg' in fields:fields['cfg']=float(fields['cfg'])
|
||||
for key in ('cfg','speed','duration'):
|
||||
if key in fields:fields[key]=float(fields[key])
|
||||
for key in ('denoise','preprocess_prompt','postprocess_output'):
|
||||
if key in fields:
|
||||
if fields[key] not in ('true','false'):raise ValueError('Ungültige Audio-Option.')
|
||||
fields[key]=fields[key]=='true'
|
||||
else:fields=self.read_json()
|
||||
if set(fields)-{'profile_id','text','device','cfg','steps','seed','reference'} or not {'profile_id','text'}<=set(fields):raise ValueError('Ungültige VoxCPM2-Anfrage.')
|
||||
if set(fields)-{'profile_id','text','device','cfg','steps','seed','reference_text','language','instruct','speed','duration','denoise','preprocess_prompt','postprocess_output','reference'} or not {'profile_id','text'}<=set(fields):raise ValueError('Ungültige VoxCPM2-Anfrage.')
|
||||
if self.api_token_authenticated():
|
||||
selected=next((p for p in self.server.endpoint.rows() if p['id']==fields['profile_id'] and p['kind']=='voice' and p['enabled']),None)
|
||||
if not selected:raise ValueError('Dieses Stimmprofil ist nicht aktiviert. In Deck das gewünschte Profil freigeben.')
|
||||
return self.respond(self.server.voxcpm_tests.start(**fields))
|
||||
except (ValueError,OSError) as exc:return self.respond({'error':str(exc)},400)
|
||||
if self.path in ('/api/v1/tts/install','/api/v1/tts/install-cancel','/api/v1/tts/assign','/api/v1/tts/start','/api/v1/tts/cancel'):
|
||||
@@ -811,7 +832,7 @@ def main():
|
||||
server.endpoint.close()
|
||||
server.stt.stop()
|
||||
server.voxcpm_tests.stop();server.tts_tests.stop()
|
||||
server.tts_runtime.stop();server.voxcpm_runtime.stop()
|
||||
server.tts_runtime.stop();server.voxcpm_runtime.stop();server.omnivoice_runtime.stop()
|
||||
server.image_runtime.stop()
|
||||
server.ltx_original_runtime.stop()
|
||||
server.separator_tests.stop();server.separator_runtime.stop();server.music.close();server.audio_cpp_runtime.stop()
|
||||
|
||||
Reference in new issue
Block a user