Fix OmniVoice preparation CLI configuration argument
This commit is contained in:
1 parent
1e575ffc92
commit
da5c280121
2 files changed
+11
-1
No files matched your search
+1
-1
@@ -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__+').')
|
||||
|
||||
@@ -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'])
|
||||
Reference in new issue
Block a user