Stop words stop every motion without the wake word and before every echo filter; give me a hand / shake hands / 악수 reach out, busy cleared by stop; look phrasings, more / again / 더 step further, act before speaking; own-voice echoes no longer asked again
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+53
-8
@@ -357,7 +357,7 @@ Short Korean commands are commands: "컵 가져다 줘" -> fetch cup, "컵 옮
|
||||
the opposite move.
|
||||
- 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; "give me your hand" / "손 줘" is arm reach.
|
||||
"p1로 가, 아니 p2로" the last one counts. A handshake ("shake hands with me", "악수하자") is arm reach, as are "give me your hand" / "give me a hand" / "손 줘".
|
||||
- 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.
|
||||
@@ -458,19 +458,22 @@ BEHIND_WORDS = (r"\blook(?:ing)? (?:over |to(?:wards?)? |at |in )?(?:the |your )
|
||||
r"|(?:고개|머리)(?:를|좀|살짝|조금|\s)*뒤(?:쪽)?(?:으로|로)?\s*(?:좀\s*)?(?:돌려|봐)") # 뒤에 봐 줘; not 뒤로 돌아
|
||||
# ^ the head turns to look behind (head_target); "what's behind you?" is a question for seeing.BEHIND
|
||||
HEAD_WORDS = (r"\blook (?:straight )?(?:up|down|left|right|ahead|forward|straight|at me|behind|this way|over here|to (?:the|your|my) (?:left|right))\b"
|
||||
r"|\blook (?:a (?:little |bit )?)?(?:more |further )?(?:at|to|towards?|on|over|in) (?:the |your |my )?(?:left|right|front)(?: side)?\b"
|
||||
r"|\blook (?:a (?:little |bit )?)?(?:more|further) (?:to (?:the |your )?)?(?:left|right|up|down)\b" # "look at the left side"
|
||||
r"|" + BEHIND_WORDS +
|
||||
r"|\blook at (?:my|this|that|our) (?:son|daughter|kid|child|baby|friend|wife|husband|boy|girl|mom|dad)\b"
|
||||
r"|(?:우리|내|제) (?:애|아이|아들|딸|친구)\s*(?:좀\s*)?(?:봐|쳐다)"
|
||||
r"|\b(?:turn|move|rotate|tilt|swing) your head\b|\b(?:raise|lift|lower|drop) your head\b|\bface me\b|\bhead (?:up|down)\b"
|
||||
r"|(?:고개|머리)(?:를|좀|살짝|조금|약간|\s)*(?:왼쪽|오른쪽|위|아래|정면|앞|들어|숙여|올려|내려|돌려)"
|
||||
r"|(?:고개|머리)(?:를|좀|\s)*(?:원위치|원래대로|제자리)|\bhead back to (?:the )?(?:centre|center|middle)\b" # the head, not put back
|
||||
r"|(?:위|아래|밑|왼쪽|오른쪽|정면|앞|나|날|저|절|나를|저를)(?:를|을|으로|로|쪽|쪽을|에)?\s*(?:\d+\s*도\s*(?:만|쯤|정도)?\s*)?(?:좀\s*)?(?:봐|보세요|봐요|봐 ?줘|봐 ?주세요|볼래|봐 ?봐)")
|
||||
r"|(?:위|아래|밑|왼쪽|오른쪽|정면|앞|나|날|저|절|나를|저를)(?:를|을|으로|로|쪽|쪽을|에)?\s*(?:\d+\s*도\s*(?:만|쯤|정도)?\s*)?(?:(?:좀|조금|더|약간|살짝)\s*)*(?:봐|보세요|봐요|봐 ?줘|봐 ?주세요|볼래|봐 ?봐)")
|
||||
LIFT_WORDS = (r"\b(?:raise|lift|lower) (?:yourself|your body|your torso|your upper body)\b|\blift (?:yourself )?(?:up|down)\b(?! (?:the|a|an|that|this|it)\b)"
|
||||
r"|\bget (?:a (?:little |tiny )?bit |a little |slightly )?(?:taller|shorter|smaller|higher|lower)\b|\bmake yourself (?:taller|shorter|smaller)\b|\bstand (?:up )?tall(?:er)?\b"
|
||||
r"|\b(?:go|move) (?:higher|lower)\b|키(?:를)? ?(?:좀 )?(?:[\d.]+ ?(?:m|mm|cm) ?(?:만 ?)?)?(?:높여|키워|올려|낮춰|줄여|크게|작게)"
|
||||
r"|몸(?:을)? ?(?:좀 )?(?:[\d.]+ ?(?:m|mm|cm) ?(?:만 ?)?)?(?:올려|내려|낮춰|높여)"
|
||||
r"|리프트(?:를)? ?(?:좀 )?(?:올려|내려|위로|아래로)|상체(?:를)? ?(?:좀 )?(?:올려|내려|들어)")
|
||||
SMALL = re.compile(r"\ba (?:little )?bit\b|\bslightly\b|\ba little\b|\ba touch\b|조금|살짝|약간|좀 더")
|
||||
MORE = re.compile(r"\b(?:more|further)\b|(?:^|\s)더(?:\s|$)") # "look left more", "왼쪽 더 봐": a step on from where it is
|
||||
HEAD_YAW, HEAD_PITCH = head_hw.AXIS_LIMITS[2], head_hw.AXIS_LIMITS[3] # commanded looks: the body's full range
|
||||
HEAD_SMALL_DEG = 15.0 # deg; "look left a bit": the head turns this much from where it is
|
||||
HEAD_AWAY_DEG = 60.0 # deg; "look away", "don't look at me": the head turns this much aside from where it is
|
||||
@@ -481,7 +484,7 @@ def head_target(t):
|
||||
"""Normalised words -> "left" | "left 30" | "up small" | "me" | "center"; None for "look up the news"."""
|
||||
if re.search(r"\blook up\b\s+(?!(?:a |please|lumi|slightly|again|at|to|\d|now|and|then|too|more)\b)[a-z]", t):
|
||||
return None
|
||||
if re.search(r"\b(?:straight|ahead|forward|center|centre)\b|정면|가운데|원위치|원래대로|제자리|(?:^|\s)앞(?:을|으로|쪽)?\s*(?:좀\s*)?(?:봐|보)", t):
|
||||
if re.search(r"\b(?:straight|ahead|forward|center|centre|front)\b|정면|가운데|원위치|원래대로|제자리|(?:^|\s)앞(?:을|으로|쪽)?\s*(?:좀\s*)?(?:봐|보)", t):
|
||||
return "center"
|
||||
if re.search(BEHIND_WORDS, t): # the head as far round as it goes, by the side said
|
||||
side = "right" if re.search(r"\bright\b|오른쪽", t) else "left" # "over your right shoulder"; left when none
|
||||
@@ -490,7 +493,7 @@ def head_target(t):
|
||||
("up", r"\bup\b|\braise\b|\blift\b|위|들어|올려"), ("down", r"\bdown\b|\blower\b|\bdrop\b|아래|밑|숙여|내려")):
|
||||
if re.search(words, t):
|
||||
deg = re.search(r"(\d+)\s*(?:degrees?|도)?", t) # a bare number on the head is degrees
|
||||
return f"{d} {deg.group(1)}" if deg else (f"{d} small" if SMALL.search(t) else d)
|
||||
return f"{d} {deg.group(1)}" if deg else (f"{d} small" if SMALL.search(t) or MORE.search(t) else d)
|
||||
if re.search(r"\b(?:at me|face me)\b|(?:^|\s)(?:나|날|저|절|나를|저를)\s*(?:좀\s*)?봐|\blook at (?:my|this|that|our) \w+|"
|
||||
r"(?:우리|내|제) (?:애|아이|아들|딸|친구)", t): # "look at my son": towards whoever speaks
|
||||
return "me" # after the directions: "look down at me" is down
|
||||
@@ -524,6 +527,10 @@ def head_goal(target, yaw, pitch, look=None, yaw_max=HEAD_YAW[1], pitch_range=HE
|
||||
else:
|
||||
y, p = look[d]
|
||||
new = (yaw if y is None else y, pitch if p is None else p)
|
||||
if d in ("left", "right") and sign * yaw >= sign * y - 1: # "look left" again while it looks left:
|
||||
new = (yaw + sign * HEAD_SMALL_DEG, pitch) # a step further, never nothing
|
||||
elif d in ("up", "down") and sign * pitch >= sign * p - 1:
|
||||
new = (yaw, pitch + sign * HEAD_SMALL_DEG * 2 / 3)
|
||||
y, p = max(-yaw_max, min(yaw_max, new[0])), max(pitch_range[0], min(pitch_range[1], new[1]))
|
||||
limited = "yaw" if n not in ("", "small") and y != new[0] else "pitch" if n not in ("", "small") and p != new[1] else None
|
||||
return y, p, limited
|
||||
@@ -618,8 +625,9 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
||||
r"|손을? ?(쥐|오므려|닫아)|주먹 ?(을 )?쥐|잡아(?!먹|당)|손 ?close|(그리퍼|집게)(를|을)? ?(좀 )?(닫아|오므려)"),
|
||||
("arm", r"\b(reach out(?! to (?!me\b))|stretch (out )?your (arm|hand)|put your (arm|hand) (out|forward)|hand forward|"
|
||||
r"hold out your (arm|hand|gripper|claw|fingers)|extend your (arm|hand|gripper)|give me your hand|offer me your hand|"
|
||||
r"give me (?:a|ur|you) hand(?!\s+(?:with|to|for|in|on|carrying|moving|lifting)\b)|shake (?:my hand|hands)|(?:give me|do|have) a handshake|"
|
||||
r"(put|hold|stick) your (arm|hand) out|reach (out )?(to|toward|towards|for) me)\b|팔을? ?(뻗|내밀)"
|
||||
r"|손을? ?(좀 )?(내밀|뻗)(?!었)|^\W*(?:(?:나|저)(?:한테|에게)?\s*)?손 ?(?:을 )?(?:좀 )?(?:줘|주세요|줄래요?|줘 ?봐)\W*$"
|
||||
r"|손을? ?(좀 )?(내밀|뻗)(?!었)|^\W*(?:(?:루미야?|lumi)\W*)?(?:(?:나|저)(?:한테|에게)?\s*)?(?:손|hand) ?(?:을 )?(?:좀 )?(?:줘|주세요|줄래요?|줘 ?봐)\W*$|악수\s*(?:좀\s*)?(?:하자|해|할래|합시다|하실래|하시죠)"
|
||||
r"|\bfold (?:up )?your arm\b|\b(?:put|take) your arm (?:down|away|back)\b|\btuck your arm\b|팔을? ?(?:좀 )?(?:접|내려|거둬)"
|
||||
r"|\b(?:arm|hand) forward\b|^\W*(?:(?:hey|lumi|robot|okay|ok|please)\W+)*hand out(?=\W*(?:$|,|robot|lumi|please|now))|\breach (?:out )?for my hand\b|\br[ie]{2}ch out\b|"
|
||||
r"\barm (?:go )?(?:to|toward|towards) me\b|\b(?:arm|hand|reach)\s*(?:을|를)?\s*(?:좀\s*)?(?:뻗|내밀|해 ?볼래|해 ?줘|해\W*$)|"
|
||||
@@ -1029,7 +1037,7 @@ def intent(text, markers=()):
|
||||
if re.search(r"\bhow do you (know|check|get|find)\b|어떻게 (알|확인)", t):
|
||||
return None # "how do you know the weather?": about Lumi
|
||||
place = re.search(r"\bin ([A-Za-z][A-Za-z ]+?)(\?|$|\.| today| tomorrow| right now| now| this)", text)
|
||||
if place:
|
||||
if place and web.asked_day("in " + place.group(1)) is None: # "in three days" is a day, no place
|
||||
return ("weather", place.group(1).strip())
|
||||
ko = next((k for k in sorted(web.KO_PLACES, key=len, reverse=True) if k in text), None) # "부산 날씨 어때?"
|
||||
return ("weather", web.en_place(ko) if ko else "")
|
||||
@@ -2127,6 +2135,28 @@ REACTION = re.compile(r"^\W*(?:(?:wow|oh|really|huh|whoa)\W+)*(?:i (?:didn'?t|di
|
||||
re.I) # a reaction to what was found, not a new question
|
||||
NOW_Q = re.compile(r"\bwhat time is it\b|\bwhat'?s the time\b|\bwhat(?:'s| is) (?:the date|today)\b|지금 몇 ?시|오늘 며칠",
|
||||
re.I) # asked of the clock, not of the lookup before
|
||||
WEATHER_WORDS = re.compile(r"\b(?:and|so|then|ok(?:ay)?|what|how|about|is|it|the|weather|like|for|on|in|at|will|be|going|"
|
||||
r"to|forecast|rain|there|that|then|please|sorry|no|i|mean|meant)\b|그럼|그러면|그리고|날씨|어때요|어때|어떤가요|어떨까요|어떻게|돼요|"
|
||||
r"비|와요|올까요|오나요|알려|줘|주세요", re.I) # the rest of "and the weather on Friday then?"
|
||||
PARTICLES = re.compile(r"^[은는도요의에이가서엔]+$") # "월요일은요" less the day
|
||||
CHECKING = re.compile(r"^\W*(?:let me (?:check|see|look)|one moment|just a moment|확인해 ?볼게요|잠시만요?)\W*$", re.I)
|
||||
# lumi says it before the lookup: never again inside the answer
|
||||
|
||||
|
||||
def weather_follow(text):
|
||||
"""A short weather follow-up that names a day and maybe a place ("내일은요?", "and Friday?", "what about Busan
|
||||
tomorrow?", "다음 주 월요일 어때요?"): the place ("" = the one asked before), else None."""
|
||||
if len(text.split()) > 8 or web.asked_day(text) is None:
|
||||
return None
|
||||
rest = web.DAY_PHRASE.sub(" ", text)
|
||||
ko = next((k for k in sorted(web.KO_PLACES, key=len, reverse=True) if k in rest), None)
|
||||
rest = WEATHER_WORDS.sub(" ", rest.replace(ko, " ") if ko else rest)
|
||||
words = [w for w in re.findall(r"[\w'-]+", rest) if not PARTICLES.match(w)]
|
||||
if ko:
|
||||
return web.en_place(ko) if not words else None
|
||||
return " ".join(words) if all(w[0].isupper() and w.isascii() for w in words) else None
|
||||
|
||||
|
||||
LOOKUP_ACTION = re.compile(r"^\s*(?:\**ACTION\**\s*:\s*)?(?:search|weather)(?: (?!results)|\s*$)") # an action line
|
||||
# written instead of the answer (the routing prompt is its system prompt): never said
|
||||
NONE_LINE = re.compile(r"\s*(?:\**ACTION\**\s*:\s*)?none\b", re.I) # "ACTION: none -" (or "none" alone)
|
||||
@@ -2167,6 +2197,7 @@ class Brain:
|
||||
self.last_facts = "" # ... and what was found for it (a follow-up is answered from it too)
|
||||
self.lookup_topic = "" # what the last lookup that was not a follow-up searched for
|
||||
self.weather_at = "" # the place of the last weather question in this talk ("" = here)
|
||||
self.weather_days = None # ... and the days it asked (web.asked_day; None = no day named)
|
||||
|
||||
def weather_place(self, target, text=""):
|
||||
"""Where a weather lookup is for: a place not named ("내일 비 와?" after Jeju's weather) is the place of the
|
||||
@@ -2175,6 +2206,15 @@ class Brain:
|
||||
self.weather_at = target
|
||||
return self.weather_at
|
||||
|
||||
def weather_on(self, text):
|
||||
"""The days a weather lookup is for (web.asked_day). Named none, it keeps the day of the turn before: of the
|
||||
weather asked ("what about Busan?" after Monday's) or of a day talked about ("next Monday is the 26th." ->
|
||||
"and the weather?"); "the day after" goes on from it. None (the whole forecast) when nothing before names one."""
|
||||
last_q = self.history[-1][0] if self.history else ""
|
||||
before = self.weather_days if last_q.endswith(WEATHER_ASKED) else web.asked_day(last_q)
|
||||
self.weather_days = web.asked_day(text, before) or before
|
||||
return self.weather_days
|
||||
|
||||
def lookup_about(self, target, about, text=""):
|
||||
"""What lumi.not_online reads for a lookup: right after a lookup (or _after's follow-up of it, "What time does
|
||||
Lotte World open? How much is a ticket?") the question looked up, so the ticket is Lotte World's, not this
|
||||
@@ -2399,6 +2439,10 @@ class Brain:
|
||||
d = look.group(1) or look.group(2)
|
||||
return {"action": "look", "target": {"위": "up", "아래": "down", "왼쪽": "left", "오른쪽": "right"}.get(d, d.lower()),
|
||||
"say": "네." if language(text) == "Korean" else "Okay."}
|
||||
if last_q.endswith(WEATHER_ASKED) and action in ("none", "unclear", "search", "weather"):
|
||||
place = weather_follow(text) # "내일 어때요?", "and Friday?", "what about Busan tomorrow?":
|
||||
if place is not None: # the weather again, the day moved (lumi.look_up)
|
||||
return {"action": "weather", "target": place}
|
||||
looked_up = before == "search" or (self.last_lookup is not None and last_q == self.last_lookup)
|
||||
if not looked_up or action not in ("none", "unclear") or is_backchannel(text) or REACTION.match(text):
|
||||
return header # "oh really?", "wow, that many?" ask nothing new
|
||||
@@ -2498,11 +2542,11 @@ class Brain:
|
||||
continue
|
||||
parts = SENTENCE_END.split(buf)
|
||||
for sentence in parts[:-1]:
|
||||
if spoken(sentence.strip(), lang): # no "ACTION: none" copied from the history
|
||||
if spoken(sentence.strip(), lang) and not CHECKING.match(sentence): # no "ACTION: none" copied
|
||||
said = True
|
||||
yield spoken(sentence.strip(), lang)
|
||||
buf = parts[-1]
|
||||
if spoken(buf.strip(), lang) and not (not said and LOOKUP_ACTION.match(buf)):
|
||||
if spoken(buf.strip(), lang) and not (not said and LOOKUP_ACTION.match(buf)) and not CHECKING.match(buf):
|
||||
said = True
|
||||
yield spoken(buf.strip(), lang)
|
||||
if said:
|
||||
@@ -2709,6 +2753,7 @@ class Brain:
|
||||
self.history = []
|
||||
self.last_lookup = None
|
||||
self.weather_at = ""
|
||||
self.weather_days = None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -83,6 +83,10 @@ AGAIN = re.compile(r"^(?:(?:just|a|an|bit|little|tiny|some|even|one|1|once|the|s
|
||||
r"the same again|more please|again please|1 more time)(?:\s+(?:please|lumi|then))?$|"
|
||||
r"^(?:루미야\s+)?(?:조금만?|좀|살짝|약간|한 ?번|1 ?번|아까처럼|똑같이)?\s*더"
|
||||
r"(?:\s*(?:가|해|가 ?줘|해 ?줘|가요|해요|가 ?주세요|해 ?주세요))?$|^한 ?번 ?더|^똑같이(?: 해| 한 ?번)?")
|
||||
LOOK_MORE = re.compile(r"^(?:(?:look|at|to|the|your|side|a|bit|little|tiny|more|again|further|please|lumi|and|then|now|"
|
||||
r"once|one|time|okay|ok|left|right|up|down|루미야|좀|조금|조금만|더|약간|살짝|한|번|한번|다시|봐|봐요|봐줘|"
|
||||
r"줘|주세요|요|(?:왼쪽|오른쪽|위|아래)(?:으로|로|쪽|쪽으로|을|를)?)(?:\s+|$))+$")
|
||||
# right after a look, only these words with a "more" / "again" in them: the head a step further that way
|
||||
LESS = re.compile(r"^(?:(?:a|bit|little|just|a little|a bit)\s+)*less(?: please)?$|^(?:좀|조금)?\s*덜$")
|
||||
JOINED = re.compile(r"\b(?:and|then|after that|and then)\b|그리고|하고|해서|가서|다음에|집어|가져")
|
||||
|
||||
@@ -164,6 +168,10 @@ def read(t, last=None, talking=False):
|
||||
s = 0 if asked else speed(t) # "really? that slow?": a reaction, not an order
|
||||
if s:
|
||||
return ("speed", s)
|
||||
if last and last[0] == "look" and LOOK_MORE.match(t) and re.search(r"\b(?:more|again|further)\b|더|다시|한 ?번", t):
|
||||
side = re.search(r"\b(left|right|up|down)\b|(왼쪽|오른쪽|위|아래)", t) # "more again", "look at more", "왼쪽으로 더"
|
||||
d = {"왼쪽": "left", "오른쪽": "right", "위": "up", "아래": "down"}.get(side.group(2), side.group(1)) if side else None
|
||||
return ("look", f"{d or last[1].split()[0]} small")
|
||||
if AGAIN.search(t) or LESS.search(t):
|
||||
if last is None:
|
||||
return None if talking else ("ask", "") # "more" of what?
|
||||
|
||||
@@ -354,7 +354,7 @@ NO = [
|
||||
'가자', '가자 이제', '이제 가자', '자 가자', "let's go now", "okay let's go", "come on, let's go", 'back to where you picked it up', 'put it back where you found it',
|
||||
# past events and tag questions are the PAST_EN / past_ko / TAG guards' (exact, before any match)
|
||||
'인스타 팔로우 해 줘', 'follow us on instagram', 'follow our account', '따라 해 봐', '내 말 따라 해', 'repeat after me', 'copy me', 'do what i do', 'can you lend me a hand?', 'give me a hand with this', '한 번만 더 해 줘', 'do it again', 'again please', 'one more time', '다시 해 줘', '또 해 봐', '한 번 더', 'over here for a sec', 'wait over there', 'the other way', '왼쪽으로', '오른쪽으로', '앞으로', '뒤로',
|
||||
'can your arm move?', 'how long is your arm?', 'how far can you reach?', '악수하자', '악수할래?', 'can you turn your head?', 'is your head turning?', 'how high can you go?', 'how low can you go?', "what's on the ceiling?", 'is the floor clean?', 'where are you looking?', 'what are you looking at?', '어디 보고 있어?', '왜 나를 봐?', '왜 따라와?', '키가 몇이야?', '팔 길이가 얼마야?', '고개 아파?', '손 차가워?', '손 따뜻해?',
|
||||
'can your arm move?', 'how long is your arm?', 'how far can you reach?', 'can you turn your head?', 'is your head turning?', 'how high can you go?', 'how low can you go?', "what's on the ceiling?", 'is the floor clean?', 'where are you looking?', 'what are you looking at?', '어디 보고 있어?', '왜 나를 봐?', '왜 따라와?', '키가 몇이야?', '팔 길이가 얼마야?', '고개 아파?', '손 차가워?', '손 따뜻해?',
|
||||
# cut-off starts
|
||||
"let's", "can you", "could you", "please", "lumi, can you", "wait", "hmm", "so", "go", "move", "turn", "look",
|
||||
"루미야 저기", "저기요", "루미야", "혹시", "그럼", "잠깐만", "있잖아", "근데",
|
||||
@@ -580,7 +580,7 @@ ARM_REACH += [
|
||||
"please stretch out your arm", "hold your arm out", "hold your hand out to me", "hand out please",
|
||||
"put your hand forward", "push your arm out", "arm forward", "arm forward please", "your arm, stretch it out",
|
||||
"you stretch arm please", "you put arm out", "arm long please", "make arm long", "arm straight please",
|
||||
"reach reach", "gimme your hand", "give your hand to me",
|
||||
"reach reach", "gimme your hand", "give your hand to me", "shake hands with me", "let's shake hands", "shake my hand", "give me a hand", "악수하자", "악수할래?", "루미야 손 줘",
|
||||
"팔 뻗어 보거라", "팔 뻗어 보게", "팔 좀 뻗어 보이소", "팔 뻗어 부러", "팔 뻗어 봐유", "팔 뻗어 줘용", "팔 뻗어 주라",
|
||||
"팔 좀 뻗어 주세요", "팔 쭉 뻗어 주세요", "팔 앞으로 뻗어 주세요", "팔 앞으로 내밀어 주세요", "손 내밀어 주세요",
|
||||
"손 좀 내밀어 줄래?", "손 앞으로 뻗어", "손 쭉 뻗어 봐", "팔 펴 봐", "팔 펴 주세요", "팔을 펴 주십시오",
|
||||
|
||||
+123
-23
@@ -122,7 +122,7 @@ WAKE = re.compile(r"\b(hi|hey|hello|okay|ok|hai|high)?[\s,.!]*(lumi|lumia|loomi|
|
||||
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)
|
||||
FETCH_STOP = re.compile(r"\b(sto+p|halt|freeze|don'?t move)\b|^\W*abort\W*$|\babort (?:the |this |your )?(?:mission|task|trip)\b|\bcancel (?:the |this |your )?(?:mission|task|trip)\b|"
|
||||
FETCH_STOP = re.compile(r"\b(sto+pp?|stob|halt|freeze|don'?t move)\b|^\W*(?:lumi\W+)?stopped\W*$|스탑|스텁|멈추(?:세요|십시오)|^\W*abort\W*$|\babort (?:the |this |your )?(?:mission|task|trip)\b|\bcancel (?:the |this |your )?(?:mission|task|trip)\b|"
|
||||
r"머+엄*춰|머+엄*추(?:세요|십시오)|멈춰|그만|정지|스톱|미션 ?취소|작업 ?취소|거기 ?서(?=[\s!.~,]*$)|움직이지 ?마|"
|
||||
r"^\W*(?:wait|잠깐|잠깐만|기다려)\W*$", re.I) # not "거기서 기다려"
|
||||
FETCH_GIVE = re.compile(r"\bgive (it|that|this|the \w+)( to me)?\b|\bhand (it )?(over|to me)\b|줘|주세요|건네", re.I)
|
||||
@@ -291,6 +291,9 @@ HELLO_ONLY = re.compile(r"^\s*(hi|hey|hello|hiya)( there)?[\s,.!]*$|^\s*(안녕|
|
||||
CAMERA_HALF_FOV = 42.0 # deg; half the camera's view (+ the head's YAW_LIMIT for the head camera)
|
||||
WAKE_MAX_S = 6.0 # s; longer utterances are not checked for the wake word
|
||||
BARGE_IN_LOGPROB = -0.6 # an interruption must be heard more clearly than a normal answer (-1.0)
|
||||
ECHO_LIKELY = 0.45 # sound match (mouth.echo) from which a barge-in is Lumi's own voice when its words
|
||||
ECHO_LIKELY_SHARE = 0.4 # ... share this much with what Lumi said; echoes 0.51 / 0.54, the visitor 0.14-0.32
|
||||
# (2026-10-23 15:08-15:16; mouth.ECHO_MIN 0.6 alone let the weather answer's echo in)
|
||||
BYE_WAVE = re.compile(r"\bb(?:ye|ay)[- ]?b(?:ye|ay)\b|바이 ?바이|빠이 ?빠이|잘 ?가", re.I) # a goodbye with a wave
|
||||
CLOSING_WAIT_S = 8.0 # s of silence after "okay" / "thank you" / "네" before Lumi says goodbye
|
||||
ANSWER_ECHO_S = 10.0 # s of Lumi's speech a dialog answer is checked against for echo: only the question
|
||||
@@ -1885,6 +1888,27 @@ class Lumi:
|
||||
def traveling(self):
|
||||
return self.patrol is not None and self.patrol.mode != "done"
|
||||
|
||||
def moving_now(self):
|
||||
"""A trip, patrol, mission or any base move runs: anyone's stop word stops it, without the wake word."""
|
||||
return self.traveling() or self.fetch_status() == "running" or \
|
||||
(safe(agv.status, default={}) or {}).get("move_status") == "running"
|
||||
|
||||
def stop_heard(self):
|
||||
"""While the main loop waits on a drive (come here): True if the next utterance is anyone's stop word; other
|
||||
words are answered after the drive."""
|
||||
u = self.mic.next(0.0)
|
||||
if u is None or u.seconds < 0.25:
|
||||
return False
|
||||
text = (ears.transcribe(u.mono) or "").strip()
|
||||
if text and not stop_order(text, self.markers) and mouth.own_voice(u):
|
||||
return False
|
||||
if text and stop_order(text, self.markers): # before own_echo: "Stop." after Lumi's "I stopped" is not
|
||||
log(f" stop word while driving: {text!r}") # an echo
|
||||
return True
|
||||
if text and not self.own_echo(text):
|
||||
self.pending_text = text
|
||||
return False
|
||||
|
||||
def write_calib(self, state, result=None):
|
||||
try:
|
||||
with open(CALIB_FILE, "w") as f:
|
||||
@@ -1924,17 +1948,26 @@ class Lumi:
|
||||
return False
|
||||
if not getattr(u, "during_speech", False) or u.seconds < 0.25:
|
||||
return False
|
||||
if mouth.own_voice(u): # the speaker's sound in the clip mic (mouth.echo)
|
||||
log(f" ignored own voice (sound match {mouth.last_echo:.2f})")
|
||||
return False
|
||||
own = mouth.own_voice(u) # the speaker's sound in the clip mic (mouth.echo)
|
||||
text = (ears.transcribe(u.mono) or "").strip()
|
||||
if not text or self.own_echo(text):
|
||||
return False
|
||||
from tasks import follow
|
||||
if follow.running() and follow.stop_word(text): # following: the base stops now, "stop" is answered next
|
||||
follow.stop() # (anyone's: safety)
|
||||
follow.stop() # (anyone's: safety, never dropped as an echo)
|
||||
self.pending_text = "stop"
|
||||
return True
|
||||
if text and stop_order(text, self.markers): # anyone's "stop" / "멈춰", one word too: motion stops now,
|
||||
log(f" interrupted by a stop word: {text!r}") # answered next; before every echo filter (at worst Lumi
|
||||
self.act("stop", "") # stops once for its own word)
|
||||
self.pending_text = text
|
||||
return True
|
||||
if own:
|
||||
log(f" ignored own voice (sound match {mouth.last_echo:.2f})")
|
||||
return False
|
||||
if not text or self.own_echo(text):
|
||||
return False
|
||||
if (mouth.last_echo or 0) >= ECHO_LIKELY and self.own_echo(text, share=ECHO_LIKELY_SHARE):
|
||||
log(f" ignored own voice (sound match {mouth.last_echo:.2f}, words): {text!r}")
|
||||
return False
|
||||
if follow.running() and not self.followed_speaks(u):
|
||||
log(f" following: not the person I follow, ignored: {text!r}")
|
||||
return False
|
||||
@@ -1959,11 +1992,16 @@ class Lumi:
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def own_echo(text, seconds=30.0):
|
||||
"""The clip mic also hears Lumi: ignore what overlaps with what it said in the last `seconds`."""
|
||||
def own_echo(text, seconds=30.0, share=0.6):
|
||||
"""The clip mic also hears Lumi: ignore what overlaps with what it said in the last `seconds`. A word counts
|
||||
when said, or when it starts a said word or a said word starts it ("temperature" / "temperatures", "over" /
|
||||
"overcast": whisper cuts and bends the echo)."""
|
||||
said = set(re.findall(r"\w+", mouth.recent_speech(seconds).lower()))
|
||||
words = re.findall(r"\w+", text.lower())
|
||||
return bool(words) and sum(w in said for w in words) / len(words) >= 0.6
|
||||
|
||||
def heard(w):
|
||||
return w in said or len(w) >= 4 and any(len(s) >= 4 and (s.startswith(w) or w.startswith(s)) for s in said)
|
||||
return bool(words) and sum(map(heard, words)) / len(words) >= share
|
||||
|
||||
# ---------- interrupts ----------
|
||||
def interrupted(self):
|
||||
@@ -2009,11 +2047,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 mouth.own_voice(u): # the speaker's sound in the clip mic (mouth.echo)
|
||||
if text and mouth.own_voice(u) and not stop_order(text, self.markers): # the speaker's sound in the clip mic
|
||||
# (mouth.echo); a stop word is never dropped as Lumi's own voice
|
||||
log(f" ignored own voice (sound match {mouth.last_echo:.2f}): {text!r}")
|
||||
text = None
|
||||
if text and self.own_echo(text) and (u is None or (u.during_speech if u.source == "clip"
|
||||
else len(text.split()) <= 2)):
|
||||
if text and self.own_echo(text) and not stop_order(text, self.markers) 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
|
||||
@@ -2188,6 +2227,7 @@ class Lumi:
|
||||
en = self.lang == "en"
|
||||
if action == "weather": # "내일 비 와?" after Jeju's weather: Jeju
|
||||
target = self.brain.weather_place(target, text)
|
||||
days = self.brain.weather_on(text) # "and next Monday?": that day only, at the same place
|
||||
if action == "search" and private_ask(text): # never looked up, whoever it is about
|
||||
log(" search refused: a person's private details")
|
||||
mouth.say(PRIVATE_SAY["en" if en else "ko"])
|
||||
@@ -2199,7 +2239,7 @@ class Lumi:
|
||||
daemon=True)
|
||||
else:
|
||||
fetch = threading.Thread(target=lambda: found.update(
|
||||
facts=web.weather(target) if action == "weather" else web.search(target)), daemon=True)
|
||||
facts=web.weather_on(web.weather(target), days) if action == "weather" else web.search(target)), daemon=True)
|
||||
fetch.start()
|
||||
if not use_openai:
|
||||
# the free search: the answer is fetched and made while "Let me check." plays (~1 s sooner)
|
||||
@@ -2346,8 +2386,7 @@ class Lumi:
|
||||
self.come_back(speak=True)
|
||||
return True
|
||||
if action == "come":
|
||||
mouth.say("Okay, I'm coming." if en else "네, 갈게요.")
|
||||
self.come_to(self.current)
|
||||
self.come_to(self.current, say=True) # drives first, says "I'm coming" as it starts
|
||||
return True
|
||||
if action == "follow":
|
||||
self.follow_me()
|
||||
@@ -2450,6 +2489,8 @@ class Lumi:
|
||||
if kind == "stop":
|
||||
self.stop_all() # "stop", "stop, where are you going?": stop first, always
|
||||
return
|
||||
if self.pointed_drive(text): # "go there" / "저기로 가" with a pointing arm (pointing.py)
|
||||
return
|
||||
if kind == "detour" and self.detour(data): # after a blocked drive: "try again", "다른 길로 가 봐"
|
||||
return
|
||||
if kind == "chain" and self.chain_request(text, data): # "look at me and wave", "go to p5 and tell me the weather"
|
||||
@@ -2526,8 +2567,7 @@ class Lumi:
|
||||
return
|
||||
if head_["action"] == "come":
|
||||
gen.close()
|
||||
mouth.say("Okay, I'm coming." if self.lang == "en" else "네, 갈게요.")
|
||||
self.come_to(self.current)
|
||||
self.come_to(self.current, say=True)
|
||||
return
|
||||
if head_["action"] == "follow":
|
||||
gen.close()
|
||||
@@ -2614,9 +2654,16 @@ class Lumi:
|
||||
if follow.running(): # following: talk_turn listens to the followed person only
|
||||
return False
|
||||
u = self.mic.next(0.0)
|
||||
if u is None or not (0.3 <= u.seconds <= WAKE_MAX_S) or getattr(u, "during_speech", False):
|
||||
if u is None or not (0.3 <= u.seconds <= WAKE_MAX_S):
|
||||
return False
|
||||
during = getattr(u, "during_speech", False) # said while Lumi talks: only a stop word counts
|
||||
text = ears.transcribe(u.mono)
|
||||
if text and stop_order(text, self.markers) and self.moving_now(): # never dropped as Lumi's own voice
|
||||
log(f" stop word while moving: {text!r} (no wake word needed)") # "Stop." on a trip went on, 2026-10-23
|
||||
self.stop_all()
|
||||
return True
|
||||
if during:
|
||||
return False
|
||||
m = WAKE.search(text or "")
|
||||
if not m and HELLO_ONLY.match(text or ""): # a plain "Hi!" / "Hey" said on its own
|
||||
m = HELLO_ONLY.match(text)
|
||||
@@ -2697,8 +2744,9 @@ class Lumi:
|
||||
time.sleep(0.2)
|
||||
|
||||
# ---------- come here ----------
|
||||
def come_to(self, track):
|
||||
"""Drive to the person (a visible track) and stop about COME_STOP in front of them."""
|
||||
def come_to(self, track, say=False):
|
||||
"""Drive to the person (a visible track) and stop about COME_STOP in front of them. `say`: "I'm coming"
|
||||
once the base has the goal, spoken while it drives (the motion never waits for the words)."""
|
||||
if not self.modes.drive:
|
||||
mouth.say("Sorry, driving is switched off.")
|
||||
return
|
||||
@@ -2729,6 +2777,9 @@ class Lumi:
|
||||
log(f" base refused: {msg}")
|
||||
mouth.say("Sorry, I can't get closer from here.")
|
||||
return
|
||||
if say:
|
||||
threading.Thread(target=mouth.say, args=("Okay, I'm coming." if self.lang == "en" else "네, 갈게요.",),
|
||||
daemon=True).start()
|
||||
t, last_look = time.time(), 0.0
|
||||
time.sleep(0.5)
|
||||
while time.time() - t < COME_TIMEOUT:
|
||||
@@ -2738,6 +2789,9 @@ class Lumi:
|
||||
if isinstance(st.get("guard"), (list, tuple)):
|
||||
mouth.say(st["guard"][0] if self.lang == "en" else st["guard"][1])
|
||||
break
|
||||
if self.stop_heard(): # the main loop waits here: listen for "stop" too
|
||||
self.stop_all()
|
||||
return
|
||||
if self.vision.present(track):
|
||||
if track.distance <= COME_STOP:
|
||||
log(f" person #{track.id} is {track.distance:.2f} m away - stop")
|
||||
@@ -2753,6 +2807,52 @@ class Lumi:
|
||||
self.turn_head(HEAD_SIGN * track.angle)
|
||||
self.last_activity = time.time()
|
||||
|
||||
def pointed_drive(self, text):
|
||||
""""Go there" / "저기로 가" / "come to where I'm pointing" with a pointing arm: drive to the floor spot pointed
|
||||
at (vision/pointing.py). True when handled. "here" / "여기" without a pointing arm is left to come-here (False);
|
||||
"there" without one, or a spot that can't be told or reached, is said plainly, never guessed."""
|
||||
from vision import pointing
|
||||
word = pointing.asked(text)
|
||||
if word is None or self.base_off("go_to", "pointed"):
|
||||
return word is not None
|
||||
en = self.lang == "en"
|
||||
if not self.modes.drive or self.mission_running() or self.skill_busy():
|
||||
mouth.say("Sorry, I can't drive right now." if en else "죄송해요, 지금은 이동할 수 없어요.")
|
||||
return True
|
||||
spot = safe(pointing.target, default={"why": "no_depth"}) or {"why": "no_depth"}
|
||||
log(f"POINTED ({word}): {spot}")
|
||||
if "map" not in spot:
|
||||
if word == "here" and spot["why"] in ("nobody", "not_pointing"):
|
||||
return False # plain "come here": today's come_to
|
||||
mouth.say(pointing.SAY[spot["why"]][0 if en else 1])
|
||||
self.keep_listening()
|
||||
return True
|
||||
far = spot["clamped"]
|
||||
mouth.say((f"Going that way, {pointing.MAX_M:g} meters." if far else "Going there.") if en else
|
||||
(f"그쪽으로 {pointing.MAX_M:g}미터 갈게요." if far else "그곳으로 갈게요."))
|
||||
ok, msg = safe(agv.go_point, *spot["map"], default=(False, "error"))
|
||||
if not ok:
|
||||
log(f" base refused: {msg}")
|
||||
mouth.say("Sorry, I can't go there." if en else "죄송해요, 그곳으로 갈 수 없어요.")
|
||||
return True
|
||||
t = time.time()
|
||||
time.sleep(0.5)
|
||||
while time.time() - t < COME_TIMEOUT:
|
||||
st = safe(agv.status, default={}) or {}
|
||||
if st.get("move_status") != "running":
|
||||
log(f" pointed drive ended ({st.get('move_status')})")
|
||||
if st.get("move_status") != "succeeded":
|
||||
mouth.say("I couldn't get there." if en else "그곳까지 못 갔어요.")
|
||||
break
|
||||
if self.stop_heard(): # the main loop waits here: listen for "stop" too
|
||||
self.stop_all()
|
||||
return True
|
||||
time.sleep(0.2)
|
||||
else:
|
||||
safe(agv.cancel)
|
||||
self.last_activity = time.time()
|
||||
return True
|
||||
|
||||
# ---------- follow me (tasks/follow.py) ----------
|
||||
def follow_me(self):
|
||||
"""Lock onto the person who said "follow me" (the track talking, else the one where the voice came from)
|
||||
@@ -2974,8 +3074,8 @@ def stop_order(text, markers):
|
||||
"can you stop?", "멈출 수 있어?" and "stop, where are you going?" do stop. Not a negated stop ("don't stop", "계속
|
||||
해"), talk about stopping ("he said stop", "bus stop", "my laptop freezes", "내 다리도 자주 멈춰"); a short bare
|
||||
stop word always stops (also stretched: "stooop", "머엄춰")."""
|
||||
if NOT_STOP.search(text) and not re.fullmatch(r"\W*(?:(?:no|ok|okay|lumi|루미야?|hey)\W+)*(?:sto+p|halt|freeze|멈춰|머+엄*춰|"
|
||||
r"그만|정지|스톱|stop it|stop now)\W*", text, re.I):
|
||||
if NOT_STOP.search(text) and not re.fullmatch(r"\W*(?:(?:no|ok|okay|lumi|루미야?|hey)\W+)*(?:sto+pp?|stob|stopped|halt|freeze|멈춰|머+엄*춰|"
|
||||
r"그만|정지|스톱|스탑|stop it|stop now)\W*", text, re.I):
|
||||
return False
|
||||
asked = bool(brain_mod.STOP_ASK.match(brain_mod.CALLING.sub("", text)) or
|
||||
re.match(r"^\W*(?:stop|halt|freeze|멈춰|정지|스톱)\W*[,.!]", text, re.I))
|
||||
|
||||
@@ -270,6 +270,11 @@ ASR_SLIPS = [ # how whisper writes Korean commands (tests/asr_check.py, 2026-1
|
||||
(r"고게(?=\s*(?:들|숙))", "고개"), (r"찝어", "집어"), (r"파이나(?=\s*(?:갔|가|로))", "파이널"),
|
||||
# the owner's English as whisper wrote it live (logs/lumi.log 2026-10-21 / 22)
|
||||
(r"\bcount to(?= p\s?\d)", "come to"), # "Let's count to p5."
|
||||
# the head up / down, said or heard loosely (2026-10-23 15:08-15:16: "Look at the bellow.", "Look it up.")
|
||||
(r"\blook (?:at |to(?:wards?)? )?(?:the )?(?:upwards?|above)\b|\blook (?:at |to(?:wards?)? )(?:the )?up\b", "look up"),
|
||||
(r"\blook (?:at |to(?:wards?)? )?(?:the )?(?:downwards?|below|bellow)\b|\blook (?:at |to(?:wards?)? )(?:the )?down\b",
|
||||
"look down"),
|
||||
(r"^\W*look it up\W*$", " look up "), # alone it is the head; "look it up for me" / "look up the news" stay a search
|
||||
(r"\b(?:go )?(?:copy|pick) (\d+|one|two|three|four|five|six|seven|eight|nine|ten) point\b", r"go to p\1"),
|
||||
(r"\bfall(?:ow)? (?:lonely|of him)\b", "follow me"), # "Let's fall lonely.", "Let's fall of Him."
|
||||
# hearing round 2 (tests/asr_check.py blind r3 / set 5, 2026-10-22 night)
|
||||
@@ -294,6 +299,8 @@ KONGLISH = [ # English direction words said in Korean -> the Korean word ("레
|
||||
"돌아"), # "왼쪽으로 턴 해", "왼쪽으로 turn 해"
|
||||
(r"(?:" + _NO + r"무브|(?:(?<=미터 )|(?<=센티 )|(?<=센치 )|(?<=cm )|(?<=\dm )|(?<=으로 ))고|" + _NO + r"고\s*고)(?:\s*(?:해|해요|하세요|해\s*줘|해\s*주세요))?(?![가-힣])",
|
||||
"이동해"), # "고" alone is a particle / a place's "go": after a way only
|
||||
(_NO + r"업\s*(?=(?:좀\s*)?(?:봐|보세요|봐요))", "위 "), # "업 봐"
|
||||
(_NO + r"다운\s*(?=(?:좀\s*)?(?:봐|보세요|봐요))", "아래 "), # "다운 봐"
|
||||
(r"(고개|머리|헤드|얼굴)\s*(?:를|을)?\s*업(?![가-힣])", r"\1 들어"),
|
||||
(r"(고개|머리|헤드|얼굴)\s*(?:를|을)?\s*다운(?![가-힣])", r"\1 숙여"),
|
||||
(_NO + r"헤드(?=\s)", "고개"),
|
||||
|
||||
@@ -234,7 +234,7 @@ for t in ["I'll be back", "I'm behind you", "I'll be right back"]:
|
||||
for t in ["can you fly?", "jump", "jump for me!", "dance for me", "can you dance?", "climb the stairs", "open the door",
|
||||
"make me a coffee", "lift this table", "pick up that chair", "go upstairs", "do a backflip", "run!", "sit down",
|
||||
"날아 봐", "점프해", "춤 춰 줘", "커피 타 줘", "계단 올라가", "문 열어 줘", "이 책상 들어 봐", "앉아", "pick up my phone",
|
||||
"take my laptop", "carry me", "give me a hug", "shake hands with me", "throw the cup", "kick the ball",
|
||||
"take my laptop", "carry me", "give me a hug", "throw the cup", "kick the ball",
|
||||
"pick me up", "날 안아 줘", "공 차 봐", "이 의자 옮겨 줘", "pick up the box", "bring me a pizza"]:
|
||||
both("cannot", [t], "talk | ask | unclear")
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ for t in ["wave", "wave at them", "wave your hand", "wave hello", "give them a w
|
||||
"say hi with your hand", "손 흔들어", "손 흔들어 줄래?", "손 인사 해 줘", "손 좀 흔들어 주세요", "애들한테 손 흔들어 줘",
|
||||
"wave 해 줘", "손 wave 해 봐"]:
|
||||
add("wave", t, "action:wave")
|
||||
for t in ["do you know how to wave?", "손 흔들 줄 알아?", "I saw you wave yesterday", "the wave was nice", "shake hands with me",
|
||||
for t in ["do you know how to wave?", "손 흔들 줄 알아?", "I saw you wave yesterday", "the wave was nice",
|
||||
"a new wave of visitors is coming"]:
|
||||
add("wave_not", t, "talk")
|
||||
for t in ["bye bye", "bye-bye!", "바이바이", "빠이빠이", "잘 가", "okay, bye!", "see you, Lumi"]:
|
||||
|
||||
+23
-2
@@ -10,7 +10,7 @@ import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from assistant import brain, lumi, seeing
|
||||
from assistant import brain, lumi, seeing, web
|
||||
from tests.conversation_check import NOW, rules_route
|
||||
from tests.followup_cases import CASES
|
||||
from vision import scene
|
||||
@@ -57,7 +57,9 @@ def route(b, text, frames):
|
||||
if h["action"] == "search":
|
||||
return "search", b.search_query(h["target"])
|
||||
if h["action"] != "none":
|
||||
return f"act:{h['action']} {h['target']}" if h["action"] != "weather" else "weather", h["target"]
|
||||
if h["action"] == "weather": # the place kept, the day in the words
|
||||
return "weather", h["target"] or f"weather {b.weather_place('', text)} {text}"
|
||||
return f"act:{h['action']} {h['target']}", h["target"]
|
||||
return "llm", ""
|
||||
|
||||
|
||||
@@ -147,4 +149,23 @@ if __name__ == "__main__":
|
||||
b.history = [("what's a lidar?", "ACTION: none -\nA laser scanner.")]
|
||||
assert b._after({"action": "quiet", "target": ""}, "에이, 거짓말하지 마")["action"] == "none"
|
||||
assert b.again("one more time") == "same" and b._after({"action": "none", "target": ""}, "again")["action"] == "none"
|
||||
from assistant import driving # "more" right after a look: the head a step further (live 2026-10-23)
|
||||
looked = driving.last_command([("Look at the left side.", "ACTION: look left")])
|
||||
for said in ("More again.", "Look at more.", "Look at the left side more.", "more", "a bit more", "again", "더", "조금 더",
|
||||
"한 번 더", "좀 더 봐", "왼쪽으로 더", "look more to the left"):
|
||||
assert driving.read(driving.clean(brain._norm(said)), looked) == ("look", "left small"), said
|
||||
assert driving.read("look right", looked) is None and driving.read("i want more", looked, True) is None
|
||||
assert driving.read("오른쪽으로 더", looked) == ("look", "right small")
|
||||
# the weather asked, then the day moved (live 2026-10-23 15:37: "내일 어때요?" and "다음 주 월요일 어때요?" were
|
||||
# searched, "날씨 어때요?" then gave today's weather): the weather again, the day and place kept
|
||||
b = brain.Brain()
|
||||
b.history = [("오늘 부산 날씨 어때요? (the weather)", "흐려요.")]
|
||||
b.last_lookup, b.weather_at = b.history[0][0], "Busan"
|
||||
for t in ("내일 어때요?", "다음 주 월요일 어때요?", "And Friday?", "how about the day after?", "모레는요?"):
|
||||
for said in ("none", "search"):
|
||||
assert b._after({"action": said, "target": t}, t) == {"action": "weather", "target": ""}, (t, said)
|
||||
assert b._after({"action": "none", "target": ""}, "what about Daegu tomorrow?") == {"action": "weather", "target": "Daegu"}
|
||||
assert b._after({"action": "none", "target": ""}, "Thanks, see you tomorrow!")["action"] == "none"
|
||||
b.history = [("다음 주 월요일 어때요?", "다음 주 월요일은 10월 26일이에요.")]
|
||||
assert b.weather_on("날씨 어때요?") == web.asked_day("다음 주 월요일")
|
||||
print("followup ok")
|
||||
|
||||
@@ -43,6 +43,12 @@ CASES.update({ # any wording of the body commands, English, Korean and mixed (
|
||||
"정면 봐": ("look", "center"), "고개 살짝 왼쪽으로": ("look", "left small"), "고개 좀 위로 살짝 들어 봐": ("look", "up small"),
|
||||
"고개 오른쪽으로 30도 돌려": ("look", "right 30"), "turn your head left 120": ("look", "left 120"),
|
||||
"look behind you": ("look", "left 180"), "뒤를 봐": ("look", "left 180"), "뒤 돌아봐": ("look", "left 180"), "now 오른쪽 봐!": ("look", "right"),
|
||||
# up / down as said or heard live (2026-10-23: "Look at the bellow.", "Look it up." went to the LLM)
|
||||
"Look at up.": ("look", "up"), "look at the up": ("look", "up"), "look upward": ("look", "up"), "look above": ("look", "up"),
|
||||
"Look it up.": ("look", "up"), "Look at down.": ("look", "down"), "look downwards": ("look", "down"),
|
||||
"Look at the bellow.": ("look", "down"), "look below": ("look", "down"), "위 봐": ("look", "up"), "업 봐": ("look", "up"),
|
||||
"다운 봐": ("look", "down"), "밑에 봐": ("look", "down"), "아래 봐 줘": ("look", "down"),
|
||||
"look it up for me": None, "Can you look it up?": None, "Look up the news.": ("search", "Look up the news."),
|
||||
"look up the weather in Paris": ("weather", "Paris"),
|
||||
"부산 날씨 알려줘": ("weather", "Busan"),
|
||||
"제주도 날씨는?": ("weather", "Jeju City"),
|
||||
@@ -124,6 +130,13 @@ assert brain.head_goal("right 200", 0, 0) == (-180.0, 0, "yaw")
|
||||
assert brain.head_goal("up 50", 0, 0) == (0, 35.0, "pitch")
|
||||
assert brain.head_goal("left small", 10, 0) == (25.0, 0, None)
|
||||
assert brain.head_goal("down", 20, 10) == (20, -5, None)
|
||||
assert brain.head_goal("left", 40, 0) == (55.0, 0, None) and brain.head_goal("right", -40, 0) == (-55.0, 0, None) # "look left"
|
||||
assert brain.head_goal("up", 0, 20) == (0, 30.0, None) and brain.head_goal("left", -40, 0) == (40, 0, None) # again: further
|
||||
for said, want in {"Look at the left side.": "left", "Look at the right side.": "right", "Lumi, look at the left side.": "left",
|
||||
"look on your left": "left", "Look at the front.": "center", "look left more": "left small",
|
||||
"look more to the right": "right small", "왼쪽 좀 봐 줘": "left", "오른쪽 봐": "right", "왼쪽 봐": "left",
|
||||
"왼쪽 더 봐": "left small", "오른쪽 조금 더 봐 줘": "right small"}.items(): # live 2026-10-23: went to the LLM
|
||||
assert brain.intent(said, ["p1", "p2", "home"]) == ("look", want), (said, brain.intent(said))
|
||||
assert brain.lift_goal("up 50", 80) == (105.0, True)
|
||||
assert brain.lift_goal("down small", 50) == (20.0, False)
|
||||
assert brain.lift_goal("up", 0) == (105.0, False)
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
"""The live sequence of 2026-10-23 15:21-15:23, replayed with fakes: "give me a hand" / handshake words with an empty
|
||||
hand are arm reach (the rules, not the LLM's "I can't shake hands"), and a reach whose body move hangs ends at once on
|
||||
STOP, so the next "give me your hand" starts instead of "I'm busy with another task". No robot.
|
||||
|
||||
.venv/bin/python tests/test_reach_live.py
|
||||
"""
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from assistant import brain
|
||||
from tasks import fetch
|
||||
|
||||
MARKERS = ["home", "p1"]
|
||||
REACH = ["Let's give me a hand.", "Let's give me your hand.", "Give me your hand.", "give me a hand", "손 줘",
|
||||
"손 내밀어", "루미야 손 줘", "Lumi, 손 줘", "hand 줘", "손 좀 줘", "shake hands with me", "let's shake hands",
|
||||
"shake my hand", "give me a handshake", "악수하자", "악수해 줘", "나랑 악수할래?"]
|
||||
NOT_REACH = ["give me a hand with this", "can you lend me a hand?", "give me a hand to lift this", "I shook hands with him",
|
||||
"don't shake hands", "악수하지 마", "어제 악수했어", "the handshake was nice", "give me a break"]
|
||||
|
||||
bad = [(t, brain.intent(t, MARKERS)) for t in REACH if brain.intent(t, MARKERS) != ("arm", "reach")]
|
||||
bad += [(t, brain.intent(t, MARKERS)) for t in NOT_REACH if brain.intent(t, MARKERS) == ("arm", "reach")]
|
||||
bad += [(t, "held rule") for t in REACH if brain.hand_request(t, False, None, MARKERS)] # empty hand: never a give
|
||||
assert not bad, bad
|
||||
|
||||
# ---------- the stuck reach: the body API does not answer a head move ----------
|
||||
tmp = Path(tempfile.mkdtemp())
|
||||
fetch.STATE_FILE = tmp / "lumi_task.json"
|
||||
hung = threading.Event() # never set: the body API's moveto hangs
|
||||
fetch.head.moveto = lambda pos, **kw: hung.wait(30)
|
||||
fetch.head.status = lambda: [0.0, 0.0, -22.0, 0.0]
|
||||
fetch.camview.want = lambda name: None
|
||||
fetch.skills.cancel = fetch.agv.cancel = lambda: None
|
||||
fetch.motion.poses = lambda: {"give": [0] * 6, "look": [0] * 6}
|
||||
fetch.head_ahead = lambda: None
|
||||
moved = []
|
||||
fetch._turn = lambda deg, **kw: (fetch._head_to(-30.0, 0.0), True)[1] # the turn's head check (head_hits) hangs
|
||||
fetch._pose = lambda name: moved.append(name)
|
||||
fetch._person_point = lambda: ((0.0, 600.0, 0.0), 100.0)
|
||||
fetch._reach_to_hand = lambda *a: moved.append("hand")
|
||||
|
||||
fetch.reach(-22.7)
|
||||
time.sleep(0.3)
|
||||
assert fetch._busy() and fetch.state()["status"] == "running"
|
||||
try:
|
||||
fetch.reach(-22.0) # said again while it really runs: busy is right
|
||||
raise AssertionError("a second reach started")
|
||||
except fetch.FetchError as e:
|
||||
assert "busy" in e.args[0]
|
||||
t = time.time()
|
||||
fetch.end() # "stop" / a new command
|
||||
assert time.time() - t < 1.0 and not fetch._busy(), "stop waited for the hung body call"
|
||||
assert fetch.state()["status"] == "stopped" and moved == []
|
||||
|
||||
hung.set() # the body answers again
|
||||
fetch.reach(0.0) # the next "give me your hand": starts, not "busy"
|
||||
fetch._thread.join(2)
|
||||
assert moved == ["give", "hand"] and fetch.state()["status"] == "done", (moved, fetch.state()["status"])
|
||||
print(f"reach live ok ({len(REACH) + len(NOT_REACH)} wordings, stop during a hung body move)")
|
||||
@@ -0,0 +1,179 @@
|
||||
"""Self-check of stop words heard while Lumi moves, replaying the owner's live test of 2026-10-23 15:02-15:21
|
||||
(logs/lumi_console.log): "Stop." on a drive to a marker went on ("heard 'Stop.' (no wake word)"), "Stop, 루미."
|
||||
only paused the drive and turned the base toward the voice, a one-word "Stop." / "멈춰." while Lumi talked was not a
|
||||
stop. Fake mic, speech-to-text and base; nothing reaches the robot: python tests/test_stop_live.py"""
|
||||
import threading
|
||||
import time
|
||||
|
||||
from assistant import lumi
|
||||
from tasks import fetch, follow
|
||||
|
||||
M = ["home", "dock2"] + [f"p{i}" for i in range(1, 11)]
|
||||
done = []
|
||||
base = {"move_status": "idle"}
|
||||
|
||||
# the robot: every call that could move or stop something is recorded, never sent
|
||||
lumi.agv.cancel = lambda: done.append("agv cancel")
|
||||
lumi.agv.status = lambda: dict(base)
|
||||
lumi.agv.turn_by = lambda a: done.append("TURN") # find_caller's turn toward the voice
|
||||
lumi.agv.go_point = lambda *a: done.append("GO") or (True, "")
|
||||
lumi.skills.cancel = lambda: done.append("skills cancel")
|
||||
lumi.motion.stop = lambda: done.append("arm stop")
|
||||
follow.stop = lambda: done.append("follow stop")
|
||||
fetch.stop = lambda: done.append("fetch stop")
|
||||
fetch.state = lambda: {"status": "idle"}
|
||||
lumi.mouth.say = lambda text, **k: done.append(("say", text))
|
||||
lumi.mouth.own_voice = lambda u: False
|
||||
lumi.mouth.recent_speech = lambda s: ""
|
||||
lumi.doa.load_calib = lambda: {"fitted": False}
|
||||
lumi.doa.estimate = lambda mics, cal: (0.0, 0.0, 0.0)
|
||||
lumi.ears.heard_lang = lambda lang: lang
|
||||
|
||||
|
||||
class U: # one utterance from audio/mic.py
|
||||
def __init__(self, text, seconds=0.8, during_speech=False):
|
||||
self.mono, self.mics, self.seconds, self.during_speech, self.source = text, None, seconds, during_speech, "clip"
|
||||
|
||||
|
||||
lumi.ears.transcribe = lambda mono: mono # the fake utterance carries what whisper heard
|
||||
|
||||
|
||||
class Mic:
|
||||
def __init__(self, *utts):
|
||||
self.q = list(utts)
|
||||
|
||||
def next(self, timeout):
|
||||
return self.q.pop(0) if self.q else None
|
||||
|
||||
|
||||
class Brain:
|
||||
def reset(self):
|
||||
pass
|
||||
|
||||
|
||||
def fresh(*utts, trip=True):
|
||||
L = lumi.Lumi.__new__(lumi.Lumi)
|
||||
L.markers, L.lang, L.current, L.vision, L.pending_text = M, "en", None, None, None
|
||||
L.mic, L.brain, L.chain_stop = Mic(*utts), Brain(), threading.Event()
|
||||
L.patrol = lumi.Patrol(["p5"], once=True) if trip else None
|
||||
if trip:
|
||||
L.patrol.moving = True
|
||||
L.voice_until = L.quiet_until = 0.0
|
||||
L.last_activity, L.closing_pending, L._yaw, L._yaw_time = time.time(), None, 0.0, time.time()
|
||||
L.fetch_say = lambda en, ko: done.append(("say", en))
|
||||
L.answer = lambda text: done.append(("answer", text))
|
||||
done.clear()
|
||||
base["move_status"] = "running" if trip else "idle"
|
||||
return L
|
||||
|
||||
|
||||
def stopped(L):
|
||||
return "agv cancel" in done and "arm stop" in done and L.patrol is None and ("say", "Okay, I stopped.") in done
|
||||
|
||||
|
||||
# 15:10:13 "Let's go P5." -> patrol -> p5; then "Stop looming." / "Stop." / "Stop it." (no wake word): drove on
|
||||
for heard in ("Stop looming.", "Stop.", "Stop it.", "멈춰.", "스톱!", "그만.", "Stop, stop."):
|
||||
L = fresh(U(heard))
|
||||
assert L.check_wake() and stopped(L), (heard, done)
|
||||
|
||||
# 15:21:23 "Stop, 루미." on a drive: only "drive paused", then a base turn toward the voice and "drive on" later
|
||||
L = fresh(U("Stop, 루미."))
|
||||
assert L.check_wake() and stopped(L) and "TURN" not in done and "GO" not in done, done
|
||||
|
||||
# said while Lumi talks on the trip (clip mic, during_speech): a stop word still stops; other words are left alone
|
||||
L = fresh(U("Stop.", during_speech=True))
|
||||
assert L.check_wake() and stopped(L), done
|
||||
L = fresh(U("Lumi, go home.", during_speech=True))
|
||||
assert not L.check_wake() and "agv cancel" not in done, done
|
||||
|
||||
# a drive the dashboard or the base started (no trip of the assistant's own) is stopped too
|
||||
L = fresh(U("Stop."), trip=False)
|
||||
base["move_status"] = "running"
|
||||
assert L.check_wake() and "agv cancel" in done, done
|
||||
|
||||
# nothing moves: "stop it" between visitors is not answered; "Hi Lumi" on a drive still pauses and talks
|
||||
L = fresh(U("Stop it."), trip=False)
|
||||
assert not L.check_wake() and not done, done
|
||||
L = fresh(U("Hi Lumi."))
|
||||
assert L.check_wake() and "agv cancel" in done and L.patrol is not None and ("say", "Okay, I stopped.") not in done, done
|
||||
L = fresh(U("It stopped."))
|
||||
assert not L.check_wake() and "agv cancel" not in done, done
|
||||
|
||||
# one-word stop while Lumi talks (barge-in): "Stop." was a closing word (talk ended, the drive went on), "멈춰." ignored
|
||||
lumi.ears.understood = lambda *a: True
|
||||
for heard in ("Stop.", "멈춰.", "스탑", "Stop it."):
|
||||
L = fresh(U(heard, during_speech=True))
|
||||
assert L.barge_in() and "agv cancel" in done and "arm stop" in done and L.pending_text == heard, (heard, done)
|
||||
assert lumi.route(heard, M, L.brain)[0] == "stop", heard # answered next: stop_all
|
||||
L = fresh(U("I see.", during_speech=True))
|
||||
lumi.brain_mod.is_backchannel = lambda t: True
|
||||
L.barge_in()
|
||||
assert "agv cancel" not in done, done
|
||||
|
||||
|
||||
# "come here": the main loop waits on the drive; "stop" from anyone ends it, other words are answered after it
|
||||
class Track:
|
||||
id, distance, angle = 5, 3.0, 0.0
|
||||
|
||||
|
||||
class Vision:
|
||||
present = lambda self, t: True
|
||||
|
||||
|
||||
lumi.agv.pose = lambda: (0.0, 0.0, 0.0)
|
||||
lumi.head.status = lambda: [0, 0, 0, 0]
|
||||
lumi.nav.person_on_map = lambda *a: (3.0, 0.0)
|
||||
lumi.nav.approach = lambda *a: (2.0, 0.0, 0.0)
|
||||
L = fresh(U("Stop!"), trip=False)
|
||||
L.vision, L.modes, L.turn_head = Vision(), type("Modes", (), {"drive": True})(), lambda *a: None
|
||||
base["move_status"] = "running"
|
||||
t = time.time()
|
||||
L.come_to(Track())
|
||||
assert stopped(L) and time.time() - t < 3, done
|
||||
L = fresh(U("What is your name?"), trip=False)
|
||||
L.vision, L.modes, L.turn_head = Vision(), type("Modes", (), {"drive": True})(), lambda *a: None
|
||||
base["move_status"] = "running"
|
||||
threading.Timer(1.0, lambda: base.update(move_status="succeeded")).start()
|
||||
L.come_to(Track())
|
||||
assert "agv cancel" not in done and L.pending_text == "What is your name?", done
|
||||
|
||||
# right after Lumi said "Okay, I stopped.", "Stop." is no echo of it (own_echo counts "stop" in "stopped")
|
||||
lumi.mouth.recent_speech = lambda s: "Okay, I stopped. Let's go to p5."
|
||||
L = fresh(U("Stop."), trip=False)
|
||||
L.vision, L.modes, L.turn_head = Vision(), type("Modes", (), {"drive": True})(), lambda *a: None
|
||||
base["move_status"] = "running"
|
||||
L.come_to(Track())
|
||||
assert stopped(L), done
|
||||
head_u = U("Stop.")
|
||||
head_u.source = "head"
|
||||
lumi.ears.listen = lambda **k: ("Stop.", head_u)
|
||||
L = fresh(trip=False)
|
||||
L.warm_llm, L.interrupted, L.who_spoke, L.mission_hold = lambda: None, lambda: False, lambda u: None, None
|
||||
L.follow_filter = lambda text, u: False
|
||||
assert L.talk_turn() and ("answer", "Stop.") in done, done
|
||||
|
||||
# a stop word passes every echo filter: mouth.own_voice, own_echo, the ECHO_LIKELY gate (barge-in, talk_turn, check_wake)
|
||||
lumi.mouth.own_voice = lambda u: True
|
||||
lumi.mouth.last_echo = 0.9
|
||||
for heard in ("Stop.", "멈춰.", "Stop it."):
|
||||
L = fresh(U(heard, during_speech=True))
|
||||
assert L.barge_in() and "agv cancel" in done and L.pending_text == heard, (heard, done)
|
||||
L = fresh(U(heard, during_speech=True))
|
||||
assert L.check_wake() and stopped(L), (heard, done)
|
||||
L = fresh(trip=False)
|
||||
L.warm_llm, L.interrupted, L.who_spoke, L.mission_hold = lambda: None, lambda: False, lambda u: None, None
|
||||
L.follow_filter = lambda text, u: False
|
||||
assert L.talk_turn() and ("answer", "Stop.") in done, done
|
||||
L = fresh(U("Okay, I'm going to p5.", during_speech=True)) # Lumi's own sentence: still ignored
|
||||
assert not L.barge_in() and "agv cancel" not in done, done
|
||||
lumi.mouth.own_voice, lumi.mouth.last_echo = (lambda u: False), 0.0
|
||||
lumi.mouth.recent_speech = lambda s: ""
|
||||
|
||||
# whisper's slips of the stop words, and talk about stopping that orders nothing
|
||||
for t in ("스탑.", "Stob.", "Stopp!", "Lumi stopped.", "멈추세요.", "Stop looming.", "Stop, 루미."):
|
||||
assert lumi.stop_order(t, M), t
|
||||
for t in ("It stopped.", "The bus stop is there.", "Don't stop.", "계속 가.", "Why did you stopped?", "My laptop freezes."):
|
||||
assert not lumi.stop_order(t, M), t
|
||||
assert follow.stop_word("스탑")
|
||||
|
||||
print("ok")
|
||||
Reference in New Issue
Block a user