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:
2026-10-23 16:59:30 +09:00
co-authored by Claude Opus 5.5
parent 6177e5eef3
commit 6f2113c15a
11 changed files with 470 additions and 37 deletions
+53 -8
View File
@@ -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__":
+8
View File
@@ -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?
+2 -2
View File
@@ -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
View File
@@ -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))
+7
View File
@@ -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)", "고개"),