Publish the reviewed accumulated runtime, scheduler, profile, UI, native recipes and historical maintenance evidence. Includes Qwen GPU ASR correction and shared Anna/atelier ownership. Validated with 784 local tests, Python/JSON parsing and eight JavaScript syntax checks. Live GPU acceptance and full fresh-host restore limits remain documented.
47 lines
3.2 KiB
Python
47 lines
3.2 KiB
Python
"""Synthetic tests for reusing the installed Qwen GPU backend with private Anna."""
|
|
import copy,json,tempfile,unittest,hashlib
|
|
from pathlib import Path
|
|
from unittest.mock import Mock,patch
|
|
from profiles import Profiles,audio_voice_parameters
|
|
from tts_runtime import TTSRuntime,REPO,REVISION
|
|
from tts_test import TTSTests
|
|
from tts_worker import PresetBaseModel
|
|
|
|
MODEL=dict(id='a'*64,repo=REPO,revision=REVISION,file='model.safetensors',kind='audio',profile_eligible=True)
|
|
class AnnaTests(unittest.TestCase):
|
|
def test_only_existing_base_gpu_recipe_accepts_profile_voice(self):
|
|
for value in ('Anna','Ryan'):
|
|
self.assertEqual(audio_voice_parameters({'speed':1,'tts_voice':value},MODEL)['tts_voice'],value)
|
|
for value in (None,False,3,'unknown'):
|
|
with self.assertRaises(ValueError):audio_voice_parameters({'tts_voice':value},MODEL)
|
|
with self.assertRaises(ValueError):audio_voice_parameters({'tts_voice':'Anna'},dict(MODEL,repo='other/model'))
|
|
self.assertEqual(audio_voice_parameters({'speed':1},dict(MODEL,repo='other/model')),{'speed':1})
|
|
def test_reference_is_private_local_and_symlinks_fail_closed(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root=Path(tmp);rt=TTSRuntime(root/'tts-runtime');voice=root/'speech-voices/Anna';voice.mkdir(parents=True)
|
|
with self.assertRaises(ValueError):rt.anna_reference()
|
|
ref=voice/'reference.wav';ref.touch();self.assertEqual(rt.anna_reference(),ref)
|
|
ref.unlink();ref.symlink_to(root/'outside.wav')
|
|
with self.assertRaises(ValueError):rt.anna_reference()
|
|
def test_profile_save_reload_and_preset_preserve_voice(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
cat=Mock();cat.entry.return_value=MODEL;p=Profiles(Path(tmp)/'profiles.json',cat)
|
|
saved=p.save(dict(id=None,revision=0,name='Qwen Anna GPU 3060',kind='audio',model_id=MODEL['id'],parameters={'speed':1,'tts_voice':'Anna'}))
|
|
self.assertEqual(Profiles(p.path,cat).rows[0]['parameters']['tts_voice'],'Anna')
|
|
p.preset(dict(id=saved['id'],revision=saved['revision'],action='save',name='Anna'))
|
|
self.assertEqual(p.rows[0]['presets'][0]['parameters']['tts_voice'],'Anna')
|
|
def test_default_voice_resolves_from_profile_before_worker_dispatch(self):
|
|
for speaker in (None,'default','Ryan'):
|
|
with tempfile.TemporaryDirectory() as tmp,patch('tts_test.threading.Thread') as thread:
|
|
runtime=Mock();runtime.paths.return_value=(Path(tmp)/'python',Path(tmp)/'model')
|
|
profile=dict(id='p',kind='audio',runnable=True,parameters={'speed':1,'tts_voice':'Anna'})
|
|
profiles=Mock();profiles.status.return_value={'profiles':[profile]}
|
|
worker=TTSTests(Path(tmp)/'jobs',profiles,runtime);worker._available_gpu=Mock(return_value={'uuid':'GPU-selected'})
|
|
with patch('tts_test.cgroup_headroom',return_value=None):worker.start('p','Eine synthetische Prüfung.',speaker=speaker)
|
|
self.assertEqual(thread.call_args.kwargs['args'][2],'Ryan' if speaker=='Ryan' else 'Anna')
|
|
def test_base_wrapper_uses_anna_conditioning_not_japanese_preset(self):
|
|
backend=Mock();anna=object();japanese=object();wrapper=PresetBaseModel(backend,{'anna':anna,'ono_anna':japanese})
|
|
wrapper.generate_custom_voice(text='Hallo.',language='German',speaker='Anna')
|
|
self.assertEqual(backend.generate_voice_clone.call_args.kwargs['voice_clone_prompt'],[anna])
|
|
if __name__=='__main__':unittest.main()
|