@@ -15,6 +15,7 @@ def __init__(self, **kwargs):
1515 self .instances .append (self )
1616
1717 def generate (self , ** kwargs ):
18+ self .generate_kwargs = kwargs
1819 return [{"text" : "hello" }]
1920
2021
@@ -39,3 +40,32 @@ def test_cli_passes_hub_to_auto_model(tmp_path):
3940 assert DummyAutoModel .instances [0 ].kwargs ["hub" ] == "hf"
4041 assert stdout .getvalue ().strip () == "hello"
4142
43+
44+ def test_cli_routes_multiple_hotwords_to_paraformer_hotword (tmp_path ):
45+ audio_path = tmp_path / "sample.wav"
46+ audio_path .write_bytes (b"not a real wav" )
47+ fake_torch = types .SimpleNamespace (
48+ cuda = types .SimpleNamespace (is_available = lambda : False ),
49+ )
50+
51+ DummyAutoModel .instances = []
52+ argv = [
53+ "funasr" ,
54+ "--model" ,
55+ "paraformer" ,
56+ "--hotwords" ,
57+ "FunASR, ModelScope" ,
58+ str (audio_path ),
59+ ]
60+
61+ with (
62+ patch .object (sys , "argv" , argv ),
63+ patch .dict (sys .modules , {"torch" : fake_torch }),
64+ patch ("funasr.AutoModel" , DummyAutoModel ),
65+ redirect_stdout (io .StringIO ()),
66+ ):
67+ cli .main ()
68+
69+ generate_kwargs = DummyAutoModel .instances [0 ].generate_kwargs
70+ assert generate_kwargs ["hotword" ] == "FunASR ModelScope"
71+ assert "hotwords" not in generate_kwargs
0 commit comments