2022-10-09 14:56:39 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
2022-10-17 12:18:13 +00:00
|
|
|
from pydantic import BaseModel
|
|
|
|
|
2022-10-17 12:29:12 +00:00
|
|
|
from whispering.cli import Mode, is_valid_arg
|
2022-10-09 14:56:39 +00:00
|
|
|
|
|
|
|
|
2022-10-17 12:18:13 +00:00
|
|
|
class ArgExample(BaseModel):
|
2022-10-17 12:29:12 +00:00
|
|
|
mode: Mode
|
2022-10-17 12:18:13 +00:00
|
|
|
cmd: str
|
|
|
|
ok: bool
|
|
|
|
|
|
|
|
|
2022-10-09 14:56:39 +00:00
|
|
|
def test_options():
|
|
|
|
|
2022-10-17 12:18:13 +00:00
|
|
|
exs = [
|
2022-10-17 12:29:12 +00:00
|
|
|
ArgExample(mode=Mode.server, cmd="--mic 0", ok=False),
|
|
|
|
ArgExample(mode=Mode.server, cmd="--mic 1", ok=False),
|
|
|
|
ArgExample(
|
|
|
|
mode=Mode.server,
|
|
|
|
cmd="--host 0.0.0.0 --port 8000",
|
|
|
|
ok=True,
|
|
|
|
),
|
|
|
|
ArgExample(
|
|
|
|
mode=Mode.server,
|
|
|
|
cmd="--language en --model tiny --host 0.0.0.0 --port 8000",
|
|
|
|
ok=True,
|
|
|
|
),
|
|
|
|
ArgExample(mode=Mode.server, cmd="--beam_size 3", ok=False),
|
|
|
|
ArgExample(mode=Mode.server, cmd="--temperature 0", ok=False),
|
|
|
|
ArgExample(mode=Mode.server, cmd="--num_block 3", ok=False),
|
|
|
|
ArgExample(mode=Mode.mic, cmd="--host 0.0.0.0", ok=False),
|
|
|
|
ArgExample(mode=Mode.mic, cmd="--port 8000", ok=False),
|
2022-10-09 14:56:39 +00:00
|
|
|
]
|
|
|
|
|
2022-10-17 12:18:13 +00:00
|
|
|
for ex in exs:
|
2022-10-17 12:29:12 +00:00
|
|
|
ok = is_valid_arg(
|
|
|
|
mode=ex.mode.value,
|
|
|
|
args=ex.cmd.split(),
|
|
|
|
)
|
|
|
|
assert ok is ex.ok, f"{ex.cmd} should be {ex.ok}"
|