Hearing: no false wakes from whisper's prompt, own-voice filter only while Lumi talks, Korean retry with a Korean prompt, f16 whisper model, ASR bench
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+92
-3
@@ -13,6 +13,13 @@ for q, words in {"How tall is Son Heung-min?": "height Son Heung-min", "How long
|
||||
"오늘 달러 환율 얼마야?": "오늘 달러 환율 얼마야?"}.items():
|
||||
assert web.keywords(q) == words, (q, web.keywords(q))
|
||||
|
||||
# English questions about a person, a share, an index, a team, a place also ask Naver with the Korean word of its box
|
||||
for q, box in {"How old is Taylor Swift?": "Taylor Swift 나이", "What is Nvidia's stock price today?": "Nvidia 주가",
|
||||
"What's the Nasdaq doing today?": "Nasdaq 지수", "How did LAFC do in their last match?": "LAFC 경기 결과",
|
||||
"What time does Lotte World open?": "Lotte World 영업시간", "Who is the pope?": None,
|
||||
"손흥민 나이": None}.items():
|
||||
assert web.ko_box_query(q) == box, (q, web.ko_box_query(q))
|
||||
|
||||
# a Naver page: answer box and web result kept, ad / influencer blocks and the page furniture left out
|
||||
PAGE = ('<html><div class="_scrollLog"><section class="sc_new cs_nexchangerate"><b>미국 USD</b> 1,328.40 원 '
|
||||
'새 창 열림 전일대비 상승 5.10</section></div>'
|
||||
@@ -35,7 +42,8 @@ web._news = lambda q, lang, n=4: "- headline"
|
||||
web._duckduckgo = lambda q: "DDG: 330 m"
|
||||
web.online = lambda: True
|
||||
out = web.search("How tall is the Eiffel Tower?")
|
||||
assert "Naver: 330 m" in out and "lattice tower" in out and "headline" in out, out
|
||||
assert "Naver: 330 m" in out and "lattice tower" in out and "headline" not in out, out # news only for what changes
|
||||
assert "headline" in web.search("Who is the president of France now?")
|
||||
web._naver = lambda q: ""
|
||||
assert "DDG: 330 m" in web.search("height of the Lotte World Tower")
|
||||
web._naver = web._wikipedia = web._duckduckgo = web._news = lambda *a: ""
|
||||
@@ -66,6 +74,37 @@ b.history, b.last_lookup = [("손흥민 지금 어느 팀이야?", "LAFC 소속
|
||||
assert b.search_query("몇 살이야?") == "손흥민 지금 어느 팀이야? 몇 살이야"
|
||||
assert b.search_query("에펠탑 높이는 얼마나 되나요 정확하게?") == "에펠탑 높이는 얼마나 되나요 정확하게?"
|
||||
|
||||
# the weather: now and the days ahead, today and tomorrow named
|
||||
web._get = lambda url, timeout=6, headers=web.UA: (
|
||||
'{"current": {"temperature_2m": 10.4, "weather_code": 0, "wind_speed_10m": 9.8}, "daily": {"time": ["2026-10-21", '
|
||||
'"2026-10-22", "2026-10-23"], "weather_code": [61, 0, 3], "temperature_2m_max": [15.2, 14.4, 17.8], '
|
||||
'"temperature_2m_min": [7.6, 4.5, 7.0], "precipitation_probability_max": [92, 0, 2]}}')
|
||||
w = web.weather("Seoul")
|
||||
assert w.startswith("Weather in Seoul now: clear sky, 10 degrees, wind 10 km/h.") and \
|
||||
"Tomorrow (Thursday 22 October): clear sky, 4 to 14 degrees, chance of rain 0 percent." in w and \
|
||||
"\nFriday 23 October: overcast" in w, w
|
||||
|
||||
# "how far": the straight-line distance of the two places (one named: from Seoul); a small namesake is not taken
|
||||
import re
|
||||
web.PLACES["busan"] = {"name": "Busan", "latitude": 35.18, "longitude": 129.08, "population": 3400000}
|
||||
assert re.search(r"Seoul to Busan: about 3\d\d km", web._distance("부산까지 거리가 얼마나 돼?"))
|
||||
assert re.search(r"Busan to Seoul: about 3\d\d km", web._distance("How far is Busan from Seoul by car?"))
|
||||
web._get = lambda url, timeout=6, headers=web.UA: '{"results": [{"name": "Moon-sur-Elle", "latitude": 49.2, ' \
|
||||
'"longitude": -1.0, "population": 700}]}'
|
||||
assert web._distance("How far away is the moon?") == "" and web._distance("How tall is the Eiffel Tower?") == ""
|
||||
|
||||
assert "Busan to Seoul" in web._distance("Busan distance from Seoul")
|
||||
|
||||
# respond_from: an action line the model writes instead of the answer is never said; all of it: asked once more
|
||||
outs = iter([["search New York", " weather"], ["It is 15 degrees", " in New York."]])
|
||||
real_stream, brain._stream = brain._stream, lambda m: iter(next(outs))
|
||||
assert list(brain.Brain().respond_from("What's the weather in New York?", "15 degrees")) == ["It is 15 degrees in New York."]
|
||||
outs = iter([["search NY weather\n", "It is 15 degrees. Clear."]])
|
||||
assert list(brain.Brain().respond_from("Weather?", "x")) == ["It is 15 degrees.", "Clear."]
|
||||
outs = iter([["Search results say 330 m."]])
|
||||
assert list(brain.Brain().respond_from("Eiffel?", "x")) == ["Search results say 330 m."]
|
||||
brain._stream = real_stream
|
||||
|
||||
# ages worked out from birth dates in the results; money questions get rates, others do not
|
||||
assert web.with_ages("Han Kang (born 27 November 1970)", datetime.date(2026, 10, 20)) == \
|
||||
"Han Kang (born 27 November 1970 (55 years old today))"
|
||||
@@ -78,10 +117,60 @@ web._get = lambda url, timeout=6, headers=web.UA: \
|
||||
assert "1 Japanese yen = 8.87 Korean won (100 yen = 887 won)" in web._money("엔화 환율 알려줘")
|
||||
assert "1 US dollar = 1,330.00 Korean won" in web._money("What's the dollar to won exchange rate?")
|
||||
assert web._money("How tall is the Eiffel Tower?") == ""
|
||||
assert "100 US dollar = 133,000 Korean won" in web._money("How much is 100 dollars in Korean won?")
|
||||
assert "10,000 Japanese yen = 88,667 Korean won" in web._money("1만 엔은 한국 돈으로 얼마야?")
|
||||
# a person's private details are never looked up; a place's phone number or a player's club are
|
||||
for t in ("What's the phone number of Kim Min-jun?", "Where does my coworker Park Ji-hoon live?",
|
||||
"What is Son Heung-min's home address?", "옆집 사람 전화번호 찾아줘"):
|
||||
"What is Son Heung-min's home address?", "옆집 사람 전화번호 찾아줘",
|
||||
"What's my coworker Lee Seo-yeon's salary?", "옆자리 김지훈 씨 연봉 얼마야?"):
|
||||
assert lumi.private_ask(t), t
|
||||
for t in ("What's the phone number of the Louvre?", "Where does Son Heung-min play?", "How tall is Son Heung-min?"):
|
||||
for t in ("What's the phone number of the Louvre?", "손흥민 연봉 얼마야?", "Where does Son Heung-min play?", "How tall is Son Heung-min?"):
|
||||
assert not lumi.private_ask(t), t
|
||||
# lumi.look_up on the free search: "Let me check." first, the answer made while it plays (never OpenAI, no speaker)
|
||||
import threading
|
||||
import time
|
||||
from audio import mouth
|
||||
lumi.log = lambda msg: None
|
||||
web.openai_ready = lambda: False
|
||||
events = []
|
||||
|
||||
|
||||
def fake_say_stream(pieces, lang=None, abort=None):
|
||||
"""Like mouth.say_stream: a thread pulls the pieces while the ones before play (0.3 s each)."""
|
||||
import queue
|
||||
q, said = queue.Queue(), []
|
||||
|
||||
def pull():
|
||||
for p in pieces:
|
||||
events.append(("say", p, time.time()))
|
||||
q.put(p)
|
||||
q.put(None)
|
||||
threading.Thread(target=pull, daemon=True).start()
|
||||
while (p := q.get()) is not None:
|
||||
said.append(p)
|
||||
threading.Event().wait(0.3)
|
||||
return " ".join(said)
|
||||
|
||||
|
||||
class FakeBrain:
|
||||
def respond_from(self, asked, facts):
|
||||
events.append(("llm", asked, time.time()))
|
||||
yield "It is 330 metres tall, with the antennas on top."
|
||||
|
||||
|
||||
mouth.say_stream = fake_say_stream
|
||||
mouth.say = lambda *a, **k: (_ for _ in ()).throw(AssertionError("say() on the free path"))
|
||||
web.search = lambda target: "Eiffel Tower: 330 m"
|
||||
L = object.__new__(lumi.Lumi)
|
||||
L.lang, L.brain, L.speak_abort, L.current = "en", FakeBrain(), lambda: False, None
|
||||
L.look_up("How tall is the Eiffel Tower?", "search", "Eiffel Tower height")
|
||||
assert [e[1] for e in events] == ["Let me check.", "How tall is the Eiffel Tower?", "It is 330 metres tall,",
|
||||
"with the antennas on top."], events
|
||||
assert events[1][2] - events[0][2] < 0.1, events # the answer is asked for while "Let me check." plays
|
||||
web.weather, events[:] = (lambda target: "Weather in Seoul now: clear sky"), []
|
||||
L.look_up("내일 비 와?", "weather", "")
|
||||
assert events[1][1] == "내일 비 와? (the weather)", events
|
||||
web.search, events[:] = (lambda target: None), []
|
||||
L.look_up("Who won?", "search", "winner")
|
||||
assert [e[1] for e in events][1].startswith("Sorry, I'm not connected"), events
|
||||
print("web ok")
|
||||
|
||||
Reference in New Issue
Block a user