Refactor wake phrase handling: introduce REQUIRE_WAKE_WORD configuration, update documentation, and adjust assistant behavior for improved user experience.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
"""Test runs use the stock wake phrases, not whatever a developer happens to
|
||||
have in the project's `.env`. The speech tests are written against the
|
||||
defaults; a local `WAKE_WORDS=...` that narrows them would fail the suite for
|
||||
a reason that isn't in the code. Environment variables set by the shell still
|
||||
win, and everything else in `.env` is left alone."""
|
||||
|
||||
import os
|
||||
|
||||
os.environ.setdefault("WAKE_WORDS", (
|
||||
"hey bolt,bolt,thunderbolt,hey thunderbolt,ok bolt,okay bolt,yo bolt,hi bolt,"
|
||||
"hey assistant,ok assistant,okay assistant,"
|
||||
"hey bolts,hey volt,hey bold,hey boat,okay volt,hey thunder bolt,thunder bolt"
|
||||
))
|
||||
os.environ.setdefault("ANYWHERE_WAKE_WORDS", "assistant")
|
||||
+19
-3
@@ -177,15 +177,31 @@ def spoken(played):
|
||||
def _config(monkeypatch):
|
||||
monkeypatch.setattr(config, "STREAMING_REPLIES", False)
|
||||
monkeypatch.setattr(config, "VAD_RMS_THRESHOLD", 500)
|
||||
monkeypatch.setattr(config, "REQUIRE_WAKE_WORD", False)
|
||||
FakeTranscription.script = []
|
||||
|
||||
|
||||
def test_ignores_speech_without_the_wake_phrase():
|
||||
a, asked, played, logs, _ = make([])
|
||||
def test_ignores_speech_without_the_wake_phrase_when_required():
|
||||
a, asked, played, logs, _ = make([], wake_required=True)
|
||||
say(a, "so anyway I was telling him about the bolt")
|
||||
assert asked == [] and played == []
|
||||
|
||||
|
||||
def test_speech_without_a_wake_phrase_is_a_request_by_default():
|
||||
a, asked, played, logs, _ = make(["It's three o'clock."])
|
||||
say(a, "what time is it?")
|
||||
assert asked[0].startswith("what time is it?\n\n[Bolt Assistant: a voice-only assistant")
|
||||
assert "It's three o'clock." in spoken(played)
|
||||
assert a.state == "idle"
|
||||
|
||||
|
||||
def test_the_banner_says_which_mode_is_on():
|
||||
a, _, _, _, _ = make([])
|
||||
assert "anything you say" in a.listening_banner()
|
||||
required, _, _, _, _ = make([], wake_required=True)
|
||||
assert "Hey Bolt" in required.listening_banner()
|
||||
|
||||
|
||||
def test_wake_phrase_and_request_in_one_breath():
|
||||
a, asked, played, logs, _ = make(["It's three o'clock."])
|
||||
say(a, "Hey Bolt, what time is it?")
|
||||
@@ -205,7 +221,7 @@ def test_bare_wake_phrase_chimes_then_takes_the_next_utterance():
|
||||
|
||||
|
||||
def test_the_command_window_closes():
|
||||
a, asked, played, logs, clock = make([])
|
||||
a, asked, played, logs, clock = make([], wake_required=True)
|
||||
say(a, "Thunderbolt")
|
||||
clock.t += config.COMMAND_WAIT_SEC + 5
|
||||
say(a, "so then we left")
|
||||
|
||||
Reference in New Issue
Block a user