From da5c280121966cdcedcf6609b663c3be75502c36 Mon Sep 17 00:00:00 2001 From: Mikei386 <44135113+Mikei386@users.noreply.github.com> Date: Sun, 4 Oct 2026 22:26:29 +0200 Subject: [PATCH] Fix OmniVoice preparation CLI configuration argument --- omnivoice_worker.py | 2 +- test_voxcpm_worker.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/omnivoice_worker.py b/omnivoice_worker.py index c8f7dd0..caf5960 100644 --- a/omnivoice_worker.py +++ b/omnivoice_worker.py @@ -45,7 +45,7 @@ def main(): with open('/dev/null','w') as sink,contextlib.redirect_stdout(sink),contextlib.redirect_stderr(sink): if '--prepare-reference' in sys.argv[2:]: try: - config=json.loads(Path(sys.argv[3]).read_text());rate=config['sampling_rate'] + config=json.loads(Path(sys.argv[2]).read_text());rate=config['sampling_rate'] if type(rate)!=int or not 11025<=rate<=96000:raise ValueError('Ungültige OmniVoice-Abtastrate in der Modellkomponente.') result=prepare_reference(root,rate) except Exception as exc:result=dict(ok=False,error=str(exc) if isinstance(exc,ValueError) else 'OmniVoice: Referenzaufbereitung fehlgeschlagen ('+type(exc).__name__+').') diff --git a/test_voxcpm_worker.py b/test_voxcpm_worker.py index c981bc0..d8f9286 100644 --- a/test_voxcpm_worker.py +++ b/test_voxcpm_worker.py @@ -157,3 +157,13 @@ class OmniReferenceTests(unittest.TestCase): with patch('voxcpm_test.subprocess.run') as prepare,patch.object(t,'_ensure_voice',return_value=process): t._run_voice(dict(model=dict(kind='voice',repo='k2-fsa/OmniVoice',file='model.safetensors')), 'job',dict(text='Test',reference_text='Full transcript',preprocess_prompt=True),b'full reference',dict(uuid='test'),Mock()) prepare.assert_not_called();t.reference_transcriber.assert_not_called();self.assertEqual(t.job['state'],'complete') + +class OmniPreparationCLITests(unittest.TestCase): + def test_preparation_reads_supplied_model_configuration_without_loading_weights(self): + import json,sys,omnivoice_worker + with tempfile.TemporaryDirectory() as d: + root=Path(d);config=root/'config.json';config.write_text(json.dumps(dict(sampling_rate=24000))) + with patch.object(sys,'argv',['worker',d,str(config),'--prepare-reference']),patch.object(omnivoice_worker,'prepare_reference',return_value=dict(ok=True,original_duration=1200,duration=15)) as prepare,patch.object(omnivoice_worker,'load') as load: + self.assertEqual(omnivoice_worker.main(),0) + prepare.assert_called_once_with(root,24000);load.assert_not_called() + self.assertTrue(json.loads((root/'reference-info.json').read_text())['ok'])