优化语音输入/普通文本输入
This commit is contained in:
@@ -568,6 +568,73 @@ def test_mode_editor_prepares_one_to_many_mqtt_message_sequences() -> None:
|
||||
)
|
||||
|
||||
|
||||
def test_left_sidebar_extracts_speech_and_peripheral_control_commands() -> None:
|
||||
node = shutil.which("node")
|
||||
if node is None:
|
||||
return
|
||||
console = source("console-v2.js")
|
||||
helper_start = console.index(" const normalizedCanTarget")
|
||||
helper_end = console.index("\n\n function renderParsedCanCommands", helper_start)
|
||||
helpers = console[helper_start:helper_end]
|
||||
sample = {
|
||||
"execution_mode": "dry_run",
|
||||
"function_configs": {
|
||||
"native_climate": {
|
||||
"spec": {
|
||||
"operations": [
|
||||
{
|
||||
"id": "speech-temperature",
|
||||
"capability": "climate.set_temperature",
|
||||
"target": {"device": "hvac", "zone": "driver"},
|
||||
"parameters": {"temperature_c": 24},
|
||||
"parse_source": "speech_semantic",
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"self_extension": {
|
||||
"spec": {
|
||||
"operations": [
|
||||
{
|
||||
"id": "speech-peripheral",
|
||||
"capability": "infrared.emit",
|
||||
"target": {
|
||||
"device": "third-party-light",
|
||||
"name": "第三方氛围灯",
|
||||
},
|
||||
"parameters": {"action": "开启", "slot": 9},
|
||||
"parse_source": "local_rule",
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
script = (
|
||||
f"{helpers}\n"
|
||||
f"const result = {json.dumps(sample, ensure_ascii=False)};\n"
|
||||
"process.stdout.write(JSON.stringify({"
|
||||
"commands:parsedCanCommands(result),"
|
||||
'speechLabel:parsedCommandSourceLabel("speech_semantic")'
|
||||
"}));"
|
||||
)
|
||||
completed = subprocess.run(
|
||||
[node, "-e", script],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
output = json.loads(completed.stdout)
|
||||
|
||||
assert output["speechLabel"] == "语音语义"
|
||||
assert len(output["commands"]) == 2
|
||||
assert {item["channel"] for item in output["commands"]} == {"CAN1", "IR"}
|
||||
assert {item["command"] for item in output["commands"]} == {
|
||||
"ac temp driver 24",
|
||||
"infrared emit 9",
|
||||
}
|
||||
|
||||
|
||||
def test_interactive_console_keeps_actions_inside_composer_and_collapsed_rails_aligned() -> None:
|
||||
console = source("console-v2.js")
|
||||
styles = source("console-v2.css")
|
||||
|
||||
Reference in New Issue
Block a user