fix(app): a wake word said alone waits for what the speaker says next
A pause after the name ("자비스, ... 지금 몇 시야?") is longer than the
worker's 300 ms end silence, so the wake word ended its own utterance:
Jarvis answered the bare name and ignored the question that followed (no
wake word). Found on real Discord. A voice utterance that is only a wake
word is now joined to the same speaker's next final when that utterance
is running or starts within call.followUpMs (default 1500); otherwise the
wake word alone is the request after that time. Stops drop it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
//! matching works on Unicode-normalised letters, so it behaves the same in any script.
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::time::Duration;
|
||||
|
||||
use unicode_normalization::UnicodeNormalization;
|
||||
|
||||
@@ -27,6 +28,9 @@ pub struct CallSettings {
|
||||
pub designated_only: bool,
|
||||
pub designated_no_wake_word: bool,
|
||||
pub stop_words: Vec<String>,
|
||||
/// After a wake word said alone, how long the speaker's next utterance may take to start and
|
||||
/// still be joined to it (the pause after "Jarvis," often ends an utterance).
|
||||
pub follow_up: Duration,
|
||||
}
|
||||
|
||||
impl Default for CallSettings {
|
||||
@@ -39,6 +43,7 @@ impl Default for CallSettings {
|
||||
designated_only: false,
|
||||
designated_no_wake_word: false,
|
||||
stop_words: ["멈춰", "그만", "정지", "stop"].map(String::from).to_vec(),
|
||||
follow_up: Duration::from_millis(1500),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,6 +127,11 @@ impl CallSettings {
|
||||
})
|
||||
}
|
||||
|
||||
/// A wake word is heard and nothing else (no letters or digits around it).
|
||||
pub fn wake_word_only(&self, text: &str) -> bool {
|
||||
self.without_wake_word(&normalise(text)).is_some_and(|rest| rest.is_empty())
|
||||
}
|
||||
|
||||
/// Decide what to do with one finished utterance.
|
||||
pub fn judge(&self, speaker: u64, text: &str) -> Call {
|
||||
let norm = normalise(text);
|
||||
@@ -160,6 +170,16 @@ mod tests {
|
||||
CallSettings::default()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_wake_word_with_nothing_else_is_told_apart() {
|
||||
let c = s();
|
||||
assert!(c.wake_word_only("자비스,"));
|
||||
assert!(c.wake_word_only("자비즈?"));
|
||||
assert!(!c.wake_word_only("자비스, 지금 몇 시야?"));
|
||||
assert!(!c.wake_word_only("서비스"));
|
||||
assert!(!c.wake_word_only(""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exact_and_near_wake_words_call_but_a_different_word_does_not() {
|
||||
let c = s();
|
||||
|
||||
Reference in New Issue
Block a user