Commands: corrections inside a sentence, conditions are no order, Korean speech levels, missions on any map in any word order, never half done
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+38
-22
@@ -278,6 +278,9 @@ Short Korean commands are commands: "컵 가져다 줘" -> fetch cup, "컵 옮
|
||||
(jump, dance, fly, climb stairs, open doors, lift heavy things) is none: say plainly that you can't. A person, a
|
||||
chair, a table, a box or anything heavy you can't pick or carry: none, say so. With the action none never promise to do it ("I can!", "Okay, I'll hand it to you"): choose the
|
||||
action, or say you can't, or ask what they mean.
|
||||
- A condition or a later time is no order now ("when I say go, go to p1", "after the talk, come here", "if I
|
||||
wave, follow me", "내가 가라고 하면 가", "나중에 와"): none, say you'll do it when they ask. In "go to p1, no, p2" /
|
||||
"p1로 가, 아니 p2로" the last one counts. "Shake hands with me" is a handshake you can't do: none, offer a wave.
|
||||
- unclear: you did not understand what the visitor said or wants: ask them to repeat.
|
||||
- none: only talk.
|
||||
For weather and search only write the action line; the answer is made after the lookup.
|
||||
@@ -364,7 +367,8 @@ COLOURS = {"white": "white", "red": "red", "blue": "blue", "green": "green", "ye
|
||||
_OBJ = "|".join(rf"(?<![가-힣]){w}(?![가-힣])|(?<![가-힣]){w}(?=[을를이가은는도만좀][^가-힣]|[을를이가은는도만좀]$)" if w in _KO_WORD
|
||||
else re.escape(w) for w in sorted(OBJECTS, key=len, reverse=True))
|
||||
_COL = "|".join(COLOURS)
|
||||
STOP_TALK = re.compile(r"비상 ?정지|emergency stop|stop button|정지 ?버튼", re.I) # about the stop button, not "stop!"
|
||||
STOP_TALK = re.compile(r"비상 ?정지|emergency stop|stop button|정지 ?버튼|\b(?:can'?t|cannot|couldn'?t|won'?t) stop\b|"
|
||||
r"\bbus stop\b|\bstop (?:by|sign)\b|non-?stop", re.I) # about stopping, not "stop!" # about the stop button, not "stop!"
|
||||
BEHIND_WORDS = (r"\blook(?:ing)? (?:over |to(?:wards?)? |at |in )?(?:the |your )?" # "look at the back side", "look
|
||||
r"(?:behind|back ?side|back(?:wards?)?|rear|big side)\b" # at behind side", whisper's "big side"
|
||||
r"(?! (?:at|on|up|in|of|to|and forth)\b)" # not "look back at me", "look at the back of"
|
||||
@@ -464,14 +468,14 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
||||
r"그만 ?(?:좀 ?)?(?:쳐다|바라)(?:봐|보세요)|"
|
||||
r"(?:날|나를?|저를?|절)\s*(?:좀\s*)?(?:보지|쳐다보지) ?마|다른 ?(?:데|곳|쪽)(?:을|를)? ?(?:좀 )?봐"),
|
||||
("stop", r"\b(stop|halt|freeze|don'?t move)\b|멈춰|정지|그만 ?가|거기 ?서(?=[\s!.~,]*$)|스톱|움직이지 ?마|^\s*(서[\s,!.]*){2,}$"),
|
||||
("follow", r"\b(?:follow|come with|come along with|walk with|tag along with)\s+(?:me|us)\b(?!\s+(?:on|at)\b)|" # not "follow
|
||||
("follow", r"\b(?:follow|following|come with|come along with|walk with|tag along with)\s+(?:me|us)\b(?!\s+(?:on|at)\b)|" # not "follow
|
||||
r"\bcome along\b|(?<!말 )(?<!말을 )따라\s?(?:와|오세요|오십시오|올래)|(?<!로 )(?:같이|함께)\s?(?:가자|가요|갑시다|걸어)"), # me on instagram"
|
||||
("fetch",rf"\b(fetch|bring|deliver|carry)\b.*\b({_OBJ}|it|that|this)s?\b|\b(take|get|grab)\b.*\b({_OBJ})s?\b.*\b(from|to)\b"
|
||||
rf"|\b(go|drive) to\b.*\b(get|take|grab|pick up|fetch|bring)\b.*\b({_OBJ})s?\b"
|
||||
rf"|\b(pick up|pick|take|grab|get)\b.*\b({_OBJ})s?\b.*\b(go|drive) to\b|({_OBJ}).*(집어서|들고).*가서"
|
||||
r"|가져와|가져다|갖다|가지고 ?와|에서.*(옮겨|가져)" rf"|({_OBJ}).*(집고|들고|가지고).*(와|줘)"),
|
||||
("come", r"\bcome (?:back )?(here|hear|to me|closer|over here|over)\b|\bcome\b.*\bme\b|이리 ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오|올래)|"
|
||||
r"여기로 ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오)|가까이 ?(?:좀 ?)?(?:와|오세요)|"
|
||||
("come", r"\bcome (?:back )?(here|hear|to me|closer|over here|over|this way)\b|\bcome\b.*\bme\b|이리 ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오|올래)|"
|
||||
r"(?:여기로|이쪽으로) ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오)|가까이 ?(?:좀 ?)?(?:와|오세요)|"
|
||||
r"나한테 ?(?:돌아 ?)?와"),
|
||||
("go_home", r"\bgo (back )?(home|to (the |your )?(dock(?!2)|charger|charging))|\bgo charge|충전하러|집(?:에|으로) ?가|충전기로"),
|
||||
("go_point", r"\b(?:go|drive|move|head|come|return|walk|roll|run|proceed|navigate|travel|hurry|make your way|get|take yourself)"
|
||||
@@ -491,7 +495,8 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
||||
r"\bwave (?:at|to|your|hello|hi|bye|goodbye|back|again|for)\b|\bgimme a wave\b|\b(?:why don'?t you|if you (?:could|can|would)|"
|
||||
r"you (?:could|should|can|might)|could you|would you|can you|will you) (?:please |just )?wave\b(?!s)|\bgive (?:(?:them|him|her|us|me|everyone|the \w+) )?"
|
||||
r"a (?:little |quick |big |friendly )?wave\b|\bwave\s?(?:해|좀)|\bshake (?:your |a |my )?hands?\b(?! with\b)|\bsay (?:hi|hello|bye) with your hand\b|손 ?(?:을 |좀 |도 )?흔들|손 ?인사"),
|
||||
("turn", r"\bturn (a)?round\b|\bturn (left|right)\b|뒤로 ?돌|돌아 ?봐|왼쪽으로 ?돌|오른쪽으로 ?돌"),
|
||||
("turn", r"\bturn (a)?round\b|(?:왼쪽|오른쪽)으로 ?(?:\d+(?:\.\d+)? ?도 ?)?도(?:세요|십시오)|\bturn (?:to (?:the |your )?)?(left|right)\b|뒤로 ?돌|돌아 ?봐|"
|
||||
r"(?:왼쪽|오른쪽)으로 ?(?:\d+(?:\.\d+)? ?도 ?)?돌"),
|
||||
("make_way", r"\b(can|could|would) you (please )?move( a bit| a little| please)?\s*[?.!]*$|\bmove (aside|out of the way|over)\b|"
|
||||
r"\b(make way|get out of the way|give me some room)\b|비켜|자리 ?(좀 )?(비워|옮겨)|길 ?(좀 )?(비켜|터)"),
|
||||
("go_point", r"\b(?:go|come|drive|head) back (p\d+)\b"), # "come back p9": a place, not 1 m back
|
||||
@@ -529,6 +534,10 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
||||
]
|
||||
|
||||
|
||||
LATER = re.compile(r"^\s*(?:after|once|if|as soon as|before|unless|until)\b(?! (?:that|this|you (?:can|could|don'?t mind|would|"
|
||||
r"please))\b)|\b(?:later|tomorrow|tonight|next time|in an hour)\b|[가-힣](?<![정화측반전표라장내외평단])면\s(?!안 ?돼)|\byou'?ll (?:find|see)\b|\bat the corner\b|"
|
||||
r"\b(?:he|she|they|my \w+|his \w+|her \w+|our \w+|someone) (?:will|'ll|is going to|are going to)\b|"
|
||||
r"(?:^|\s)(?:나중에|이따가?|내일)\s", re.I) # "after the talk ends, go to p1", "내가 가라고 하면": not now
|
||||
STOP_ASK = re.compile(r"(?:(?:can|could|would|will) you (?:please |just )?stop(?: (?:now|please|moving|driving|here|there))?|"
|
||||
r"멈출 수 있(?:어|어요|니|나요)|멈춰 줄래요?|멈춰 줄 수 있(?:어|어요))\W*$", re.I) # "can you stop?": stop
|
||||
|
||||
@@ -552,10 +561,8 @@ def intent(text, markers=()):
|
||||
r"\b(can|could) you (pick( up)?|lift|hold|grab|take) (a|an|any)\b|" # "can you pick up a bottle?"
|
||||
r"^\s*(what|when|which|at what|do you|does|is it|are you)\b|몇|언제|얼마|" # "at what level do you go back?"
|
||||
rf"({_OBJ})(은|는)\s.*수 ?있|(루미가|로봇이)\s.*수 ?있|는 ?거 ?(돼|되나|가능)|" # "물컵은 가져다줄 수 있어요?"
|
||||
r"어떻게|왜|혼자|스스로|\bby yourself\b|\bsomeone\b|줄 ?알아|할 ?줄|\bcome here often\b|"
|
||||
r"^\s*(?:after|once|if|as soon as|before|unless|until)\b(?! (?:that|this|you (?:can|could|don'?t mind|would|please))\b)|"
|
||||
r"\b(?:later|tomorrow|tonight|next time|in an hour)\b|(?:하|가|끝나|되|부르|말하)면\s(?!안 ?돼)|(?:^|\s)(?:나중에|이따가?|내일)\s",
|
||||
CALLING.sub("", t)) # "Lumi, is it hard to ...?", "after the talk ends, go to p1", "내가 가라고 하면"
|
||||
r"어떻게|왜|혼자|스스로|\bby yourself\b|\bsomeone\b|줄 ?알아|할 ?줄|\bcome here often\b",
|
||||
CALLING.sub("", t)) or LATER.search(CALLING.sub("", t)) # "Lumi, is it hard to ...?"
|
||||
visitor = re.search(r"^\W*(?:can|may|could|should|shall) (?:i|we)\b", CALLING.sub("", t)) # "can I come closer?"
|
||||
for action, pat in INTENTS:
|
||||
m = re.search(pat, t, re.I)
|
||||
@@ -565,7 +572,7 @@ def intent(text, markers=()):
|
||||
return None # "where's your emergency stop?", "how do I stop you?"
|
||||
if action == "look_away":
|
||||
return None if asks or "?" in t else ("look", "away") # "don't look at me", "쳐다보지 마"
|
||||
if action != "quiet" and re.search(r"(?<!why )\b(don'?t|do not|never)\b|(하|펴|가|잡|놓|열)지 ?마", t) and action != "stop":
|
||||
if action != "quiet" and re.search(r"(?<!why )\b(don'?t|do not|never)\b|[가-힣]지 ?마(?:세요|요|라)?(?![가-힣])", t) and action != "stop":
|
||||
return None # "don't go to p1", "손 펴지 마": not an order
|
||||
if asks and action in ("go_home", "go_point", "move", "make_way", "turn", "pick", "put", "move_object", "fetch", "come",
|
||||
"arm", "grip_open", "grip_close", "wave", "look", "lift", "follow", "come_back"):
|
||||
@@ -668,7 +675,7 @@ def _fix_kinds(t, markers):
|
||||
"""The values in t a correction may replace: {kind: [match, ...]}: place, distance, angle, direction, object, colour."""
|
||||
names = sorted((re.escape(m.lower()) for m in markers if len(m) > 1), key=len, reverse=True)
|
||||
pats = {"place": rf"(?<![a-z0-9_])(?:p\d+|{'|'.join(names) or 'p0'})(?![a-z0-9_])",
|
||||
"angle": r"\d+(?:\.\d+)?\s*(?:degrees?|도)", "distance": r"\d+(?:\.\d+)? m\b", "direction": _FIX_DIR,
|
||||
"angle": r"\d+(?:\.\d+)?\s*(?:degrees?|도)", "distance": r"\d+(?:\.\d+)? m(?![a-z])", "direction": _FIX_DIR,
|
||||
"time": r"\d+(?:\.\d+)?\s*(?:seconds?|secs?|minutes?|mins?|초|분)(?![a-z가-힣])",
|
||||
"object": rf"(?<![a-z])(?:{_OBJ})s?(?![a-z])", "colour": rf"(?<![a-z])(?:{_COL})(?![a-z])"}
|
||||
out = {}
|
||||
@@ -694,8 +701,9 @@ def self_correct(text, markers=()):
|
||||
"" when the command was taken back ("go to the stage, never mind", "스테이지로 가, 아니 됐어"); None when a
|
||||
correction is there but can't be read for sure (Lumi asks again, nothing moves); the text itself otherwise."""
|
||||
from assistant import steps
|
||||
if re.search(r"\b(?:say|tell|announce)\b|말해|전해|[\"“”]", text, re.I):
|
||||
return text # a message to say may hold any words
|
||||
if re.search(r"\b(?:say|tell|announce)\b|말해|전해|[\"“”]", text, re.I) or \
|
||||
re.search(r"\b(?:stop|halt|freeze|don'?t move)\b|멈춰|정지|그만|스톱|움직이지 ?마|거기 ?서", text, re.I):
|
||||
return text # a message to say may hold any words; a stop always wins
|
||||
t = wording.norm(text, markers)
|
||||
end = re.search(r"[\s,.;!?]+(?:(?:oh|uh|um|아|음)\W+)?(?:never ?mind|forget (?:it|that|about it)|cancel (?:that|it)|"
|
||||
r"(?:아니\s*)?(?:됐어요?|됐다|취소))\W*$", t)
|
||||
@@ -704,10 +712,10 @@ def self_correct(text, markers=()):
|
||||
for _ in range(3):
|
||||
m = next((m for m in FIX.finditer(t) if m.start() > 0 and t[:m.start()].strip(" ,.;!?")), None)
|
||||
if not m:
|
||||
return t if _ else text
|
||||
return _recase(t, text) if _ else text
|
||||
left, right, said = t[:m.start()].strip(" ,.;!?"), t[m.end():].strip(" ,.;!?"), m.group(0)
|
||||
if not _reads(left, markers) and not {"distance", "angle", "direction"} & set(_fix_kinds(left, markers)):
|
||||
return t if _ else text # "I like apples, no, I love them": talk, not a command
|
||||
return _recase(t, text) if _ else text # "I like apples, no, I love them": talk, not a command
|
||||
if not right or FIX_CANCEL.match(right):
|
||||
if right or _STRONG_NO.search(said):
|
||||
return "" # taken back
|
||||
@@ -743,12 +751,18 @@ def self_correct(text, markers=()):
|
||||
fixed = fixed[:x.start()] + rk[kind][-1].group(0) + " " + fixed[x.start():]
|
||||
said_again = all(w in fixed.split() for w in tail.split()) # "turn left, no, turn right": "turn"
|
||||
new = next((c for c in ([] if said_again else [f"{fixed} {tail}"]) + [fixed] if _reads(c, markers)), None)
|
||||
if new is None and _reads(first, markers):
|
||||
new = instead()
|
||||
if new is None and _reads(first, markers) and not set(rk) & set(_fix_kinds(clauses[-1], markers)):
|
||||
new = instead() # another command ("go to the stage, no, come here")
|
||||
if new is None:
|
||||
return None
|
||||
t = f"{new}, {rest[0]}" if rest else new
|
||||
return t
|
||||
return _recase(t, text)
|
||||
|
||||
|
||||
def _recase(t, text):
|
||||
"""Words written as the original had them ("james" -> "James"): names keep their capital in the read-back."""
|
||||
said = {w.lower(): w for w in re.findall(r"[A-Za-z][a-z]*[A-Z]?[a-z]*", text) if not w.islower()}
|
||||
return re.sub(r"[a-z]+", lambda m: said.get(m.group(0), m.group(0)), t)
|
||||
|
||||
|
||||
# ---------- fetch tasks (docs/16 §4): strict parsing, nothing is guessed ----------
|
||||
@@ -759,12 +773,12 @@ _PLACE_WORD = rf"(?:point|marker|포인트)\s*(\d+)|(?<![a-z])p\s?(\d+)(?!\d)|(\
|
||||
_NOT_OBJ = r"(?:not|instead of) (?:the |a |an )?$" # "not the apple, the cup": the apple is not meant
|
||||
|
||||
|
||||
FILLER_IN = re.compile(r"(?<![\w'])(?:u+h+m*|u+m+|e+r+m*|hmm+)(?![\w'])[,.]*\s*|(?<![가-힣])(?:음+|어+)(?![가-힣])[,.]*\s*")
|
||||
FILLER_IN = re.compile(r"(?:,\s*)?(?<![\w'])(?:u+h+m*|u+m+|e+r+m*|hmm+)(?![\w'])[,.]*\s*|(?:,\s*)?(?<![가-힣])(?:음+|어+)(?![가-힣])[,.]*\s*")
|
||||
|
||||
|
||||
def unfill(t):
|
||||
"""'go to the um the stage' -> 'go to the stage': fillers inside the words and the word said twice around them."""
|
||||
t = FILLER_IN.sub("", t)
|
||||
t = re.sub(r" {2,}", " ", FILLER_IN.sub(" ", t)).strip()
|
||||
return re.sub(r"\b(the|a|to) \1\b", r"\1", t)
|
||||
|
||||
|
||||
@@ -1116,7 +1130,7 @@ PLACE_EN = re.compile(
|
||||
r"(?:\s+(?:here|there|over there|somewhere|anywhere))?(?:\s+(?:on|onto|next to|beside|by|near|in front of)\s+.+)?"
|
||||
rf"{_TAIL}|\b(?:put|set) (?:it |that |this )?down\b", re.I)
|
||||
PLACE_KO = re.compile(r"(?<!내)(?<!그냥 )(?<!가만히 )(?<!내버려 )(?:놔|놓아|놓으|둬|두세요|올려 ?놔|올려 ?놓|내려 ?놔|내려 ?놓|내려 ?줘|내려 ?주세요|내려 ?둬)"
|
||||
r"\s*(?:줘|주세요|요|줄래요?|주시겠어요|주실래요|주십시오|줄 수 있어요?|주실 수 있어요)?\s*[.!?~]*$")
|
||||
r"(?:으십시오|으세요|으시겠어요)?\s*(?:줘|주세요|요|줄래요?|주시겠어요|주실래요|주십시오|줄 수 있어요?|주실 수 있어요)?\s*[.!?~]*$")
|
||||
OPEN_HAND = re.compile(r"\bopen (?:your |the )?(?:hand|gripper|fingers)\b|\bopen it\b|\blet (?:it )?go\b|"
|
||||
r"손을? ?(?:좀 )?(?:펴|벌려|열어)|손 ?open|hand open", re.I)
|
||||
HAND_Q = re.compile(r"^\W*(?:what|how|why|when|where|which|who|do|does|did|is|are|was|were|have you|has)\b|"
|
||||
@@ -1271,7 +1285,7 @@ IN_LANGUAGE = re.compile(r"^\s*(and |then |now |okay,? |and say it |say (it|that
|
||||
r"^\s*(그거|그걸|그럼|다시|이번엔|이제)?\s*(한국어|영어|korean|english)\s?로(?!.*(대화|할 ?수|할 ?줄|돼요\?|되나))"
|
||||
r"(요|는요|는|도)?\s*(다시\s*)?((말|말씀|얘기)?\s*해\s*(줘|주세요|줄래요?|줄 ?수 ?있어요?|봐요?)?)?"
|
||||
r"\s*[!?.~]*\s*$", re.I)
|
||||
WAVE_ASK = re.compile(r"\bwav(e|ing)\b|\bwith your hand\b|\bshake (?:your |my )?hands?\b|흔들|손 ?인사|인사.*손으로|손으로.*인사", re.I)
|
||||
WAVE_ASK = re.compile(r"\bwav(e|ing)\b|\bwith your hand\b|\bshake (?:your |my )?hands?\b(?! with\b)|흔들|손 ?인사|인사.*손으로|손으로.*인사", re.I)
|
||||
SING_ASK = re.compile(r"\bsing|\bsong|\bmusic\b|노래|한 ?곡|불러", re.I)
|
||||
LOOK_MORE = re.compile(r"^\W*(?:and|now|then|and now)?\s*(up|down|left|right)\W*$|"
|
||||
r"^\W*(?:이제|그럼|그리고)?\s*(위|아래|왼쪽|오른쪽)(?:도|로|으로|요|도요)?\W*$", re.I) # right after a look
|
||||
@@ -1748,6 +1762,8 @@ class Brain:
|
||||
if re.search(r"\b(bye|goodbye|(?<!can't )(?<!cant )(?<!cannot )(?<!not )(?<!to )see you|good night|i have to go|i'?m leaving)\b|안녕히|잘 ?가|잘 ?있어|"
|
||||
r"다음에 봐|갈게요|가 ?볼게요|안녕\s*[.!]?$", text, re.I):
|
||||
action = "end"
|
||||
if action in MOTIONS and LATER.search(bare):
|
||||
action, target = "none", "" # "when I say go, go to the stage": not now
|
||||
rule = intent(text, markers) # clear wordings win over the small model's guess
|
||||
if rule and not (rule[0] == "search" and action in ("go_to", "come", "look", "weather", "sing")):
|
||||
action, target = rule
|
||||
|
||||
@@ -33,7 +33,7 @@ VERB = re.compile(r"\b(?:move|go|come|drive|step|scoot|scooch|shift|inch|roll|ba
|
||||
r"가|와|이동|움직|물러|빠져|후진|전진|비켜")
|
||||
OTHER = re.compile(r"\b(?:look|head|turn|rotate|face|arm|hand|lift|raise|lower|it|this|that|them|those|these|here|there|"
|
||||
r"home|me|us)\b|\bthe (?!left\b|right\b)|\bgo (?:right )?ahead\b|\bback to (?![\d.])|\bp\d+\b|고개|머리|팔|손|돌아|돌려|봐|쳐다|들어|올려|내려|"
|
||||
r"여기|저기|이리|집|\S(?:을|를)(?=\s)") # the head, an object, a place: not a short drive
|
||||
r"여기|저기|이리|집|\S(?:을|를)(?=\s)|도십시오|도세요|\d+(?:\.\d+)? ?도(?=\s|$)") # the head, an object, a place: not a short drive
|
||||
SAYER = re.compile(r"\b(?:i|i'm|im|i'll|i've|we|we're|he|she|they|there|it's|it is|my|our|his|her|their|was|were|"
|
||||
r"if|when)\b|(?:^|\s)(?:나|저|우리|저희)(?:는|도|가)\s") # "I live a few metres to the left"
|
||||
_NATIVE = {"한": 1, "두": 2, "세": 3, "네": 4, "다섯": 5, "여섯": 6, "일곱": 7, "여덟": 8, "아홉": 9, "열": 10,
|
||||
@@ -50,10 +50,10 @@ NUM_WORD = re.compile(r"\b(?:eleven|twelve|thirteen|fourteen|fifteen|sixteen|sev
|
||||
|
||||
FASTER = re.compile(r"\b(?:faster|quicker|speed (?:it )?up|pick up (?:the )?(?:pace|speed)|step on it|hurry(?: up)?|"
|
||||
r"get a move on|more speed|full speed|go quick(?:ly)?|too slow(?:ly)?|so slow(?:ly)?|"
|
||||
r"not fast enough|move it)\b|빨리|빠르게|속도\s*(?:를|좀)?\s*(?:좀\s*)?(?:높|올)\S*|느려|느리다|서둘러")
|
||||
r"not fast enough|move it)\b|빨리|빠르게|(?:속도|speed)\s*(?:를|좀)?\s*(?:좀\s*)?(?:높|올)\S*|느려|느리다|서둘러")
|
||||
SLOWER = re.compile(r"\b(?:slower|slow (?:it )?down|slow|ease (?:off|up)|not so fast|too fast|"
|
||||
r"so fast|less speed|gently|more slowly|slowly)\b|"
|
||||
r"천천히|느리게|속도\s*(?:를|좀)?\s*(?:좀\s*)?(?:줄|낮|늦)\S*|빨라|빠르다|살살")
|
||||
r"천천히|느리게|(?:속도|speed)\s*(?:를|좀)?\s*(?:좀\s*)?(?:줄|낮|늦)\S*|빨라|빠르다|살살")
|
||||
_FILLER = (r"please|pls|lumi|hey|hi|okay|ok|so|um+|uh+|well|now|then|just|can|could|would|will|you|you're|youre|"
|
||||
r"are|is|going|moving|driving|go|drive|move|"
|
||||
r"keep|going|get|it|the|a|an|bit|little|tiny|notch|touch|tad|lot|much|way|even|bit|slightly|somewhat|"
|
||||
|
||||
+12
-7
@@ -113,7 +113,7 @@ CLOSE_BOX = 0.85 # a person is really closer than TOO_CLOSE on
|
||||
HEAD_SIGN = 1.0 # +image angle -> +head yaw (checked: + = robot's left)
|
||||
LOOK = {"left": (40, None), "right": (-40, None), "center": (0, 0), "up": (None, 20), "down": (None, -5)}
|
||||
# ^ yaw/pitch in degrees for "look" commands: +yaw = left, +pitch = up (checked on the dashboard 2026-10-12)
|
||||
WAKE = re.compile(r"\b(hi|hey|hello|okay|ok|hai|high)?[\s,.!]*(lumi|loomi|lumie|lumy|lummy|looney|lu-mi|rumi|roomie)\b"
|
||||
WAKE = re.compile(r"\b(hi|hey|hello|okay|ok|hai|high)?[\s,.!]*(lumi|lumia|loomi|lumie|lumy|lummy|looney|lu-mi|rumi|roomie)\b"
|
||||
r"|루미|누미", re.I)
|
||||
WAKE_REPLY = {"en": "Yes? How can I help?", "ko": "네? 무엇을 도와드릴까요?"}
|
||||
NAME_ONLY = re.compile(r"^\s*(hi |hey |hello )?(lumi|loomi|rumi|루미)[\s,.!?]*$", re.I)
|
||||
@@ -1788,9 +1788,12 @@ class Lumi:
|
||||
return True
|
||||
self.warm_llm() # the LLM's prompt start cached while they speak
|
||||
text, u = ears.listen(wait_s=4.0, on_start=lambda: log(" hearing speech"), abort=self.interrupted, full=True)
|
||||
if text and self.own_echo(text) and (u is None or u.source == "clip" or len(text.split()) <= 2):
|
||||
# Lumi heard itself: the clip mic, or the room's echo of the last word on the head array (muted while Lumi
|
||||
# talks); a longer head-array sentence is the visitor ("okay go to P9" after a list with p9, 2026-10-21)
|
||||
if text and self.own_echo(text) and (u is None or (u.during_speech if u.source == "clip"
|
||||
else len(text.split()) <= 2)):
|
||||
# Lumi heard itself: the clip mic while Lumi talked, or the room's echo of the last word on the head array
|
||||
# (muted while Lumi talks); a longer head-array sentence is the visitor ("okay go to P9" after a list with
|
||||
# p9, 2026-10-21). A clip-mic utterance begun after Lumi stopped is the visitor: "Lumi.", "Can you see
|
||||
# me?" seconds after a greeting were dropped 20 times on 2026-10-21
|
||||
log(f" ignored own voice: {text!r}")
|
||||
text = None
|
||||
if text and NOISE_WORDS.fullmatch(text.strip()): # a cough, a beep, "um": not worth "say it again"
|
||||
@@ -2060,7 +2063,7 @@ class Lumi:
|
||||
mouth.say("Sorry, I only understand English and Korean." if self.lang == "en" else "죄송해요, 영어와 한국어만 이해해요.")
|
||||
self.keep_listening()
|
||||
return
|
||||
fixed = brain_mod.self_correct(text, self.markers) # "go to start, no, end", "컵 집어, 아니 병"
|
||||
fixed = text if self.mission_running() else brain_mod.self_correct(text, self.markers) # "go to start, no, end"
|
||||
if fixed != text:
|
||||
log(f" corrected in the sentence: {fixed!r}")
|
||||
if not fixed: # None: not read for sure, asked; "": taken back ("never mind")
|
||||
@@ -2539,8 +2542,10 @@ class Lumi:
|
||||
|
||||
|
||||
def stop_order(text, markers):
|
||||
""""stop", "freeze", "멈춰": stop everything at once. Not "stop talking" and not a question about the stop button."""
|
||||
asked = bool(brain_mod.STOP_ASK.match(brain_mod.CALLING.sub("", text))) # "can you stop?", "멈출 수 있어?": stop
|
||||
""""stop", "freeze", "멈춰": stop everything at once. Not "stop talking" and not a question about the stop button;
|
||||
"can you stop?", "멈출 수 있어?" and "stop, where are you going?" do stop."""
|
||||
asked = bool(brain_mod.STOP_ASK.match(brain_mod.CALLING.sub("", text)) or
|
||||
re.match(r"^\W*(?:stop|halt|freeze|멈춰|정지|스톱)\W*[,.!]", text, re.I))
|
||||
return bool(FETCH_STOP.search(text) or asked) and (brain_mod.intent(text, markers) or ("",))[0] not in ("quiet", "look") \
|
||||
and not brain_mod.STOP_TALK.search(text) and ("?" not in text or asked)
|
||||
|
||||
|
||||
+10
-5
@@ -55,14 +55,15 @@ def _norm(text, markers=()):
|
||||
t = re.sub(r"(?<=[가-힣])고\s*나서(?=[\s,]|$)", "고", t) # "가고 나서" = "가고"
|
||||
for honour, plain in _HON_KO: # "가셔서" = "가서", "받으시고" = "받고"
|
||||
t = re.sub(rf"(?<![가-힣]){honour}(?=[\s,.!?]|$)", plain, t)
|
||||
return re.sub(r"(?<![가-힣])(간|온|집은|잡은|든|받은|준|놓은|돈|기다린|들른|가신|오신|기다리신|받으신|집으신|잡으신|드신|주신|놓으신)"
|
||||
return re.sub(r"(?<![가-힣])(간|온|집은|잡은|든|받은|준|놓은|돈|기다린|들른|가신|오신|기다리신|받으신|집으신|잡으신|드신|주신|놓으신|도신)"
|
||||
r"\s*(?:다음에?|후에?|뒤에?)(?=[\s,]|$)",
|
||||
lambda m: _AFTER_KO[m.group(1)], t).strip() # "p3에 간 다음에" = "p3에 가고"
|
||||
|
||||
|
||||
_AFTER_KO = {"간": "가고", "온": "오고", "집은": "집고", "잡은": "잡고", "든": "들고", "받은": "받고", "준": "주고", "놓은": "놓고",
|
||||
"돈": "돌고", "기다린": "기다리고", "들른": "들르고", "가신": "가고", "오신": "오고", "기다리신": "기다리고",
|
||||
"받으신": "받고", "집으신": "집고", "잡으신": "잡고", "드신": "들고", "주신": "주고", "놓으신": "놓고"}
|
||||
"받으신": "받고", "집으신": "집고", "잡으신": "잡고", "드신": "들고", "주신": "주고", "놓으신": "놓고",
|
||||
"도신": "돌고"}
|
||||
_HON_KO = [("가셔서", "가서"), ("가시고", "가고"), ("가셨다가", "갔다가"), ("오셔서", "와서"), ("오시고", "오고"),
|
||||
("돌아오셔서", "돌아와서"), ("기다리셔서", "기다려서"), ("기다리시고", "기다리고"), ("기다리셨다가", "기다렸다가"),
|
||||
("드시고", "들고"), ("드셔서", "들어서"), ("받으시고", "받고"),
|
||||
@@ -91,7 +92,7 @@ def _place(word, markers):
|
||||
|
||||
def _places(t, markers):
|
||||
"""'p3, p5 or p7' / 'p3' / 'here' -> list of names, or None when one of them is not a place on the map."""
|
||||
t = re.sub(r"^either\s+", "", t.strip())
|
||||
t = re.sub(r"^(?:either|(?:a )?random (?:one )?of|one of|any of)(?: the)?\s+", "", t.strip())
|
||||
words = [w for w in re.split(r"\s*(?:,\s*(?:or|and)\b|,|\bor\b|\band\b|또는|(?<=[a-z\d])이나(?=\s)|(?<=[a-z\d])나(?=\s))\s*",
|
||||
t) if w.strip()]
|
||||
names = [_place(w, markers) for w in words]
|
||||
@@ -115,7 +116,7 @@ def _go(c, markers):
|
||||
if brain.COME_BACK.fullmatch(re.sub(r"(?<=[와가])(?:서|고)$", "", c)):
|
||||
return {"do": "go", "to": "here"} # "come back", "go back where you were", "원래 자리로 돌아와"
|
||||
m = re.fullmatch(r"(?:(?:go|drive|head|come|move|return|get|walk|roll|run|proceed|navigate|travel|hurry|make your way|"
|
||||
r"take yourself)(?: back)?(?: over| on| ahead)?|(?:bring|take|carry) it(?: back)?)"
|
||||
r"take yourself)(?: back)?(?: on)?(?: over| ahead)?|(?:bring|take|carry) it(?: back)?)"
|
||||
r" to (?:the )?(?:(?:a )?random (?:one )?of |one of |any of )?(?:the )?(.+?)(?: point| marker)?", c)
|
||||
if m:
|
||||
to = _places(m.group(1), markers)
|
||||
@@ -156,6 +157,7 @@ def _move(c):
|
||||
rf"(?:(?:go|move|drive|step|walk|come|back up|head)\s+)?{_NUM} m\s+(?:to (?:the |your )?)?{_DIR}",
|
||||
rf"(?:go|move|drive|step|walk|head)\s+{_NUM} m()",
|
||||
rf"{_DIR_KO}\s*{_NUM} m\s*(?:가|가고|가서|이동|이동해|움직여|와|갔다가|갔다)(?:세요|줘)?",
|
||||
rf"{_NUM} m\s*(?:만\s*)?{_DIR_KO}\s*(?:가|가고|가서|이동|이동해|움직여|와|갔다가)(?:세요|줘)?",
|
||||
rf"(){_NUM} m\s*(?:더\s*)?(?:가|가고|가서|이동해|이동하고|이동해서|전진|전진해|전진하고)(?:세요|줘)?") # "1미터 가": forward
|
||||
for p in pats:
|
||||
m = re.fullmatch(p, c)
|
||||
@@ -518,6 +520,9 @@ def _person(c, markers):
|
||||
m = re.fullmatch(rf"(?:go|drive|head) (?:over )?to {_NAME} (?:at|in|by) (.+)", c)
|
||||
if m and _is_name(m.group(1), markers) and (to := _places(m.group(2), markers)) and len(to) == 1:
|
||||
return [{"do": "go", "to": to[0]}, {"do": "_for", "person": m.group(1)}] # the next give is for them
|
||||
m = re.fullmatch(rf"let {_NAME} have (?:it|this|that|the (?:(?:{COL}) )?(?:{OBJ})s?)", c)
|
||||
if m and _is_name(m.group(1), markers):
|
||||
return [{"do": "give", "person": m.group(1), "where": False}] # "let Sarah have it"
|
||||
m = re.fullmatch(rf"(?:bring|take|carry|fetch) (him|her|them|{_NAME}) (?:the |a |an |this |that )?(?:({COL}) )?({OBJ})s?", c)
|
||||
if m and (m.group(1) in ("him", "her", "them") or _is_name(m.group(1), markers)):
|
||||
obj, col = _thing(m.group(3), m.group(4)) # "bring her the cup": pick it, then to her (_NAME is group 2)
|
||||
@@ -654,7 +659,7 @@ def _clause(c, markers, after=None):
|
||||
|
||||
|
||||
def _clause_steps(c, markers, after=None):
|
||||
c = re.sub(r"^(?:second(?:ly)?|third(?:ly)?|fourth|first(?:ly)?|step \d)[\s,]+", "", c.strip(" .!?")) # "second, go to ..."
|
||||
c = re.sub(r"^(?:second(?:ly)?|third(?:ly)?|fourth|first(?:ly)?|last(?:ly)?|step \d)[\s,]+", "", c.strip(" .!?")) # "second, go to ..."
|
||||
c = re.sub(rf"^(?:{_FILL}[\s,]+)+|(?:[\s,]+{_FILL})+$", "", c).strip(" .!?,")
|
||||
if re.search(r"[가-힣]", c):
|
||||
c = re.sub(r"\s+", " ", c)
|
||||
|
||||
+10
-1
@@ -226,9 +226,18 @@ def map_names(t, names):
|
||||
return re.sub(r"(\b(?:to|from|at|toward|towards) (?:the )?)([a-z][a-z0-9_]*(?: [a-z0-9]+)?)", slip, t)
|
||||
|
||||
|
||||
ASR_SLIPS = [ # how whisper writes Korean commands (tests/asr_check.py, 2026-10-21) -> as said
|
||||
(r"([a-z0-9])\.?\s+(으로|로)\s*(?=가|와|이동|돌아)", r"\1\2 "), # "P3. 로가줘", "final point. 로 가": one word
|
||||
(r"(?<=로)\s*가죠(?![가-힣])", " 가 줘"), # "p3로 가 줘" written "p3로 가죠"
|
||||
]
|
||||
|
||||
|
||||
def norm(text, names=()):
|
||||
"""Lower case, numbers first ("point five meters" is a distance), then marker names (names: the map's)."""
|
||||
"""Lower case, whisper's slips (ASR_SLIPS), numbers first ("point five meters" is a distance), then marker names
|
||||
(names: the map's)."""
|
||||
t = " " + (text or "").lower().replace("’", "'") + " "
|
||||
for slip, said in ASR_SLIPS:
|
||||
t = re.sub(slip, said, t)
|
||||
return re.sub(r"\s+", " ", map_names(markers(numbers(t)), names)).strip()
|
||||
|
||||
|
||||
|
||||
+55
-6
@@ -24,6 +24,8 @@ STT_URL = "http://127.0.0.1:8096"
|
||||
WHISPER_SERVER = ROOT / "whisper.cpp/build/bin/whisper-server"
|
||||
WHISPER_MODEL = ROOT / "models/ggml-large-v3-turbo-q5_0.bin"
|
||||
PROMPT = "Hi Lumi. Hey Lumi. 루미야." # helps whisper spell the robot's name
|
||||
LANG_PROMPT = {"en": "Hi Lumi. Hey Lumi.", "ko": "안녕하세요, 루미야."} # when asked again in one language: the
|
||||
# mixed prompt made whisper write Korean in Latin letters ("Natarawa" for 나 따라와)
|
||||
last = {} # levels of the last listen() call, for the log: noise, threshold, peak
|
||||
|
||||
|
||||
@@ -81,9 +83,23 @@ def louder(audio, target=0.7):
|
||||
|
||||
LANGS = {"english": "en", "korean": "ko"}
|
||||
MIN_LOGPROB = -1.0 # below this average token log-probability whisper was guessing
|
||||
NAME_ONLY = re.compile(r"\W*(lumi|루미야?)\W*", re.I)
|
||||
KO_BONUS = 0.3 # another language named: asked in Korean and in English, a Hangul answer's average
|
||||
# log-probability counts this much more (tests/asr_check.py: +3 of 898 cases)
|
||||
ODD_KO_BONUS = 0.3 # English text with a word no dictionary has: Korean asked too, taken when written in
|
||||
# Hangul and its log-probability + this beats the English one (tests/asr_check.py)
|
||||
WORDS_FILE = pathlib.Path("/usr/share/dict/words")
|
||||
OUR_WORDS = {"lumi", "cutshion", "okay", "ok", "hmm", "um", "uh"}
|
||||
SLIPS = [ # whisper's spellings of our names (tests/asr_check.py, logs/lumi.log 2026-10-21) -> the name
|
||||
(r"\b(?:[kc]ut(?:s|t)?ch[aei]n|katchen|kutch and)(?= company|\b)", "Cutshion"),
|
||||
(r"\b(?:coaching|cushion|kitchen) (?=company)", "Cutshion "),
|
||||
(r"\bcushion(?=[은는이가을를의에])|커션|컷션", "쿳션"),
|
||||
]
|
||||
_words = set()
|
||||
last_stt = {} # language / confidence of the last transcription (see understood())
|
||||
|
||||
|
||||
BEAM_SIZE = 0 # whisper beam search width (0: the server's greedy decoding)
|
||||
HEARD_DIR = ROOT / "logs" / "heard" # the last HEARD_KEEP utterances as wav, to check what Lumi really heard
|
||||
HEARD_KEEP = 50
|
||||
|
||||
@@ -91,7 +107,8 @@ HEARD_KEEP = 50
|
||||
def _infer(wav, prompt, language=None):
|
||||
"""One whisper-server call: (text, language, language probability, average token log-probability)."""
|
||||
boundary = uuid.uuid4().hex
|
||||
fields = {"response_format": "verbose_json", "prompt": prompt, **({"language": language} if language else {})}
|
||||
fields = {"response_format": "verbose_json", "prompt": prompt, **({"language": language} if language else {}),
|
||||
**({"beam_size": BEAM_SIZE} if BEAM_SIZE else {})}
|
||||
body = "".join(f"--{boundary}\r\nContent-Disposition: form-data; name=\"{k}\"\r\n\r\n{v}\r\n"
|
||||
for k, v in fields.items()).encode()
|
||||
body += (f"--{boundary}\r\nContent-Disposition: form-data; name=\"file\"; filename=\"a.wav\"\r\n"
|
||||
@@ -106,6 +123,23 @@ def _infer(wav, prompt, language=None):
|
||||
return out.get("text", "").strip(), lang, out.get("detected_language_probability"), logprob
|
||||
|
||||
|
||||
def names(text):
|
||||
"""Our names as whisper wrote them (SLIPS) -> the names; "Lumi야" -> 루미야."""
|
||||
text = re.sub(r"\blumi(?=[야아])", "루미", text, flags=re.I)
|
||||
for slip, said in SLIPS:
|
||||
text = re.sub(slip, said, text, flags=re.I)
|
||||
return text
|
||||
|
||||
|
||||
def not_english(text):
|
||||
"""A word in English text that no dictionary has (our names, p-numbers and contractions aside)."""
|
||||
if not _words and WORDS_FILE.exists():
|
||||
_words.update(w.strip().lower() for w in WORDS_FILE.open() if w.strip().isalpha())
|
||||
words = [re.sub(r"'.*", "", w) for w in re.findall(r"[a-z']+", text.lower())]
|
||||
return bool(_words) and any(w and w not in _words and w not in OUR_WORDS and not re.fullmatch(r"p\d*", w)
|
||||
for w in words)
|
||||
|
||||
|
||||
def transcribe(audio, prompt=PROMPT):
|
||||
"""int16 mono 16 kHz -> text (empty string if nothing understood). Also fills last_stt.
|
||||
Whisper sometimes names another language (Japanese) for Korean said from afar and writes only the prompt's
|
||||
@@ -128,13 +162,28 @@ def transcribe(audio, prompt=PROMPT):
|
||||
except OSError:
|
||||
pass
|
||||
text, lang, prob, logprob = _infer(wav, prompt)
|
||||
only_name = re.fullmatch(r"\W*(lumi|루미야?)\W*", text, re.I) and len(audio) > 1.5 * RATE
|
||||
text = names(text)
|
||||
asked = {}
|
||||
|
||||
def ask(code): # transcribed with the language fixed, once per language
|
||||
if code not in asked:
|
||||
t2, _, _, lp2 = _infer(wav, LANG_PROMPT.get(code, prompt), code)
|
||||
asked[code] = (names(t2), {"en": "english", "ko": "korean"}[code], None, lp2)
|
||||
return asked[code]
|
||||
only_name = NAME_ONLY.fullmatch(text) and len(audio) > 1.5 * RATE
|
||||
if lang not in LANGS or only_name:
|
||||
tries = [(text, lang, prob, logprob)] if lang in LANGS and not only_name else []
|
||||
for code, name in (("ko", "korean"), ("en", "english")):
|
||||
t2, _, _, lp2 = _infer(wav, prompt, code)
|
||||
tries.append((t2, name, None, lp2))
|
||||
text, lang, prob, logprob = max(tries, key=lambda r: r[3])
|
||||
tries += [ask("ko"), ask("en")]
|
||||
more = [r for r in tries if not NAME_ONLY.fullmatch(r[0])] # "Lumi, 이리 와" came back "Lumi." in English
|
||||
# forced to English, Korean speech comes back translated and sure of itself: Hangul gets KO_BONUS
|
||||
text, lang, prob, logprob = max(more if only_name and more else tries,
|
||||
key=lambda r: r[3] + (KO_BONUS if re.search(r"[가-힣]", r[0]) else 0.0))
|
||||
if lang == "english" and not_english(text): # "Natarawa", "Lumi. Iriwa.": Korean written in Latin letters
|
||||
t2 = ask("ko")
|
||||
if re.search(r"[가-힣]", t2[0]) and t2[3] + ODD_KO_BONUS > logprob:
|
||||
text, lang, prob, logprob = t2
|
||||
if lang == "english" and re.search(r"[가-힣]", text):
|
||||
lang = "korean" # "Red cup. 집어줘." tagged English: the Korean is real
|
||||
last_stt.clear()
|
||||
last_stt.update(text=text, language=lang, lang_prob=prob, logprob=round(logprob, 2))
|
||||
# whisper writes things like "[BLANK_AUDIO]" or "(music)" for non-speech
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
"""Spoken cases for the speech-to-text check (tests/asr_check.py): what a person says, and how it sounds.
|
||||
|
||||
A case: {"text": the words as Lumi should read them, "say": [(lang, words), ...] the pieces the TTS speaks (a mixed
|
||||
sentence is English and Korean pieces one after the other), "lang": "en" | "ko" | "mix", "kind": "command" |
|
||||
"question" | "short" | "wake"}. The text is what the routing is judged against; "say" is how people say it
|
||||
("피쓰리로 가 줘" for "p3로 가 줘", "p five" for "p5").
|
||||
"""
|
||||
import random
|
||||
|
||||
R = random.Random(11) # the same cases every run
|
||||
CASES = []
|
||||
|
||||
|
||||
def add(kind, lang, text, *say):
|
||||
"""say: (lang, words) pieces; none given: the text itself in the case's language."""
|
||||
CASES.append({"kind": kind, "lang": lang, "text": text,
|
||||
"say": list(say) or [("ko" if lang == "ko" else "en", text)]})
|
||||
|
||||
|
||||
EN_NUM = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"]
|
||||
KO_EN_NUM = ["원", "투", "쓰리", "포", "파이브", "식스", "세븐", "에잇", "나인", "텐"]
|
||||
SINO = ["일", "이", "삼", "사", "오", "육", "칠", "팔", "구", "십"]
|
||||
|
||||
# ---- English: going to places
|
||||
for n in R.sample(range(1, 11), 6):
|
||||
w = EN_NUM[n - 1]
|
||||
add("command", "en", f"Go to p{n}.", ("en", f"Go to p {w}."))
|
||||
add("command", "en", f"Lumi, go to point {w}.")
|
||||
add("command", "en", f"Please drive to p{n}.", ("en", f"Please drive to p {w}."))
|
||||
for t in ["Head over to the final point.", "Go to the exit, please.", "Lumi, take me to the final point.",
|
||||
"Go back home.", "Go to your charger.", "Go to dock two.", "Drive to aisle a.", "Go to aisle b, please.",
|
||||
"Can you go to p seven?", "Lumi, could you go to point three?", "Go home and charge.",
|
||||
"Move to point ten.", "Take me to the exit."]:
|
||||
add("command", "en", t)
|
||||
# ---- English: coming, following, stopping
|
||||
for t in ["Come here.", "Come over here, please.", "Lumi, come to me.", "Come closer.", "Follow me.",
|
||||
"Walk with me.", "Stop following me.", "Stop.", "Wait.", "Stop right there.", "Hold on.", "That's enough.",
|
||||
"Stay here.", "Lumi, stop.", "Come back.", "Go back where you were.", "Be quiet.", "Please be quiet for a while."]:
|
||||
add("command", "en", t)
|
||||
# ---- English: head, base, lift
|
||||
for t in ["Look left.", "Look to your right.", "Look up.", "Look down a bit.", "Look behind you.", "Look at me.",
|
||||
"Look straight ahead.", "Turn your head thirty degrees to the left.", "Turn left.", "Turn right.",
|
||||
"Turn around.", "Turn right ninety degrees.", "Turn left forty five degrees.", "Move forward one meter.",
|
||||
"Back up twenty centimeters.", "Move back half a meter.", "Go forward two meters.",
|
||||
"Move left fifty centimeters.", "Move back a little.", "Go forward a tiny bit.", "Raise yourself.",
|
||||
"Lower yourself a bit.", "Go a bit faster.", "Slow down.", "Move back ten centimeters.",
|
||||
"Come forward thirty centimeters."]:
|
||||
add("command", "en", t)
|
||||
# ---- English: hand and objects
|
||||
for t in ["Open your hand.", "Close your hand.", "Wave your hand.", "Wave at me.", "Fold your arm.",
|
||||
"Pick up the red cup.", "Pick up the white cup.", "Bring me the bottle.", "Bring me a cup, please.",
|
||||
"Give me the cup.", "Hand it over.", "Put it down here.", "Put the cup on the table.", "Take this.",
|
||||
"Take the cup from my hand.", "Find the red cup and bring it to me.", "Grab the bottle.",
|
||||
"Let go of the cup.", "Put it back.", "Can you hold this for me?"]:
|
||||
add("command", "en", t)
|
||||
# ---- English: voice, songs, missions
|
||||
for t in ["Speak louder.", "Talk a bit slower.", "Speak quieter, please.", "I can't hear you.", "Sing a song.",
|
||||
"Can you sing for me?", "Go to p three, wait ten seconds, then come back.",
|
||||
"Go to the final point and then go home.", "Go to p five, then p two, then come back here."]:
|
||||
add("command", "en", t.replace("p three", "p3").replace("p five", "p5").replace("p two", "p2"), ("en", t))
|
||||
# ---- English: questions
|
||||
for t in ["What's your name?", "Who made you?", "What is Cutshion?", "Tell me about Cutshion company.",
|
||||
"Where is Cutshion located?", "How many people work at Cutshion?", "How old are you?",
|
||||
"What can you do?", "What's the weather like today?", "Is it going to rain tomorrow?", "What time is it?",
|
||||
"What's the date today?", "Can you see me?", "What am I holding?", "What color is my shirt?",
|
||||
"What color are my pants?", "How many people are here?", "Do you see a cup?", "What do you see?",
|
||||
"Is there a bottle on the table?", "How far is the cup?", "What's behind you?", "Are you a robot?",
|
||||
"How much do you weigh?", "How fast can you drive?", "How long does your battery last?",
|
||||
"What's the dollar exchange rate?", "Who is the president of Korea?", "Can you tell me a joke?",
|
||||
"Where is the restroom?", "Do you speak Korean?", "What does Cutshion make?", "Can you pick things up?",
|
||||
"How tall are you?", "What is in my hand?", "Am I wearing glasses?"]:
|
||||
add("question", "en", t)
|
||||
# ---- English: short answers, wake words
|
||||
for t in ["Yes.", "No.", "Okay.", "Thank you.", "Thanks, bye.", "Got it.", "Really?", "I see.", "Sure.",
|
||||
"No, thanks.", "Good job.", "See you later.", "That's all, thank you.", "Okay, bye."]:
|
||||
add("short", "en", t)
|
||||
for t in ["Lumi.", "Hi Lumi.", "Hey Lumi.", "Hello Lumi.", "Hi.", "Lumi, are you there?", "Hey Lumi, how are you?"]:
|
||||
add("wake", "en", t)
|
||||
|
||||
# ---- Korean: going to places
|
||||
for n in R.sample(range(1, 11), 6):
|
||||
add("command", "ko", f"p{n}로 가 줘.", ("ko", f"피{KO_EN_NUM[n - 1]}로 가 줘."))
|
||||
add("command", "ko", f"포인트 {SINO[n - 1]}으로 가.", ("ko", f"포인트 {SINO[n - 1]}으로 가."))
|
||||
for n in R.sample(range(1, 10), 3):
|
||||
add("command", "ko", f"{SINO[n - 1]} 번 포인트로 가 줘.")
|
||||
for t in ["파이널 포인트로 가 줘.", "홈으로 가.", "충전하러 가.", "도크 투로 가.", "엑시트로 가 줘.", "집으로 돌아가.",
|
||||
"루미야, 파이널로 가.", "피텐으로 가 줄래?", "포인트 파이브로 이동해."]:
|
||||
add("command", "ko", t)
|
||||
# ---- Korean: coming, following, stopping
|
||||
for t in ["이리 와.", "이쪽으로 와 줘.", "루미야 이리 와.", "가까이 와.", "나 따라와.", "따라와 줘.", "따라오지 마.",
|
||||
"멈춰.", "그만.", "기다려.", "거기 있어.", "잠깐만.", "조용히 해.", "돌아와.", "원래 자리로 돌아가."]:
|
||||
add("command", "ko", t)
|
||||
# ---- Korean: head, base, lift
|
||||
for t in ["왼쪽 봐.", "오른쪽 봐.", "위를 봐.", "아래 봐.", "뒤 봐.", "나 봐.", "정면 봐.", "고개 들어.", "고개 숙여.",
|
||||
"앞으로 일 미터 가.", "뒤로 이십 센티 가.", "반 미터 뒤로 가.", "왼쪽으로 돌아.", "오른쪽으로 구십 도 돌아.",
|
||||
"뒤로 돌아.", "키 좀 높여.", "몸 좀 낮춰.", "살짝 뒤로 가.", "조금 앞으로 와.", "더 빨리 가.", "천천히 가.",
|
||||
"앞으로 삼십 센티 가."]:
|
||||
add("command", "ko", t)
|
||||
# ---- Korean: hand and objects
|
||||
for t in ["손 펴.", "손 쥐어.", "손 흔들어 줘.", "손 인사 해 줘.", "빨간 컵 집어 줘.", "흰 컵 집어.", "컵 좀 갖다 줘.",
|
||||
"물병 가져와.", "컵 좀 주세요.", "이거 받아.", "테이블에 놔 줘.", "여기 내려놔.", "컵 테이블에 올려 줘.",
|
||||
"빨간 컵 찾아서 가져와.", "병 잡아.", "컵 내려놔.", "그거 나 줘.", "이것 좀 들고 있어."]:
|
||||
add("command", "ko", t)
|
||||
# ---- Korean: voice, songs, missions
|
||||
for t in ["크게 말해 줘.", "천천히 말해.", "소리 좀 줄여.", "안 들려.", "노래 불러 줘.", "노래 하나 해 줄래?",
|
||||
"파이널 갔다가 홈으로 와."]:
|
||||
add("command", "ko", t)
|
||||
add("command", "ko", "p3 갔다가 십 초 기다리고 돌아와.", ("ko", "피쓰리 갔다가 십 초 기다리고 돌아와."))
|
||||
# ---- Korean: questions
|
||||
for t in ["이름이 뭐야?", "누가 만들었어?", "컷션이 뭐야?", "컷션 회사에 대해 알려 줘.", "컷션은 어디에 있어?",
|
||||
"몇 살이야?", "뭘 할 수 있어?", "오늘 날씨 어때?", "내일 비 와?", "지금 몇 시야?", "오늘 며칠이야?",
|
||||
"나 보여?", "내가 뭘 들고 있어?", "내 옷 무슨 색이야?", "여기 사람 몇 명 있어?", "컵 보여?", "뭐가 보여?",
|
||||
"테이블 위에 뭐 있어?", "컵 얼마나 멀리 있어?", "너 로봇이야?", "무게가 얼마나 돼?", "배터리 얼마나 가?",
|
||||
"달러 환율 알려 줘.", "농담 하나 해 줘.", "화장실 어디예요?", "영어 할 줄 알아?", "물건 집을 수 있어?",
|
||||
"키가 몇이야?", "내 손에 뭐 있어?", "나 안경 썼어?"]:
|
||||
add("question", "ko", t)
|
||||
# ---- Korean: short answers, wake words
|
||||
for t in ["네.", "아니요.", "응.", "고마워요.", "감사합니다.", "알겠어요.", "그래요?", "아 그렇구나.", "됐어요, 고마워요.",
|
||||
"안녕히 계세요.", "수고하세요.", "잘했어요.", "좋아요."]:
|
||||
add("short", "ko", t)
|
||||
for t in ["루미야.", "안녕 루미야.", "루미야, 안녕.", "루미야 거기 있어?", "안녕하세요."]:
|
||||
add("wake", "ko", t)
|
||||
|
||||
# ---- Mixed: English pieces inside Korean and the reverse
|
||||
for t, say in [("Lumi, 이리 와.", [("en", "Lumi,"), ("ko", "이리 와.")]),
|
||||
("루미야, come here.", [("ko", "루미야,"), ("en", "come here.")]),
|
||||
("Lumi, 나 따라와.", [("en", "Lumi,"), ("ko", "나 따라와.")]),
|
||||
("루미야, follow me.", [("ko", "루미야,"), ("en", "follow me.")]),
|
||||
("Lumi, 멈춰.", [("en", "Lumi,"), ("ko", "멈춰.")]),
|
||||
("루미야, stop.", [("ko", "루미야,"), ("en", "stop.")]),
|
||||
("p3로 가 줘.", [("en", "p three"), ("ko", "로 가 줘.")]),
|
||||
("p5로 가.", [("en", "p five"), ("ko", "로 가.")]),
|
||||
("final point로 가 줘.", [("en", "final point"), ("ko", "로 가 줘.")]),
|
||||
("home으로 가.", [("en", "home"), ("ko", "으로 가.")]),
|
||||
("dock two로 가.", [("en", "dock two"), ("ko", "로 가.")]),
|
||||
("Lumi, 왼쪽 봐.", [("en", "Lumi,"), ("ko", "왼쪽 봐.")]),
|
||||
("루미야, look left.", [("ko", "루미야,"), ("en", "look left.")]),
|
||||
("Lumi, 손 흔들어 줘.", [("en", "Lumi,"), ("ko", "손 흔들어 줘.")]),
|
||||
("루미야, open your hand.", [("ko", "루미야,"), ("en", "open your hand.")]),
|
||||
("cup 좀 가져와.", [("en", "cup"), ("ko", "좀 가져와.")]),
|
||||
("red cup 집어 줘.", [("en", "red cup"), ("ko", "집어 줘.")]),
|
||||
("Lumi, 오늘 날씨 어때?", [("en", "Lumi,"), ("ko", "오늘 날씨 어때?")]),
|
||||
("루미야, what's your name?", [("ko", "루미야,"), ("en", "what's your name?")]),
|
||||
("Cutshion이 뭐야?", [("en", "Cutshion"), ("ko", "이 뭐야?")]),
|
||||
("Okay, 고마워요.", [("en", "Okay,"), ("ko", "고마워요.")]),
|
||||
("네, thank you.", [("ko", "네,"), ("en", "thank you.")]),
|
||||
("Lumi, 뒤로 이십 센티 가.", [("en", "Lumi,"), ("ko", "뒤로 이십 센티 가.")]),
|
||||
("루미야, move back one meter.", [("ko", "루미야,"), ("en", "move back one meter.")]),
|
||||
("Lumi, 노래 불러 줘.", [("en", "Lumi,"), ("ko", "노래 불러 줘.")]),
|
||||
("루미야, sing a song.", [("ko", "루미야,"), ("en", "sing a song.")])]:
|
||||
add("command" if "?" not in t else "question", "mix", t, *say)
|
||||
@@ -0,0 +1,66 @@
|
||||
"""A second set of spoken cases for tests/asr_check.py (--cases 2), kept apart from asr_cases.py so a fix made on
|
||||
the first set is checked on words it has not seen: the owner's way of saying commands (logs/lumi.log 2026-10-21),
|
||||
polite Korean, numbers and times, follow-ups. Same form as asr_cases.py.
|
||||
"""
|
||||
from tests.asr_cases import EN_NUM, KO_EN_NUM, SINO
|
||||
|
||||
CASES = []
|
||||
|
||||
|
||||
def add(kind, lang, text, *say):
|
||||
CASES.append({"kind": kind, "lang": lang, "text": text,
|
||||
"say": list(say) or [("ko" if lang == "ko" else "en", text)]})
|
||||
|
||||
|
||||
# ---- English as the owner says it
|
||||
for n in (1, 3, 5, 7, 9, 10):
|
||||
add("command", "en", f"Let's go to p{n}.", ("en", f"Let's go to p {EN_NUM[n - 1]}."))
|
||||
add("command", "en", f"Lumi, go to p{n} point.", ("en", f"Lumi, go to p {EN_NUM[n - 1]} point."))
|
||||
for t in ["Let's come to me.", "Let's follow me.", "Look at the back side.", "Look at the left side.",
|
||||
"Look at the right side.", "Can you shake your hand?", "Open your hand, please.", "Let's go back one meter.",
|
||||
"Come back twenty centimeters.", "Let's go home.", "Go to the final point, please.", "Stop, stop.",
|
||||
"Okay, you can go now.", "Go to p ten and wait thirty seconds, then come back here again.",
|
||||
"Lumi, what is the color of my t-shirt?", "What about my shoes?", "What is in my hand?",
|
||||
"Can you sing a song for me?", "Who made you?", "How many people work in Cutshion company?",
|
||||
"Can you give me information about Cutshion company?", "Where is the location?", "Can you explain more?",
|
||||
"Turn left ninety degrees.", "Move forward fifty centimeters.", "Raise your head.", "Look down.",
|
||||
"Give me the red cup.", "Put the cup on the white table.", "Bring me the white cup from the table.",
|
||||
"Pick up the bottle and give it to me.", "Take the cup and go to p five.", "Wait here.",
|
||||
"What time is it now?", "What's the weather in Seoul?", "Hi Lumi, how are you today?",
|
||||
"Lumi, are you listening?", "Speak slower, please.", "A bit louder.", "Good job, Lumi."]:
|
||||
add("command" if not t.endswith("?") else "question", "en",
|
||||
t.replace("p ten", "p10").replace("p five", "p5"), ("en", t))
|
||||
|
||||
# ---- Korean, polite and plain
|
||||
for n in (2, 4, 6, 8):
|
||||
add("command", "ko", f"p{n}로 가 주세요.", ("ko", f"피{KO_EN_NUM[n - 1]}로 가 주세요."))
|
||||
add("command", "ko", f"{SINO[n - 1]} 번 포인트로 가 주실래요?")
|
||||
for t in ["이리 와 주세요.", "저 따라오세요.", "잠깐 멈춰 주세요.", "충전하러 가세요.", "파이널 포인트로 가 주세요.",
|
||||
"왼쪽 좀 봐 주세요.", "오른쪽을 봐요.", "뒤를 봐 줘.", "고개 좀 들어 봐.", "앞으로 오십 센티 가 주세요.",
|
||||
"뒤로 일 미터 가요.", "오른쪽으로 돌아 주세요.", "한 바퀴 돌아.", "손 좀 펴 주세요.", "손 오므려.",
|
||||
"빨간 컵 좀 갖다 주세요.", "흰 컵 테이블에 올려 주세요.", "물병 좀 집어 줄래요?", "이거 좀 받아 주세요.",
|
||||
"컵 여기 놔 주세요.", "노래 한 곡 불러 주세요.", "조금 더 크게 말해 주세요.", "말 좀 천천히 해 줘.",
|
||||
"피세븐 갔다가 삼십 초 기다리고 돌아와.", "홈으로 가서 충전해.", "여기서 기다려.", "그만해.", "가만히 있어."]:
|
||||
add("command", "ko", t.replace("피세븐", "p7"), ("ko", t))
|
||||
for t in ["너 이름이 뭐예요?", "누가 너를 만들었어요?", "쿳션 회사는 뭐 하는 회사예요?", "쿳션 직원은 몇 명이에요?",
|
||||
"지금 몇 시예요?", "오늘 날씨 어때요?", "서울 날씨 알려 주세요.", "제가 보여요?", "제 손에 뭐가 있어요?",
|
||||
"제 셔츠 무슨 색이에요?", "여기 몇 명 있어요?", "앞에 뭐가 보여요?", "컵 어디 있어?", "너는 몇 살이에요?",
|
||||
"무엇을 할 수 있어요?", "노래 할 줄 알아요?", "한국어 잘해요?", "충전은 얼마나 걸려요?"]:
|
||||
add("question", "ko", t)
|
||||
for t in ["네, 맞아요.", "아니요, 괜찮아요.", "알겠습니다.", "고맙습니다.", "잘 가요.", "다음에 봐요.", "진짜요?", "그렇구나."]:
|
||||
add("short", "ko", t)
|
||||
for t in ["루미.", "루미야, 안녕?", "안녕 루미."]:
|
||||
add("wake", "ko", t)
|
||||
|
||||
# ---- Mixed
|
||||
for t, say in [("Lumi, 홈으로 가.", [("en", "Lumi,"), ("ko", "홈으로 가.")]),
|
||||
("루미야, go home.", [("ko", "루미야,"), ("en", "go home.")]),
|
||||
("p7으로 가 주세요.", [("en", "p seven"), ("ko", "으로 가 주세요.")]),
|
||||
("Lumi, 컵 좀 갖다 줘.", [("en", "Lumi,"), ("ko", "컵 좀 갖다 줘.")]),
|
||||
("루미야, what can you do?", [("ko", "루미야,"), ("en", "what can you do?")]),
|
||||
("Lumi, 지금 몇 시야?", [("en", "Lumi,"), ("ko", "지금 몇 시야?")]),
|
||||
("Okay, 이제 가도 돼.", [("en", "Okay,"), ("ko", "이제 가도 돼.")]),
|
||||
("white cup 테이블에 놔 줘.", [("en", "white cup"), ("ko", "테이블에 놔 줘.")]),
|
||||
("Lumi, 오른쪽 봐.", [("en", "Lumi,"), ("ko", "오른쪽 봐.")]),
|
||||
("루미야, turn around.", [("ko", "루미야,"), ("en", "turn around.")])]:
|
||||
add("command" if "?" not in t else "question", "mix", t, *say)
|
||||
@@ -0,0 +1,235 @@
|
||||
"""Speech-to-text check: spoken cases (tests/asr_cases.py) made with the TTS, made to sound like the robot's
|
||||
microphones, sent through ears.transcribe() exactly as Lumi does, then through Lumi's routing.
|
||||
|
||||
.venv/bin/python tests/asr_check.py # all cases, both rooms
|
||||
.venv/bin/python tests/asr_check.py --room far # one room: near (clip mic) | far (head array, echo, people)
|
||||
.venv/bin/python tests/asr_check.py --prompt "..." # another whisper prompt than ears.PROMPT
|
||||
.venv/bin/python tests/asr_check.py --cases 2 # the second set (tests/asr_cases2.py)
|
||||
.venv/bin/python tests/asr_check.py --heard # also the real clips in logs/heard/ (text only, no judgement)
|
||||
.venv/bin/python tests/asr_check.py --set LANG_RETRY=False --tag before # an ears constant; -> logs/asr_check_before.md
|
||||
|
||||
Needs a whisper-server; the check starts its own on STT_PORT (never the live one on 8096, which Lumi uses).
|
||||
A case is right when the text routes as the written text does (tests/command_check.rules: the same motion, or both
|
||||
for the LLM and the words nearly the same), whisper's language is the spoken one, and ears.understood() takes it
|
||||
(else Lumi says "say it again"). -> logs/asr_check.md / .json; audio cached in logs/asr_check/.
|
||||
"""
|
||||
import collections
|
||||
import difflib
|
||||
import hashlib
|
||||
import json
|
||||
import pathlib
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import urllib.request
|
||||
import wave
|
||||
|
||||
import numpy as np
|
||||
|
||||
from assistant import brain, lumi
|
||||
from audio import ears
|
||||
from tests.asr_cases import CASES
|
||||
from tests.asr_cases2 import CASES as CASES2
|
||||
from tests.command_check import rules
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
OUT = ROOT / "logs" / "asr_check"
|
||||
STT_PORT = 8097
|
||||
MARKERS = ['home', 'PInit', 'Wp', 'a', 'b', 'dock2', 'exit', 'final', 'p1', 'p10', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7',
|
||||
'p8', 'p9', 'aisle_a', 'aisle_b'] # the map of 2026-10-21 and a few more
|
||||
VOICES = ["F1", "F2", "F3", "F4", "F5", "M1", "M2", "M3", "M4", "M5"]
|
||||
ROOMS = { # how the sound reaches whisper: echo time (s), signal to noise (dB), level (peak of full scale), babble
|
||||
"near": dict(rt60=0.15, snr=28, peak=0.4, babble=False), # clip mic at the chest
|
||||
"far": dict(rt60=0.5, snr=12, peak=0.04, babble=True), # head array 1.5-3 m away, people talking around
|
||||
}
|
||||
TEXT_CLOSE = 0.8 # difflib ratio of the normalised texts for a question / short answer to count as heard
|
||||
|
||||
|
||||
def start_server():
|
||||
url = f"http://127.0.0.1:{STT_PORT}"
|
||||
try:
|
||||
urllib.request.urlopen(url + "/", timeout=1)
|
||||
except OSError:
|
||||
log = open(OUT / "whisper.log", "a")
|
||||
subprocess.Popen([str(ears.WHISPER_SERVER), "-m", str(ears.WHISPER_MODEL), "--host", "127.0.0.1",
|
||||
"--port", str(STT_PORT), "-l", "auto", "-nt"], stdout=log, stderr=log, start_new_session=True)
|
||||
for _ in range(120):
|
||||
time.sleep(0.5)
|
||||
try:
|
||||
urllib.request.urlopen(url + "/", timeout=1)
|
||||
break
|
||||
except OSError:
|
||||
pass
|
||||
ears.STT_URL = url
|
||||
ears.HEARD_DIR = OUT / "heard" # never the robot's logs/heard
|
||||
|
||||
|
||||
_tts = {}
|
||||
|
||||
|
||||
def synth(pieces, voice, speed):
|
||||
"""[(lang, words)] -> float32 mono 16 kHz, cached."""
|
||||
key = hashlib.md5(json.dumps([pieces, voice, speed]).encode()).hexdigest()[:16]
|
||||
f = OUT / "audio" / f"{key}.npy"
|
||||
if f.exists():
|
||||
return np.load(f)
|
||||
if not _tts:
|
||||
from supertonic import TTS
|
||||
_tts["tts"] = TTS(model="supertonic-3", model_dir=ROOT / "models/supertonic3", auto_download=False,
|
||||
intra_op_num_threads=4)
|
||||
tts = _tts["tts"]
|
||||
style = tts.get_voice_style(voice)
|
||||
parts = []
|
||||
for lang, words in pieces:
|
||||
wav, _ = tts.synthesize(words, voice_style=style, lang=lang, total_steps=4, speed=speed, silence_duration=0.1)
|
||||
parts.append(np.asarray(wav, np.float32).reshape(-1))
|
||||
x = np.concatenate(parts)
|
||||
x = np.interp(np.arange(0, len(x), tts.sample_rate / ears.RATE), np.arange(len(x)), x).astype(np.float32)
|
||||
f.parent.mkdir(parents=True, exist_ok=True)
|
||||
np.save(f, x)
|
||||
return x
|
||||
|
||||
|
||||
def room(x, how, rng, others=()):
|
||||
"""Echo (exponential noise tail), people talking (other cases' audio), noise, a quiet level; -> int16."""
|
||||
n = int(how["rt60"] * ears.RATE)
|
||||
ir = rng.standard_normal(n) * np.exp(-6.9 * np.arange(n) / n)
|
||||
ir[0] = 1.0 / 0.3
|
||||
ir *= 0.3
|
||||
y = np.convolve(x, ir)[:len(x) + n // 2]
|
||||
y = np.concatenate([np.zeros(int(0.3 * ears.RATE)), y, np.zeros(int(0.4 * ears.RATE))]) # pre-roll, end silence
|
||||
p = float(np.mean(y ** 2)) + 1e-12
|
||||
noise = np.cumsum(rng.standard_normal(len(y))) # brown-ish room rumble + hiss
|
||||
noise = noise - np.convolve(noise, np.ones(400) / 400, "same") + 0.5 * rng.standard_normal(len(y))
|
||||
if how["babble"] and others:
|
||||
b = np.zeros(len(y))
|
||||
for o in others:
|
||||
start = rng.integers(0, max(1, len(y) - len(o))) if len(o) < len(y) else 0
|
||||
seg = o[:len(y) - start]
|
||||
b[start:start + len(seg)] += seg
|
||||
noise = noise / np.sqrt(np.mean(noise ** 2)) + 2.0 * b / (np.sqrt(np.mean(b ** 2)) + 1e-9)
|
||||
noise *= np.sqrt(p / 10 ** (how["snr"] / 10) / (np.mean(noise ** 2) + 1e-12))
|
||||
y = y + noise
|
||||
y *= how["peak"] / (np.abs(y).max() + 1e-9)
|
||||
return np.clip(y * 32767, -32767, 32767).astype(np.int16)
|
||||
|
||||
|
||||
def plain(t):
|
||||
return re.sub(r"[^\w가-힣 ]", "", (t or "").lower()).split()
|
||||
|
||||
|
||||
def route(text, b):
|
||||
try:
|
||||
r = rules(text, "idle", MARKERS, b) or "llm"
|
||||
if r.startswith("action:fetch"): # its target is the whole text: what it asks for
|
||||
task = brain.fetch_from_text(text, MARKERS)[0]
|
||||
r = "action:fetch " + " ".join(f"{k}={task[k]}" for k in sorted(task) if task[k] and k != "said")
|
||||
return r
|
||||
except Exception as e: # noqa: BLE001 - a crash is a failure of that case
|
||||
return f"error {e!r}"
|
||||
|
||||
|
||||
def judge(c, heard, stt):
|
||||
"""(verdict, why): right | slip (text heard wrong) | lang (wrong language tag) | unclear (asked again) | lost."""
|
||||
if not heard:
|
||||
return "lost", "nothing"
|
||||
want_lang = {"en": "english", "ko": "korean"}.get(c["lang"])
|
||||
if c["kind"] == "wake":
|
||||
ok = bool(lumi.WAKE.search(heard) or lumi.HELLO_ONLY.match(heard))
|
||||
return ("right", "") if ok else ("slip", "no wake word")
|
||||
clear = ears.understood() or (ears.heard_clearly() and lumi.own_command(heard, ""))
|
||||
if not clear:
|
||||
return "unclear", f"{stt.get('language')} {stt.get('logprob')}"
|
||||
if want_lang and stt.get("language") != want_lang:
|
||||
return "lang", stt.get("language")
|
||||
want, got = route(c["text"], brain.Brain()), route(heard, brain.Brain())
|
||||
if want != got:
|
||||
return "slip", f"{got} (want {want})"
|
||||
if want == "llm" or c["kind"] in ("short", "question"):
|
||||
r = difflib.SequenceMatcher(None, " ".join(plain(c["text"])), " ".join(plain(heard))).ratio()
|
||||
if r < TEXT_CLOSE:
|
||||
return "slip", f"text {r:.2f}"
|
||||
return "right", ""
|
||||
|
||||
|
||||
def main(args):
|
||||
OUT.mkdir(parents=True, exist_ok=True)
|
||||
rooms = [args[args.index("--room") + 1]] if "--room" in args else list(ROOMS)
|
||||
if "--prompt" in args:
|
||||
ears.PROMPT = args[args.index("--prompt") + 1]
|
||||
for i, a in enumerate(args): # --set LANG_RETRY=False: an ears constant
|
||||
if a == "--set":
|
||||
k, v = args[i + 1].split("=", 1)
|
||||
setattr(ears, k, type(getattr(ears, k))(eval(v)))
|
||||
only = args[args.index("--only") + 1] if "--only" in args else None
|
||||
tag = args[args.index("--tag") + 1] if "--tag" in args else ""
|
||||
if "--port" in args: # a whisper-server already running there
|
||||
global STT_PORT
|
||||
STT_PORT = int(args[args.index("--port") + 1])
|
||||
start_server()
|
||||
rng = np.random.default_rng(5)
|
||||
rows, t0 = [], time.time()
|
||||
pool = CASES2 if "--cases" in args and args[args.index("--cases") + 1] == "2" else CASES
|
||||
cases = [c for c in pool if not only or re.search(only, c["text"])]
|
||||
for i, c in enumerate(cases):
|
||||
voice, speed = VOICES[i % len(VOICES)], [0.85, 0.95, 1.05, 1.15][(i // len(VOICES)) % 4]
|
||||
x = synth(c["say"], voice, speed)
|
||||
for rname in rooms:
|
||||
others = [synth(pool[(i * 7 + k * 13) % len(pool)]["say"], VOICES[(i + k + 3) % 10], 1.0) * 0.5
|
||||
for k in range(3)] if ROOMS[rname]["babble"] else ()
|
||||
audio = room(x, ROOMS[rname], rng, others)
|
||||
t1 = time.time()
|
||||
heard = ears.transcribe(audio, ears.PROMPT)
|
||||
stt = dict(ears.last_stt, secs=round(time.time() - t1, 2))
|
||||
verdict, why = judge(c, heard, stt)
|
||||
rows.append({**c, "room": rname, "voice": voice, "speed": speed, "heard": heard, "stt": stt,
|
||||
"verdict": verdict, "why": why})
|
||||
if verdict != "right" and "-v" in args:
|
||||
print(f"{verdict:7} [{c['lang']}/{rname}] {c['text']!r} -> {heard!r} {why}", flush=True)
|
||||
if "--heard" in args:
|
||||
heard_clips(rows)
|
||||
name = "asr_check" + (f"_{tag}" if tag else "")
|
||||
(ROOT / "logs" / f"{name}.json").write_text(json.dumps(rows, ensure_ascii=False, indent=0))
|
||||
report(rows, time.time() - t0, ROOT / "logs" / f"{name}.md")
|
||||
|
||||
|
||||
def heard_clips(rows):
|
||||
"""The real utterances kept in logs/heard (local only): the text with this prompt, no judgement."""
|
||||
for f in sorted((ROOT / "logs" / "heard").glob("*.wav")):
|
||||
with wave.open(str(f)) as w:
|
||||
audio = np.frombuffer(w.readframes(w.getnframes()), np.int16)
|
||||
heard = ears.transcribe(audio, ears.PROMPT)
|
||||
rows.append({"kind": "real", "lang": "?", "text": f.name, "room": "real", "heard": heard,
|
||||
"stt": dict(ears.last_stt), "verdict": "real", "why": ""})
|
||||
|
||||
|
||||
def report(rows, secs, path):
|
||||
judged = [r for r in rows if r["verdict"] != "real"]
|
||||
by = collections.defaultdict(collections.Counter)
|
||||
for r in judged:
|
||||
for k in (f"{r['lang']} {r['room']}", f"{r['kind']} {r['room']}", "ALL"):
|
||||
by[k][r["verdict"]] += 1
|
||||
kinds = ["right", "slip", "lang", "unclear", "lost"]
|
||||
lines = [f"# Speech-to-text check ({time.strftime('%Y-%m-%d %H:%M')}, prompt {ears.PROMPT!r}, {secs:.0f} s)", "",
|
||||
f"{len(judged)} spoken cases. " + ", ".join(kinds) + ". Speech-to-text time per case: median "
|
||||
f"{sorted(r['stt'].get('secs', 0) for r in judged)[len(judged) // 2] if judged else 0} s, 90 % "
|
||||
f"{sorted(r['stt'].get('secs', 0) for r in judged)[int(len(judged) * 0.9)] if judged else 0} s.", "",
|
||||
"| group | cases | " + " | ".join(kinds) + " |", "|---|---|" + "---|" * len(kinds)]
|
||||
for k in sorted(by, key=lambda k: (k == "ALL", k)):
|
||||
c = by[k]
|
||||
lines.append(f"| {k} | {sum(c.values())} | " + " | ".join(str(c[v]) for v in kinds) + " |")
|
||||
for v in kinds[1:]:
|
||||
lines += ["", f"## {v}", ""] + [f"- [{r['lang']}/{r['room']} {r['voice']} {r['speed']}] {r['text']!r} -> "
|
||||
f"{r['heard']!r} [{r['stt'].get('language')} {r['stt'].get('logprob')}] {r['why']}"
|
||||
for r in judged if r["verdict"] == v]
|
||||
real = [r for r in rows if r["verdict"] == "real"]
|
||||
if real:
|
||||
lines += ["", "## Real clips", ""] + [f"- {r['text']}: {r['heard']!r} [{r['stt'].get('language')} "
|
||||
f"{r['stt'].get('logprob')}]" for r in real]
|
||||
path.write_text("\n".join(lines) + "\n")
|
||||
print("\n".join(lines[:len(by) + 6]))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
@@ -126,7 +126,7 @@ for t, want in [("move forward 1 meter", "action:move forward 1"), ("could you g
|
||||
("move back", "action:move back"), ("move forward 4 meters", "refuse"), ("앞으로 10미터 가", "refuse"),
|
||||
("move back twenty", "ask")]:
|
||||
add("move", t, want)
|
||||
for t, want in [("turn left", "action:turn left 90"), ("turn to the right please", "action:turn right 90"),
|
||||
for t, want in [("turn left", "action:turn left 90"), ("turn to the right please", "action:turn right"),
|
||||
("turn around", "action:turn around"), ("could you turn left 30 degrees?", "action:turn left 30"),
|
||||
("turn right 45 degrees", "action:turn right 45"), ("왼쪽으로 돌아", "action:turn left 90"),
|
||||
("오른쪽으로 돌아 줘", "action:turn right 90"), ("뒤로 돌아", "action:turn around"),
|
||||
|
||||
@@ -0,0 +1,475 @@
|
||||
"""Third command set (2026-10-21 night), written blind from docs/14 (§4, §6) and docs/17 only: single spoken commands
|
||||
and near misses on the conference map, English, Korean (반말, 해요체, 하십시오체) and mixed, as people say them at a
|
||||
booth: fillers, hedges ("could you maybe", "I was wondering if", "~해 줄 수 있어요?", "~해 주실래요?"), negations,
|
||||
conditions and later times (no motion), corrections inside the sentence, things the body can't do, questions about
|
||||
abilities, remarks that only look like commands, and whisper's slips. Same notation as tests/command_cases2.py; the
|
||||
intent names start with "blind:". A question back ("ask" / "talk") is accepted wherever the words are unclear; a wrong
|
||||
motion never is.
|
||||
"""
|
||||
CONF = ["home", "start", "end", "init", "final", "middle", "table_front", "stage", "booth_2", "dock2"]
|
||||
CASES = []
|
||||
|
||||
|
||||
def add(intent, text, expect, state="idle", before=None): # before: (what was said, Lumi's action line)
|
||||
lang = "ko" if any("가" <= ch <= "힣" for ch in text) else "en"
|
||||
CASES.append({"intent": "blind:" + intent, "text": text, "lang": lang, "state": state, "before": before,
|
||||
"expect": expect, "markers": CONF})
|
||||
|
||||
|
||||
def each(intent, templates, fills, expect, state="idle", before=None):
|
||||
for tpl in templates:
|
||||
for word, val in fills:
|
||||
add(intent, tpl.format(o=word), expect.format(o=val), state, before)
|
||||
|
||||
|
||||
GO = "action:go_to {o} | mission"
|
||||
NO_MOVE = "talk | ask"
|
||||
CANT = "refuse | talk"
|
||||
|
||||
# ---------- go to a marker: English ----------
|
||||
each("go", ["I was wondering if you could go to {o}", "could you go over to {o} real quick?",
|
||||
"hey Lumi, {o}, please. Go there.", "so, uh, can you head to {o}?", "would you mind going to {o}?"],
|
||||
[("the stage", "stage"), ("booth two", "booth_2"), ("table front", "table_front"), ("the middle", "middle"),
|
||||
("the start", "start"), ("the end point", "end"), ("init", "init"), ("final", "final")], GO) # 40
|
||||
add("go", "go home", GO.format(o="home"))
|
||||
add("go", "Lumi, go back home please", GO.format(o="home"))
|
||||
add("go", "go to dock two", GO.format(o="dock2"))
|
||||
add("go", "go to dock 2", GO.format(o="dock2"))
|
||||
add("go", "drive over to booth 2", GO.format(o="booth_2"))
|
||||
add("go", "go to booth number two", GO.format(o="booth_2"))
|
||||
add("go", "take yourself to the table front", GO.format(o="table_front"))
|
||||
add("go", "go to the front of the table", "action:go_to table_front | mission | ask")
|
||||
add("go", "go to the charger", "action:go_to dock2 | action:go_to home | ask")
|
||||
add("go", "go charge yourself", "action:go_to dock2 | action:go_to home | ask | talk")
|
||||
add("go", "go to the starting point", "action:go_to start | ask")
|
||||
add("go", "go to the end", GO.format(o="end"))
|
||||
# whisper's slips: one letter off after "to"
|
||||
add("go_whisper", "go to the stagee", GO.format(o="stage"))
|
||||
add("go_whisper", "go to the stag", GO.format(o="stage"))
|
||||
add("go_whisper", "go to boot two", "action:go_to booth_2 | ask")
|
||||
add("go_whisper", "go to booth to", "action:go_to booth_2 | ask")
|
||||
add("go_whisper", "go to the midle", GO.format(o="middle"))
|
||||
add("go_whisper", "go to finale", "action:go_to final | ask")
|
||||
add("go_whisper", "go to in it", "action:go_to init | ask")
|
||||
add("go_whisper", "go to table fronts", "action:go_to table_front | ask")
|
||||
# not on this map
|
||||
add("go_unknown", "go to the kitchen", "refuse | talk | ask")
|
||||
add("go_unknown", "go to p3", "refuse | talk | ask")
|
||||
add("go_unknown", "go to booth three", "refuse | talk | ask")
|
||||
add("go_unknown", "go to the exit", "refuse | talk | ask")
|
||||
add("go_unknown", "부스 쓰리로 가", "refuse | talk | ask")
|
||||
add("go_unknown", "주방으로 가", "refuse | talk | ask")
|
||||
|
||||
# ---------- go to a marker: Korean, every speech level ----------
|
||||
each("go_ko", ["{o}로 가", "{o}로 가요", "{o}로 가 주세요", "{o}로 가십시오", "{o}로 가 주실래요?",
|
||||
"{o}로 가 줄 수 있어요?", "음 {o}로 좀 가 줄래?"],
|
||||
[("스테이지", "stage"), ("부스 투", "booth_2"), ("테이블 프론트", "table_front"), ("엔드", "end")], GO) # 28
|
||||
add("go_ko", "스타트로 이동해 주십시오", GO.format(o="start"))
|
||||
add("go_ko", "미들로 가 봐", GO.format(o="middle"))
|
||||
add("go_ko", "파이널로 가 주세요", GO.format(o="final"))
|
||||
add("go_ko", "이닛으로 가", GO.format(o="init"))
|
||||
add("go_ko", "홈으로 가요", GO.format(o="home"))
|
||||
add("go_ko", "집에 가", "action:go_to home | ask")
|
||||
add("go_ko", "도크 투로 가 주세요", GO.format(o="dock2"))
|
||||
add("go_ko", "충전하러 가", "action:go_to dock2 | action:go_to home | ask | talk")
|
||||
add("go_ko", "부스 2번으로 가 줘", GO.format(o="booth_2"))
|
||||
|
||||
# ---------- go: mixed ----------
|
||||
add("go_mixed", "stage로 가 줘", GO.format(o="stage"))
|
||||
add("go_mixed", "booth two로 가 주세요", GO.format(o="booth_2"))
|
||||
add("go_mixed", "table front로 이동", GO.format(o="table_front"))
|
||||
add("go_mixed", "go to 스테이지", GO.format(o="stage"))
|
||||
add("go_mixed", "please 엔드로 가", GO.format(o="end"))
|
||||
add("go_mixed", "Lumi, middle 쪽으로 가 볼래?", GO.format(o="middle"))
|
||||
add("go_mixed", "home으로 돌아가", GO.format(o="home"))
|
||||
|
||||
# ---------- corrections inside the sentence ----------
|
||||
add("correct", "go to start, no, end", GO.format(o="end"))
|
||||
add("correct", "go to the stage, sorry, I mean booth two", GO.format(o="booth_2"))
|
||||
add("correct", "go to booth two, uh no wait, table front", GO.format(o="table_front"))
|
||||
add("correct", "go to the middle, actually no, the final point", GO.format(o="final"))
|
||||
add("correct", "스타트로 가, 아니 엔드로", GO.format(o="end"))
|
||||
add("correct", "스테이지로 가요, 아 아니다, 부스 투로 가요", GO.format(o="booth_2"))
|
||||
add("correct", "미들로, 아니 테이블 프론트로 가 주세요", GO.format(o="table_front"))
|
||||
add("correct", "turn left, I mean right", "action:turn right 90")
|
||||
add("correct", "왼쪽으로 돌아, 아니 오른쪽", "action:turn right 90")
|
||||
add("correct", "move forward 1 meter, no, 2 meters", "action:move forward 2")
|
||||
add("correct", "앞으로 1미터, 아니 50센티 가", "action:move forward 0.5")
|
||||
add("correct", "pick up the cup, no, the apple", "action:pick apple")
|
||||
add("correct", "사과 집어, 아니 오렌지", "action:pick orange")
|
||||
add("correct", "look left, no, right", "action:look right")
|
||||
add("correct_back", "go to the stage, never mind", NO_MOVE)
|
||||
add("correct_back", "스테이지로 가, 아니 됐어", NO_MOVE)
|
||||
add("correct_back", "turn around, actually forget it", NO_MOVE)
|
||||
add("correct_back", "follow me, oh never mind", NO_MOVE)
|
||||
add("correct_unclear", "go to the stage, no, the kitchen", NO_MOVE)
|
||||
add("correct_unclear", "부스 투로 가, 아니 화장실로", NO_MOVE)
|
||||
add("correct_talk", "I like apples, no, I love them", "talk")
|
||||
|
||||
# ---------- negations: no motion ----------
|
||||
add("neg", "don't go to the stage", NO_MOVE)
|
||||
add("neg", "please don't follow me", NO_MOVE)
|
||||
add("neg", "don't turn around", NO_MOVE)
|
||||
add("neg", "you don't need to come here", NO_MOVE)
|
||||
add("neg", "don't pick up the cup", NO_MOVE)
|
||||
add("neg", "no need to wave", NO_MOVE)
|
||||
add("neg", "스테이지로 가지 마", NO_MOVE)
|
||||
add("neg", "따라오지 마세요", NO_MOVE)
|
||||
add("neg", "컵 집지 마", NO_MOVE)
|
||||
add("neg", "이리 오지 마십시오", NO_MOVE)
|
||||
add("neg", "don't move forward", NO_MOVE + " | stop") # a stop is never harmful
|
||||
add("neg", "손 흔들지 마", NO_MOVE)
|
||||
|
||||
# ---------- conditions and later times: no motion ----------
|
||||
add("cond", "when I say go, go to the stage", NO_MOVE)
|
||||
add("cond", "after the talk ends, go to start", NO_MOVE)
|
||||
add("cond", "go there tomorrow", NO_MOVE)
|
||||
add("cond", "if someone calls you, come here", NO_MOVE)
|
||||
add("cond", "in an hour, go to booth two", NO_MOVE)
|
||||
add("cond", "later, could you follow me around?", NO_MOVE)
|
||||
add("cond", "before we close tonight go to the charger", NO_MOVE)
|
||||
add("cond", "내가 가라고 하면 스테이지로 가", NO_MOVE)
|
||||
add("cond", "발표 끝나면 엔드로 가 주세요", NO_MOVE)
|
||||
add("cond", "내일 부스 투로 가", NO_MOVE)
|
||||
add("cond", "이따가 따라와", NO_MOVE)
|
||||
add("cond", "손님 오시면 손 흔들어 주세요", NO_MOVE)
|
||||
|
||||
# ---------- come ----------
|
||||
add("come", "come here", "action:come")
|
||||
add("come", "come to me please", "action:come")
|
||||
add("come", "could you come over here?", "action:come")
|
||||
add("come", "hey, come closer", "action:come | ask")
|
||||
add("come", "come hear", "action:come")
|
||||
add("come", "come back here", "action:come")
|
||||
add("come", "이리 와", "action:come")
|
||||
add("come", "이리 와 주세요", "action:come")
|
||||
add("come", "이쪽으로 오십시오", "action:come")
|
||||
add("come", "여기로 와 줄래요?", "action:come")
|
||||
add("come", "이리 돌아와", "action:come")
|
||||
add("come", "come here 해 줘", "action:come")
|
||||
add("come_not", "can I come closer?", "talk")
|
||||
add("come_not", "come on, that's so funny", "talk")
|
||||
add("come_not", "my friend will come here soon", "talk")
|
||||
|
||||
# ---------- come back ----------
|
||||
add("come_back", "come back", "action:come_back | ask")
|
||||
add("come_back", "return", "action:come_back | ask")
|
||||
add("come_back", "go back where you were", "action:come_back | ask")
|
||||
add("come_back", "돌아와", "action:come_back | ask")
|
||||
add("come_back", "원래 자리로 돌아가", "action:come_back | ask")
|
||||
add("come_back", "원래 있던 데로 돌아가 주세요", "action:come_back | ask")
|
||||
add("come_back", "come back to the stage", GO.format(o="stage"))
|
||||
add("come_back", "스테이지로 돌아와", GO.format(o="stage"))
|
||||
add("come_back", "come back 20 cm", "action:move back 0.2")
|
||||
add("come_back", "go back", "action:move back 1")
|
||||
add("come_back_not", "I'll come back later", "talk")
|
||||
add("come_back_not", "come back tomorrow, we'll be here", "talk")
|
||||
add("come_back_not", "she will come back", "talk")
|
||||
add("come_back_not", "이따 다시 올게요", "talk")
|
||||
|
||||
# ---------- follow ----------
|
||||
add("follow", "follow me", "action:follow | refuse")
|
||||
add("follow", "could you maybe follow me?", "action:follow | refuse")
|
||||
add("follow", "come with me", "action:follow | refuse")
|
||||
add("follow", "walk with me", "action:follow | refuse")
|
||||
add("follow", "follow mi", "action:follow | refuse | ask")
|
||||
add("follow", "따라와", "action:follow | refuse")
|
||||
add("follow", "나 따라와", "action:follow | refuse")
|
||||
add("follow", "저 따라오세요", "action:follow | refuse")
|
||||
add("follow", "같이 가자", "action:follow | refuse")
|
||||
add("follow", "저를 따라오십시오", "action:follow | refuse")
|
||||
add("follow", "follow me 해 줘", "action:follow | refuse")
|
||||
add("follow_not", "follow me on Instagram", "talk")
|
||||
add("follow_not", "I follow you", "talk")
|
||||
add("follow_not", "did you follow me?", "talk")
|
||||
add("follow_not", "제 말 따라와요?", "talk")
|
||||
add("follow_not", "can you follow what I'm saying?", "talk")
|
||||
|
||||
# ---------- short moves ----------
|
||||
add("move", "move forward one meter", "action:move forward 1")
|
||||
add("move", "back up two hundred millimetres", "action:move back 0.2")
|
||||
add("move", "move back 5 centimeters", "action:move back 0.05")
|
||||
add("move", "go left half a meter", "action:move left 0.5")
|
||||
add("move", "could you move to the right 1.5 meters?", "action:move right 1.5")
|
||||
add("move", "let's bake 20 cm", "action:move back 0.2")
|
||||
add("move", "big one meter", "action:move back 1 | ask")
|
||||
add("move", "forward one metal", "action:move forward 1 | ask")
|
||||
add("move", "20센티 뒤로", "action:move back 0.2")
|
||||
add("move", "앞으로 반 미터", "action:move forward 0.5")
|
||||
add("move", "이십 센티 뒤로 가", "action:move back 0.2")
|
||||
add("move", "왼쪽으로 1미터 가 주세요", "action:move left 1")
|
||||
add("move", "오른쪽으로 삼십 센치 이동하십시오", "action:move right 0.3")
|
||||
add("move", "앞으로 일 미터 가 줄 수 있어요?", "action:move forward 1")
|
||||
add("move", "move forward 1미터", "action:move forward 1")
|
||||
add("move", "back up a tiny bit", "action:move back 0.05")
|
||||
add("move", "inch forward", "action:move forward 0.05 | ask")
|
||||
add("move", "a hair to the left", "action:move left 0.05")
|
||||
add("move", "two steps back", "action:move back 1")
|
||||
add("move", "go back a little", "action:move back 0.5")
|
||||
add("move", "살짝 뒤로", "action:move back 0.05")
|
||||
add("move", "한 뼘 앞으로", "action:move forward 0.2")
|
||||
add("move", "반 걸음 뒤로 가 주세요", "action:move back 0.25 | ask")
|
||||
add("move_ask", "move back 20", "ask")
|
||||
add("move_ask", "move forward a couple of metres", "ask")
|
||||
add("move_ask", "앞으로 조금만 더 가 볼래요 한 스무", "ask | action:move forward 0.5")
|
||||
add("move_refuse", "move forward 5 meters", "refuse")
|
||||
add("move_refuse", "go back one kilometer", "refuse")
|
||||
add("move_refuse", "앞으로 10미터 가", "refuse")
|
||||
add("move_refuse", "move left half a millimetre", "refuse")
|
||||
|
||||
# ---------- turns ----------
|
||||
add("turn", "turn left", "action:turn left 90")
|
||||
add("turn", "turn right please", "action:turn right 90")
|
||||
add("turn", "turn 45 degrees to the left", "action:turn left 45")
|
||||
add("turn", "can you turn right thirty degrees?", "action:turn right 30")
|
||||
add("turn", "turn around", "action:turn around")
|
||||
add("turn", "뒤로 돌아", "action:turn around")
|
||||
add("turn", "왼쪽으로 돌아", "action:turn left 90")
|
||||
add("turn", "오른쪽으로 돌아 주세요", "action:turn right 90")
|
||||
add("turn", "오른쪽으로 사십오 도 도십시오", "action:turn right 45")
|
||||
add("turn", "turn left 해 줘", "action:turn left 90")
|
||||
add("turn", "한 바퀴 빙 돌아 봐", "action:turn around | ask") # owner set (command_cases): around
|
||||
add("turn_not", "it's your turn to talk", "talk")
|
||||
add("turn_not", "turn left at the corner and you'll find the restroom", "talk")
|
||||
|
||||
# ---------- look (head) ----------
|
||||
add("look", "look left", "action:look left")
|
||||
add("look", "look to your right", "action:look right")
|
||||
add("look", "look up", "action:look up")
|
||||
add("look", "could you look down a bit?", "action:look down")
|
||||
add("look", "look at me", "action:look me")
|
||||
add("look", "eyes on me, please", "action:look me")
|
||||
add("look", "고개 들어", "action:look up")
|
||||
add("look", "고개 숙여 주세요", "action:look down")
|
||||
add("look", "고개 살짝 왼쪽으로", "action:look left")
|
||||
add("look", "정면 봐", "action:look center | action:look me")
|
||||
add("look", "저 봐 주실래요?", "action:look me")
|
||||
add("look", "turn your head 30 degrees right", "action:look right | action:look right 30")
|
||||
add("look", "look right 해 봐", "action:look right")
|
||||
add("look_not", "what's behind you?", "seeing | talk")
|
||||
add("look_not", "뒤에 뭐 있어?", "seeing | talk")
|
||||
add("look_not", "look at this booth, isn't it nice?", "talk")
|
||||
add("look_not", "you look great today", "talk")
|
||||
|
||||
# ---------- lift ----------
|
||||
add("lift", "raise yourself", "action:lift up")
|
||||
add("lift", "lower yourself a bit", "action:lift down")
|
||||
add("lift", "could you get a little taller?", "action:lift up")
|
||||
add("lift", "키 좀 높여", "action:lift up")
|
||||
add("lift", "몸 5센티만 내려", "action:lift down")
|
||||
add("lift", "몸 좀 낮춰 주세요", "action:lift down")
|
||||
add("lift", "lift 올려 줘", "action:lift up")
|
||||
add("lift_not", "can you lift a car?", "talk | refuse")
|
||||
|
||||
# ---------- wave ----------
|
||||
add("wave", "wave", "action:wave | refuse")
|
||||
add("wave", "wave your hand", "action:wave | refuse")
|
||||
add("wave", "can you shake your hand?", "action:wave | refuse")
|
||||
add("wave", "give us a wave!", "action:wave | refuse")
|
||||
add("wave", "손 흔들어 줘", "action:wave | refuse")
|
||||
add("wave", "손 인사 해 주세요", "action:wave | refuse")
|
||||
add("wave", "안녕 하고 손 흔들어", "action:wave | refuse")
|
||||
add("wave", "wave 해 줄래?", "action:wave | refuse")
|
||||
add("wave", "wave your hand", "refuse | action:wave", state="holding") # wave() refuses aloud
|
||||
add("wave", "손 흔들어 주실래요?", "refuse | action:wave", state="holding")
|
||||
add("wave_not", "I saw you wave", "talk")
|
||||
add("wave_not", "the wave was nice", "talk")
|
||||
add("wave_not", "아까 손 흔드는 거 귀여웠어요", "talk")
|
||||
add("wave_q", "can you wave?", "action:wave | refuse | talk")
|
||||
|
||||
# ---------- bye-bye ----------
|
||||
add("bye", "bye bye", "end | action:wave")
|
||||
add("bye", "bay bay", "end | action:wave")
|
||||
add("bye", "바이바이", "end | action:wave")
|
||||
add("bye", "빠이빠이", "end | action:wave")
|
||||
add("bye", "잘 가", "end | action:wave")
|
||||
add("bye", "okay, bye", "end | action:wave")
|
||||
add("bye", "안녕히 계세요", "end | action:wave")
|
||||
add("bye", "bye bye", "end", state="holding")
|
||||
|
||||
# ---------- pick ----------
|
||||
add("pick", "pick up the cup", "action:pick cup")
|
||||
add("pick", "could you grab that mug for me?", "action:pick cup")
|
||||
add("pick", "take the glass", "action:pick cup")
|
||||
add("pick", "pick up the apple", "action:pick apple")
|
||||
add("pick", "I was wondering if you could pick up the orange", "action:pick orange")
|
||||
add("pick", "pick up the white cup", "action:pick cup")
|
||||
add("pick", "컵 잡아", "action:pick cup")
|
||||
add("pick", "사과 집어 주세요", "action:pick apple")
|
||||
add("pick", "오렌지 좀 들어 줄 수 있어요?", "action:pick orange")
|
||||
add("pick", "컵을 집어 주십시오", "action:pick cup")
|
||||
add("pick", "cup pick up 해 줘", "action:pick cup")
|
||||
add("pick", "빨간 컵 pick up", "action:pick cup")
|
||||
add("pick_refuse", "pick up the bottle", "refuse | action:pick bottle | talk")
|
||||
add("pick_refuse", "take the banana", "refuse | action:pick banana | talk")
|
||||
add("pick_refuse", "병 집어", "refuse | action:pick bottle | talk")
|
||||
add("pick_refuse", "바나나 잡아 주세요", "refuse | action:pick banana | talk")
|
||||
add("pick_refuse", "pick up the laptop", "refuse | talk | ask")
|
||||
add("pick_full", "pick up the cup", "refuse | talk | action:pick", state="holding") # the task refuses a full hand
|
||||
add("pick_not", "I'll pick up my cup later", "talk")
|
||||
add("pick_not", "do you like apples?", "talk")
|
||||
add("move_object", "move the cup", "action:move_object cup | action:pick cup | mission")
|
||||
|
||||
# ---------- put / place (holding) ----------
|
||||
add("place", "put it down", "place", state="holding")
|
||||
add("place", "put it back", "place | action:put back", state="holding")
|
||||
add("place", "put it on the table", "place", state="holding")
|
||||
add("place", "could you set it down over there?", "place", state="holding")
|
||||
add("place", "drop it here", "place", state="holding")
|
||||
add("place", "내려놔", "place", state="holding")
|
||||
add("place", "제자리에 놔 주세요", "place | action:put back", state="holding")
|
||||
add("place", "테이블에 놔", "place", state="holding")
|
||||
add("place", "책상 위에 올려놓으십시오", "place", state="holding")
|
||||
add("place", "put it on the lower one", "place | ask", state="holding")
|
||||
add("place", "table 위에 put it", "place", state="holding")
|
||||
add("place_empty", "put it down", "empty_hand")
|
||||
add("place_empty", "테이블에 놔 주세요", "empty_hand")
|
||||
|
||||
# ---------- give (holding) ----------
|
||||
add("give", "give it to me", "give", state="holding")
|
||||
add("give", "bring it to me", "give | action:fetch", state="holding")
|
||||
add("give", "pass it over", "give", state="holding")
|
||||
add("give", "hand it to her", "give", state="holding")
|
||||
add("give", "I'll take it", "give", state="holding")
|
||||
add("give", "줘", "give", state="holding")
|
||||
add("give", "이리 줘", "give", state="holding")
|
||||
add("give", "저 주세요", "give", state="holding")
|
||||
add("give", "저 사람한테 줘", "give", state="holding")
|
||||
add("give", "give it to me 해 줘", "give", state="holding")
|
||||
add("give_empty", "give it to me", "empty_hand")
|
||||
add("give_empty", "이리 줘", "empty_hand")
|
||||
|
||||
# ---------- receive (take from the person's hand) ----------
|
||||
add("receive", "take this from my hand", "receive")
|
||||
add("receive", "hold this", "receive")
|
||||
add("receive", "here you go", "receive | talk")
|
||||
add("receive", "I'll give you this cup", "receive")
|
||||
add("receive", "can you take this apple from me?", "receive")
|
||||
add("receive", "이거 받아", "receive")
|
||||
add("receive", "드릴게요", "receive | talk")
|
||||
add("receive", "내 손에 있는 거 가져가", "receive")
|
||||
add("receive", "이 컵 받아 주실래요?", "receive")
|
||||
add("receive", "this 받아 줘", "receive")
|
||||
|
||||
# ---------- hand open / close ----------
|
||||
add("hand", "open your hand", "action:arm open")
|
||||
add("hand", "close your hand", "action:arm close")
|
||||
add("hand", "손을 펴", "action:arm open")
|
||||
add("hand", "손 좀 펴 주세요", "action:arm open")
|
||||
add("hand", "손 오므려", "action:arm close | ask")
|
||||
add("hand", "could you open your gripper?", "action:arm open")
|
||||
add("hand", "open your hand", "refuse", state="holding")
|
||||
add("hand", "손 펴", "refuse", state="holding")
|
||||
add("hand", "let go", "give | place | refuse", state="holding")
|
||||
|
||||
# ---------- fetch ----------
|
||||
add("fetch", "bring me the apple from the stage", "action:fetch | mission")
|
||||
add("fetch", "could you get me a cup from booth two?", "action:fetch | mission")
|
||||
add("fetch", "go get the orange from table front", "action:fetch | mission")
|
||||
add("fetch", "엔드에서 컵 가져와", "action:fetch | mission")
|
||||
add("fetch", "스테이지에서 사과 가져다주세요", "action:fetch | mission")
|
||||
add("fetch", "부스 투에서 컵 좀 가져와 주실래요?", "action:fetch | mission")
|
||||
add("fetch", "bring the cup from start to table front", "action:fetch | mission")
|
||||
add("fetch", "pass me the cup", "mission | action:fetch")
|
||||
add("fetch", "can I have the apple?", "mission | action:fetch")
|
||||
add("fetch", "컵 좀 줘", "mission | action:fetch")
|
||||
add("fetch_refuse", "bring me a bottle from the stage", "refuse | talk | ask")
|
||||
add("fetch_unknown", "bring me a cup from the kitchen", "refuse | talk | ask | action:fetch") # parse_fetch asks
|
||||
add("fetch_not", "I brought my own cup", "talk")
|
||||
|
||||
# ---------- stop ----------
|
||||
add("stop", "stop", "stop")
|
||||
add("stop", "stop stop stop", "stop")
|
||||
add("stop", "that's enough", "stop | talk")
|
||||
add("stop", "멈춰", "stop")
|
||||
add("stop", "그만", "stop")
|
||||
add("stop", "그만하세요", "stop")
|
||||
add("stop", "정지하십시오", "stop")
|
||||
add("stop", "stop, where are you going?", "stop")
|
||||
add("stop", "wait", "stop | talk")
|
||||
add("stop", "기다려", "stop | talk")
|
||||
add("stop", "거기 서", "stop")
|
||||
add("stop_not", "I can't stop laughing", "talk")
|
||||
add("stop_not", "the bus stop is outside", "talk")
|
||||
add("stop_not", "거기서 기다려", "stop | talk")
|
||||
|
||||
# ---------- speed ----------
|
||||
add("speed", "a bit faster", "speed faster")
|
||||
add("speed", "can you pick up the pace?", "speed faster")
|
||||
add("speed", "way too slow", "speed faster")
|
||||
add("speed", "더 빨리", "speed faster")
|
||||
add("speed", "너무 느려요", "speed faster")
|
||||
add("speed", "slow down", "speed slower")
|
||||
add("speed", "not so fast", "speed slower")
|
||||
add("speed", "ease off a little", "speed slower")
|
||||
add("speed", "천천히", "speed slower")
|
||||
add("speed", "속도 줄여 주세요", "speed slower")
|
||||
add("speed", "좀 천천히 가 줄래요?", "speed slower")
|
||||
add("speed", "speed 좀 올려", "speed faster")
|
||||
add("speed_not", "you are so fast at answering", "talk")
|
||||
|
||||
# ---------- again, with the turn before ----------
|
||||
add("again", "again", "action:turn left 90", before=("turn left", "ACTION: turn left 90"))
|
||||
add("again", "one more time", "action:move forward 1", before=("move forward one meter", "ACTION: move forward 1"))
|
||||
add("again", "a bit more", "action:turn left 15", before=("turn left", "ACTION: turn left 90"))
|
||||
add("again", "조금 더", "action:turn right 15", before=("오른쪽으로 돌아", "ACTION: turn right 90"))
|
||||
add("again", "한 번 더", "action:move back 0.2", before=("20센티 뒤로", "ACTION: move back 0.2"))
|
||||
add("again", "10센티 더", "action:move forward 0.1", before=("앞으로 50센티", "ACTION: move forward 0.5"))
|
||||
add("again", "just a few centimetres more", "action:move forward 0.05 | ask", before=("move forward half a meter", "ACTION: move forward 0.5"))
|
||||
add("again", "same again", "speed faster", before=("a bit faster", "ACTION: speed 1"))
|
||||
add("again", "less", "speed slower", before=("a bit faster", "ACTION: speed 1"))
|
||||
add("again", "more", "speed slower", before=("slow down", "ACTION: speed -1"))
|
||||
add("again_none", "again", "ask | talk")
|
||||
add("again_none", "한 번 더", "ask | talk")
|
||||
add("again_talk", "more", "talk", before=("tell me about JAKA", "ACTION: none -\nJAKA makes robot arms."))
|
||||
|
||||
# ---------- missions in one command ----------
|
||||
add("mission", "take the cup, go to booth two and give it to James", "mission")
|
||||
add("mission", "go to the stage, wait 10 seconds and come back", "mission")
|
||||
add("mission", "컵 들고 스테이지로 가서 줘", "mission")
|
||||
add("mission", "스타트 갔다 와", "mission")
|
||||
add("mission", "pick up the apple then go to the end and put it on the table", "mission | action:fetch")
|
||||
add("mission", "부스 투에 가서 컵 받아서 테이블 프론트로 가 주세요", "mission")
|
||||
add("mission_part", "go to the stage and wave", "refuse | talk | ask")
|
||||
add("mission_part", "go to the stage and dance", "refuse | talk | ask")
|
||||
add("mission_part", "스테이지 가서 춤춰", "refuse | talk | ask")
|
||||
|
||||
# ---------- things the body can't do ----------
|
||||
add("cant", "jump", CANT)
|
||||
add("cant", "can you dance for us?", CANT)
|
||||
add("cant", "fly up to the ceiling", CANT)
|
||||
add("cant", "go up the stairs", CANT)
|
||||
add("cant", "open the door for me", CANT)
|
||||
add("cant", "점프해 봐", CANT)
|
||||
add("cant", "춤 좀 춰 주세요", CANT)
|
||||
add("cant", "계단 올라가 주십시오", CANT)
|
||||
|
||||
# ---------- questions about abilities: no motion ----------
|
||||
add("ability", "what can you do?", "talk")
|
||||
add("ability", "are you able to follow people?", "talk")
|
||||
add("ability", "how far can you drive?", "talk")
|
||||
add("ability", "can you pick up a bottle?", "talk | refuse")
|
||||
add("ability", "how fast can you go?", "talk")
|
||||
add("ability", "뭐 할 수 있어요?", "talk")
|
||||
add("ability", "물건 집을 수 있어?", "talk")
|
||||
add("ability", "사람 따라다닐 수 있나요?", "talk")
|
||||
add("ability", "can you go to the stage?", GO.format(o="stage"))
|
||||
add("ability", "스테이지로 가 줄 수 있어요?", GO.format(o="stage"))
|
||||
|
||||
# ---------- seeing, status, conversation ----------
|
||||
add("seeing", "what do you see?", "seeing")
|
||||
add("seeing", "지금 뭐 보여?", "seeing")
|
||||
add("status", "what are you doing?", "status")
|
||||
add("status", "where are you going?", "status")
|
||||
add("status", "what are you holding?", "status", state="holding")
|
||||
add("status", "뭐 해?", "status")
|
||||
add("status", "어디 가?", "status")
|
||||
add("talk", "I see", "talk")
|
||||
add("talk", "아 그렇구나", "talk")
|
||||
add("talk", "okay", "talk | end")
|
||||
add("talk", "thank you", "talk | end")
|
||||
add("end", "thanks, that's all", "end")
|
||||
add("end", "수고하세요", "end")
|
||||
add("end", "see you", "end | action:wave")
|
||||
add("talk", "good morning, Lumi", "talk")
|
||||
add("talk", "go on", "end | talk")
|
||||
@@ -22,6 +22,7 @@ from assistant import brain, driving, lumi, seeing
|
||||
from audio import sing
|
||||
from tests.command_cases import CASES as CASES1
|
||||
from tests.command_cases2 import CASES as CASES2 # 2026-10-21 night: new wordings, the conference map
|
||||
from tests.command_cases3 import CASES as CASES3 # the same night, written blind from docs/14 and docs/17
|
||||
from tests.conversation_check import NOW, markers
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
@@ -152,7 +153,8 @@ def main(args):
|
||||
global OUT
|
||||
marks = markers()
|
||||
use_llm, cached = "--llm" in args, "--cached" in args
|
||||
cases = CASES2 if "--new" in args else CASES1 if "--old" in args else CASES1 + CASES2
|
||||
cases = CASES2 if "--new" in args else CASES3 if "--blind" in args else CASES1 if "--old" in args else \
|
||||
CASES1 + CASES2 + CASES3
|
||||
only = [a for a in args if not a.startswith("-")]
|
||||
old = {}
|
||||
if cached and OUT.with_suffix(".json").exists():
|
||||
@@ -176,9 +178,11 @@ def main(args):
|
||||
got, raw, first = "llm?", "", ""
|
||||
if got is None:
|
||||
key = (c["text"], c["state"], str(c["before"]))
|
||||
if key in old:
|
||||
if key in old: # the saved action line checked again by today's Brain._action
|
||||
raw, first = old[key]["raw"], old[key]["first"]
|
||||
a, _, tgt = raw.partition(" ")
|
||||
head = brain.Brain._action("ACTION: " + raw, brain.self_correct(c["text"], mk) or c["text"], mk) or \
|
||||
{"action": "none", "target": ""}
|
||||
a, tgt = head["action"], head["target"] if head["action"] != "receive" else raw.partition(" ")[2]
|
||||
got = act(a, tgt, first, c["state"])
|
||||
elif use_llm:
|
||||
try:
|
||||
|
||||
+17
-1
@@ -170,13 +170,14 @@ CASES.update({
|
||||
"take the cup and bring it to Sarah, who is at booth two": "pick cup | go booth_2 | give Sarah",
|
||||
"go to the stage and wait there until I tell you to come back": "go stage | wait",
|
||||
"go ahead to the stage and come back": "go stage | go here",
|
||||
"take the cup, roll on over to the end, and let Sarah have it": "pick cup | go end | give Sarah",
|
||||
"pick up the cup, go forward half a meter, turn right, go forward one meter and put it on the table":
|
||||
"pick cup | move forward 0.5 | turn -90 | move forward 1 | place dining table",
|
||||
})
|
||||
|
||||
# said with a correction inside: brain.self_correct reads it first (lumi.answer)
|
||||
FIXED = {
|
||||
"take the cup, go to start, no, end, and give it to James": "pick cup | go end | give james",
|
||||
"take the cup, go to start, no, end, and give it to James": "pick cup | go end | give James",
|
||||
"go to start, sorry, I mean the stage, then come back": "go stage | go here",
|
||||
"go to the stage, wait 10 seconds, no, 20 seconds, then come back": "go stage | wait 20 | go here",
|
||||
"컵 들고 스타트로 가, 아니 엔드로 가서 줘": "pick cup | go end | give",
|
||||
@@ -195,3 +196,18 @@ READ_BACK = {
|
||||
("Go to table front, wait 30 seconds, then go to my dock.",
|
||||
"table front 위치로 가고 30초 기다리고 충전소로 갈게요."),
|
||||
}
|
||||
|
||||
# for the LLM pass (tests/steps_llm_check.py): wordings the rules leave a part of, with what must come out ("?":
|
||||
# nothing may be kept; every value must be written in the words, steps.read checks that)
|
||||
LLM = {
|
||||
"grab the cup, then zip over to booth two and pass it to whoever is standing there": "pick cup | go booth_2 | give",
|
||||
"snag the apple, scoot over to the stage, and drop it on the table": "pick apple | go stage | place dining table",
|
||||
"take the cup, roll on over to the end, and let Sarah have it": "pick cup | go end | give Sarah",
|
||||
"head to the stage, hang tight for 20 seconds, then make your way back here": "go stage | wait 20 | go here",
|
||||
"컵 챙겨서 스테이지 쪽으로 슝 가서 거기 계신 분께 건네 드려": "pick cup | go stage | give",
|
||||
"스테이지 가서 한 20초 쉬었다가 돌아와": "go stage | wait 20 | go here",
|
||||
"take the cup to the stage and juggle it": "?",
|
||||
"go to the stage and then go to the kitchen": "?",
|
||||
"take the cup, go to booth seven and give it to Sarah": "?",
|
||||
"컵 들고 스테이지 가서 춤추고 와": "?",
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
"""Missions (docs/17), eighth round (2026-10-21 night), written blind from docs/17 only: two to five steps in one
|
||||
breath on the conference map, English, Korean (반말, 해요체, 하십시오체, honorific -시-) and mixed, with then / and /
|
||||
after that / 그리고 / 다음에 / -고 / -서 / -고 나서 / -ㄴ 다음에, waits with times, named people, people at places,
|
||||
"갔다 와", corrections inside. Same notation as tests/test_steps.py; "?" = some words must stay unread or the mission
|
||||
is refused (nothing runs).
|
||||
"""
|
||||
CONF = ["home", "start", "end", "init", "final", "middle", "table_front", "stage", "booth_2", "dock2"]
|
||||
|
||||
CASES = {
|
||||
# ---- English: then / and / after that ----
|
||||
"pick up the cup and take it to the stage": "pick cup | go stage",
|
||||
"grab the cup, then go to booth two, then give it to Sarah": "pick cup | go booth_2 | give Sarah",
|
||||
"go to the middle and then come back": "go middle | go here",
|
||||
"go to table front, pick up the apple, and bring it back to me": "go table_front | pick apple | go here | give",
|
||||
"go to the end, after that go to final, after that come back here": "go end | go final | go here",
|
||||
"first go to init, second go to start, and last go home": "go init | go start | go home",
|
||||
"go to the stage, wait a moment, then come back": "go stage | wait 10 | go here",
|
||||
"go to booth two and wait there for 30 seconds, then go to the end": "go booth_2 | wait 30 | go end",
|
||||
"take the orange to table front and put it on the table": "pick orange | go table_front | place dining table",
|
||||
"take the cup to the end and put it down": "pick cup | go end | place",
|
||||
"go to the start, wait 2 minutes and come back": "go start | wait 120 | go here",
|
||||
"turn right, go forward half a meter and turn left": "turn -90 | move forward 0.5 | turn 90",
|
||||
"move back 1 meter and then turn around": "move back 1 | turn 180",
|
||||
"go to the stage, say welcome to our booth, and come back": "go stage | say welcome to our booth | go here",
|
||||
"go to booth two and say: the demo starts at three": "go booth_2 | say the demo starts at three",
|
||||
"go to the final point and do what they tell you": "go final | wait order",
|
||||
"go to the stage and wait there until someone gives you a cup, then bring it here":
|
||||
"go stage | receive cup wait | go here",
|
||||
"go to table front, ask them for the cup and then bring it to booth two": "go table_front | receive cup | go booth_2",
|
||||
"go to the middle and stay there": "go middle | wait",
|
||||
"go to the end, wait there, then go home": "go end | wait | go home",
|
||||
"pick up the cup, go to init and hold it": "pick cup | go init | hold",
|
||||
"bring the cup to Sarah at the stage": "pick cup | go stage | give Sarah",
|
||||
"Sarah is at booth two, bring her the apple": "pick apple | go booth_2 | give Sarah",
|
||||
"bring the cup to James, who is at the end": "pick cup | go end | give James",
|
||||
"take the cup to Mr. Kim at table front": "pick cup | go table_front | give Mr. Kim",
|
||||
"go to the stage or booth two and come back": "go stage,booth_2 | go here",
|
||||
"take the cup to one of start, middle or end": "pick cup | go start,middle,end",
|
||||
"go to the start and the end": "go start | go end",
|
||||
"after 30 seconds go to the stage": "wait 30 | go stage",
|
||||
"wait 5 seconds, then turn left and go forward one meter": "wait 5 | turn 90 | move forward 1",
|
||||
"go to the stage, wait 1 minute 30 seconds, then go to the middle and come back":
|
||||
"go stage | wait 90 | go middle | go here",
|
||||
"go to booth two, wait half an hour, then come back": "go booth_2 | wait 1800 | go here",
|
||||
"take this from me and bring it to the stage": "receive hand | go stage",
|
||||
"hold this and take it to Sarah at booth two": "receive hand | go booth_2 | give Sarah",
|
||||
"pass me the cup": "pick cup | give",
|
||||
"go to the stage, pick up the cup, go to booth two, give it to Sarah and come back":
|
||||
"go stage | pick cup | go booth_2 | give Sarah | go here",
|
||||
"after you get to the stage, wait 10 seconds and come back": "go stage | wait 10 | go here",
|
||||
"go to stage wait 10 seconds come back": "go stage | wait 10 | go here",
|
||||
"Anvar asks you to take the cup to the stage": "pick cup | go stage",
|
||||
"um, so, I'd like you to go to the middle, uh, and then to final": "go middle | go final",
|
||||
# ---- English: corrections inside ----
|
||||
"go to start, no, end, then come back": "go end | go here",
|
||||
"take the cup, go to the stage, sorry, I mean booth two, and give it to James": "pick cup | go booth_2 | give James",
|
||||
"go to the middle, wait 10 seconds, no, 20 seconds, then come back": "go middle | wait 20 | go here",
|
||||
"go to the stage, not booth two, and come back": "go stage | go here",
|
||||
"turn left, I mean right, then go forward 1 meter": "turn -90 | move forward 1",
|
||||
# ---- English: must stay unread or be refused ----
|
||||
"go to the kitchen and come back": "?",
|
||||
"go to booth three, then go to the stage": "?",
|
||||
"go to the stage and wait a few minutes, then come back": "?",
|
||||
"go to the end, wait a while and come back": "?",
|
||||
"go to the stage and wave": "?",
|
||||
"go to booth two and follow me": "?",
|
||||
"go to the middle and dance": "?",
|
||||
"if nobody is there, come back": "?",
|
||||
"go to the stage and if nobody is there, come back": "?",
|
||||
"pick up the bottle and take it to the end": "?",
|
||||
"take the banana to the stage": "?",
|
||||
"move forward 5 meters and then turn left": "?",
|
||||
"go to the end and wait there for an hour": "?",
|
||||
"pick up the cup and give it to James": "?",
|
||||
"take this from me and put it on the table at the stage": "?",
|
||||
"go to the stage, never mind": "?",
|
||||
"go to the stage and jump": "?",
|
||||
# ---- Korean 반말 ----
|
||||
"컵 들고 스테이지로 가서 줘": "pick cup | go stage | give",
|
||||
"부스 투 갔다 와": "go booth_2 | go here",
|
||||
"엔드 다녀와": "go end | go here",
|
||||
"스타트로 가고 그리고 미들로 가": "go start | go middle",
|
||||
"사과 집고 테이블 프론트로 가서 테이블에 놔": "pick apple | go table_front | place dining table",
|
||||
"스테이지 가서 십 초 기다렸다가 돌아와": "go stage | wait 10 | go here",
|
||||
"파이널로 가서 잠깐 기다리고 다음에 홈으로 가": "go final | wait 10 | go home",
|
||||
"먼저 이닛으로 가고 그다음 엔드로 가": "go init | go end",
|
||||
"왼쪽으로 돌고 앞으로 1미터 가": "turn 90 | move forward 1",
|
||||
"오른쪽으로 돌아서 반 미터 앞으로 가": "turn -90 | move forward 0.5",
|
||||
"부스 투에 가서 기다려": "go booth_2 | wait",
|
||||
"스테이지에서 기다려": "go stage | wait",
|
||||
"5분 뒤에 엔드로 가": "wait 300 | go end",
|
||||
"미들 가서 1분 30초 기다렸다가 돌아와": "go middle | wait 90 | go here",
|
||||
"부스 투에 있는 사라한테 컵 갖다줘": "pick cup | go booth_2 | give 사라",
|
||||
"사라는 부스 투에 있어, 컵 갖다줘": "pick cup | go booth_2 | give 사라",
|
||||
"컵 가지고 엔드로 가서 민준이한테 줘": "pick cup | go end | give 민준",
|
||||
"스타트로 가, 아니 엔드로 가서 줘": "go end | give",
|
||||
"스테이지 가서 시키는 거 해": "go stage | wait order",
|
||||
"컵 들고 미들로 가서 들고 있어": "pick cup | go middle | hold",
|
||||
"스테이지 가서 몇 분 기다려": "?",
|
||||
"부스 투 가서 한참 있다가 와": "?",
|
||||
"주방 갔다 와": "?",
|
||||
"스테이지 가서 손 흔들어": "?",
|
||||
"엔드 가서 춤춰": "?",
|
||||
"병 들고 스테이지로 가": "?",
|
||||
# ---- Korean 해요체 ----
|
||||
"컵 들고 부스 투로 가서 제임스한테 줘요": "pick cup | go booth_2 | give 제임스",
|
||||
"스테이지로 가서 안녕하세요라고 말해 주세요": "go stage | say 안녕하세요",
|
||||
"테이블 프론트에 가서 컵 받아서 스테이지로 가 주세요": "go table_front | receive cup | go stage",
|
||||
"엔드 가서 누가 컵 주면 받아서 여기로 와 주세요": "go end | receive cup wait | go here",
|
||||
"미들로 가고 나서 파이널로 가 주세요": "go middle | go final",
|
||||
"스타트로 간 다음에 엔드로 가 주세요": "go start | go end",
|
||||
"스테이지 가서 30초 기다린 다음에 돌아와요": "go stage | wait 30 | go here",
|
||||
"사과 집어서 엔드로 가서 내려놔 주세요": "pick apple | go end | place",
|
||||
"부스 투로 가서 잠시 기다렸다가 홈으로 가요": "go booth_2 | wait 10 | go home",
|
||||
"이거 받아서 스테이지에 있는 사라 씨한테 갖다 주세요": "receive hand | go stage | give 사라",
|
||||
"스테이지로 가요, 아니 부스 투로 가서 기다려 주세요": "go booth_2 | wait",
|
||||
"부스 투로 가서 이따가 돌아와요": "?",
|
||||
"아무도 없으면 돌아와 주세요": "?",
|
||||
"스테이지 가서 저 따라와 주세요": "?",
|
||||
# ---- Korean 하십시오체 / honorific -시- ----
|
||||
"컵을 드시고 스테이지로 가셔서 김 부장님께 드리십시오": "pick cup | go stage | give 김 부장님",
|
||||
"부스 투로 가셔서 10초 기다리신 후에 돌아오십시오": "go booth_2 | wait 10 | go here",
|
||||
"엔드에 가셔서 컵을 받으시고 여기로 오십시오": "go end | receive cup | go here",
|
||||
"테이블 프론트로 가셔서 시키는 일을 하십시오": "go table_front | wait order",
|
||||
"스타트로 가신 다음에 미들로 가십시오": "go start | go middle",
|
||||
"오른쪽으로 도신 후에 앞으로 일 미터 가십시오": "turn -90 | move forward 1",
|
||||
"스테이지로 가셔서 30분 기다리십시오": "go stage | wait 1800",
|
||||
"스테이지로 가셔서 한 시간 기다리십시오": "?",
|
||||
# ---- mixed / code-switched ----
|
||||
"take the cup 하고 stage로 가서 줘": "pick cup | go stage | give",
|
||||
"booth two로 가서 wait 10 seconds 하고 돌아와": "go booth_2 | wait 10 | go here",
|
||||
"컵 pick up 하고 table front로 가 줘": "pick cup | go table_front",
|
||||
"go to 스테이지 and come back": "go stage | go here",
|
||||
"엔드로 가서 give it to Sarah": "go end | give Sarah",
|
||||
"pick up the apple 그리고 미들로 가": "pick apple | go middle",
|
||||
"go to booth two 하고 dance 해": "?",
|
||||
"go to 주방 and come back": "?",
|
||||
# ---- whisper slips and fillers ----
|
||||
"go to the stagee and come back": "go stage | go here",
|
||||
"uh go to booth two then um come back here": "go booth_2 | go here",
|
||||
"Lumi please go to the middle then the end then come back": "go middle | go end | go here",
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
"""The mission reader's LLM pass (steps.read, brain.MODEL through Ollama) on wordings the rules leave a part of
|
||||
(tests/steps_cases7.py LLM): what it kept must be exactly the steps written there, and nothing for "?".
|
||||
Uses the shared LLM: run it alone. python tests/steps_llm_check.py"""
|
||||
import time
|
||||
|
||||
from assistant import steps
|
||||
from tests import steps_cases7 as c7
|
||||
|
||||
real = steps._ollama
|
||||
from tests.test_steps import short # noqa: E402 - runs the offline checks, which fake the LLM
|
||||
steps._ollama = real
|
||||
|
||||
right, t0 = 0, time.time()
|
||||
for text, want in c7.LLM.items():
|
||||
got, unread, by = steps.read(text, c7.CONF)
|
||||
ok = (bool(unread) or bool(steps.check(got, False, c7.CONF))) if want == "?" else \
|
||||
not unread and got == [short(x.strip()) for x in want.split(" | ")]
|
||||
right += ok
|
||||
print(f"{'ok ' if ok else 'FAIL'} [{by}] {text!r}\n want {want}\n got {got} unread {unread}", flush=True)
|
||||
print(f"{right}/{len(c7.LLM)} right ({time.time() - t0:.0f} s)")
|
||||
@@ -0,0 +1,46 @@
|
||||
"""ears.transcribe() choices without whisper: a fake _infer answers per language.
|
||||
|
||||
.venv/bin/python tests/test_ears.py
|
||||
"""
|
||||
import numpy as np
|
||||
|
||||
from audio import ears
|
||||
|
||||
ears.ensure_stt_server = lambda: None
|
||||
ears.HEARD_DIR = ears.ROOT / "logs" / "asr_check" / "heard_test"
|
||||
AUDIO = np.zeros(16000, np.int16)
|
||||
|
||||
|
||||
def fake(answers):
|
||||
"""answers: {None | 'en' | 'ko': (text, lang, prob, logprob)}; records the languages asked."""
|
||||
asked = []
|
||||
|
||||
def infer(wav, prompt, language=None):
|
||||
asked.append(language)
|
||||
return answers[language]
|
||||
ears._infer = infer
|
||||
return asked
|
||||
|
||||
|
||||
# Korean written in Latin letters ("Natarawa." is no English word): asked in Korean too, the Hangul one kept
|
||||
asked = fake({None: ("Natarawa.", "english", 0.55, -0.4),
|
||||
"ko": ("나 따라와.", "korean", None, -0.5)})
|
||||
assert ears.transcribe(AUDIO) == "나 따라와." and ears.heard_lang() == "ko" and asked == [None, "ko"], asked
|
||||
# sure English in dictionary words: one call only
|
||||
asked = fake({None: ("Go to p3.", "english", 0.97, -0.1)})
|
||||
assert ears.transcribe(AUDIO) == "Go to p3." and asked == [None], asked
|
||||
# Hangul in a text tagged English: Korean
|
||||
asked = fake({None: ("Red cup. 집어줘.", "english", 0.6, -0.15)})
|
||||
assert ears.transcribe(AUDIO) == "Red cup. 집어줘." and ears.heard_lang() == "ko" and asked == [None], asked
|
||||
# whisper's spelling of the company
|
||||
asked = fake({None: ("What does Kutchen make?", "english", 0.9, -0.2)})
|
||||
assert ears.transcribe(AUDIO) == "What does Cutshion make?", ears.last_stt
|
||||
# another language (Japanese) named: both asked
|
||||
asked = fake({None: ("Lumi.", "japanese", 0.5, -0.01), # Korean translated when forced to English
|
||||
"ko": ("컵 좀 주세요.", "korean", None, -0.3), "en": ("Give me a cup.", "english", None, -0.1)})
|
||||
assert ears.transcribe(AUDIO) == "컵 좀 주세요." and asked == [None, "ko", "en"], asked
|
||||
# only the name from 2 s of audio: asked in both, the one with more than the name kept although less sure
|
||||
asked = fake({None: ("Lumi.", "english", 0.9, -0.05),
|
||||
"ko": ("Lumi야, 이리 와.", "korean", None, -0.4), "en": ("Lumi.", "english", None, -0.05)})
|
||||
assert ears.transcribe(np.zeros(32000, np.int16)) == "루미야, 이리 와." and asked == [None, "ko", "en"], asked
|
||||
print("ears ok")
|
||||
@@ -46,6 +46,8 @@ FIX = {"go to start, no, end": "go to end", "스타트로 가, 아니 엔드로"
|
||||
"앞으로 1미터, 아니 2미터 가": "앞으로 2 m 가", "컵 집어, 아니 병": "병 집어", "go to the stage, never mind": "",
|
||||
"스테이지로 가, 아니 됐어": "", "go to the stage, no, the kitchen": None, "I like apples, no, I love them": None,
|
||||
"go to the stage, no rush": None, "no, go to the end": None}
|
||||
for text in ("stop, no, wait", "go to start, no wait, stop", "멈춰, 아니 기다려"): # a stop is never rewritten
|
||||
assert brain.self_correct(text, M) == text and lumi.stop_order(text, M), text
|
||||
for text, want in FIX.items():
|
||||
got = brain.self_correct(text, M)
|
||||
assert got == (text if want is None and text in ("I like apples, no, I love them", "go to the stage, no rush",
|
||||
|
||||
+8
-4
@@ -1,7 +1,7 @@
|
||||
"""Self-check of reading missions (docs/17), no robot, no LLM: python tests/test_steps.py
|
||||
|
||||
Each case: command -> the steps it must give, written short:
|
||||
go p1 | go p3,p5,p7 (one of them) | go here | move left 1 | turn -90 | pick white cup | receive cup |
|
||||
go p1 | go p3,p5,p7 (one of them) | go here | move left 1 | turn -90 | pick white cup | receive cup | receive hand |
|
||||
say <text> | place | place white dining table left | give | hold | arm reach |
|
||||
wait (no time: stay / until go on) | wait 30 | wait order [600] (an instruction there) | receive cup wait [120]
|
||||
"?" as the steps: some words must stay unread (Lumi asks again, nothing runs)."""
|
||||
@@ -23,6 +23,8 @@ def short(s):
|
||||
return {"do": "turn", "deg": float(w[1])}
|
||||
if do == "pick":
|
||||
return {"do": "pick", "object": w[-1], "colour": w[1] if len(w) == 3 else None}
|
||||
if do == "receive" and w[1:] == ["hand"]:
|
||||
return {"do": "receive", "object": None, "from_hand": True} # "take this from me": from the person's hand
|
||||
if do == "receive":
|
||||
out = {"do": "receive", "object": w[1] if len(w) > 1 and w[1] != "wait" else None}
|
||||
if "wait" in w:
|
||||
@@ -298,7 +300,9 @@ print("steps wait ok")
|
||||
from assistant import brain
|
||||
from tests import steps_cases7 as c7
|
||||
failed = []
|
||||
for text, want in list(c7.CASES.items()) + [(brain.self_correct(t, c7.CONF), w) for t, w in c7.FIXED.items()]:
|
||||
from tests import steps_cases8 as c8 # written blind from docs/17 (2026-10-21 night), with corrections
|
||||
for text, want in list(c7.CASES.items()) + [(brain.self_correct(t, c7.CONF), w) for t, w in
|
||||
list(c7.FIXED.items()) + list(c8.CASES.items())]:
|
||||
got, unread = steps.rules(text, c7.CONF)
|
||||
if want == "?":
|
||||
ok = bool(unread) or bool(steps.check(got, False, c7.CONF))
|
||||
@@ -313,7 +317,7 @@ for want, (en, ko) in c7.READ_BACK.items():
|
||||
if steps.describe(s_, lang) != said:
|
||||
failed.append(want)
|
||||
print(f"FAIL read-back {lang} {want!r}\n want {said}\n got {steps.describe(s_, lang)}")
|
||||
print(f"{len(c7.CASES) + len(c7.FIXED) - sum(1 for f in failed if f in c7.CASES or f in c7.FIXED.values())}/"
|
||||
f"{len(c7.CASES) + len(c7.FIXED)} read right on the conference map")
|
||||
print(f"{len(c7.CASES) + len(c7.FIXED) + len(c8.CASES) - len(failed)}/{len(c7.CASES) + len(c7.FIXED) + len(c8.CASES)} "
|
||||
"read right on the conference map")
|
||||
assert not failed
|
||||
print("steps conference ok")
|
||||
|
||||
Reference in New Issue
Block a user