feat: answer calls in the voice channel through the response policy
- conversation.rs: the loop between the core's events and the rest. Finals go through call detection and the response policy; answers are asked of the brain and spoken from the app's queue, an interruption cancels only that answer, a voice stop silences everything, and missed requests are kept without text (last 100). Tested with a fake voice side. - Core: answer(user, text) adopts a playback request the worker speaks under the same id, cancel(id) stops one request, ask_addressed and ask_rank pass the conversation's questions; new SpeakingStopped, Addressed and Ranked events. - Worker client: reply, addressed and rank messages and their results; a reply with no answer, refused or not sent ends its speech as failed. - Voice worker: addressed and rank messages on their own threads, beside a running reply; a spoken reply cancelled while the brain is answering is not spoken. judges.py holds the two short LLM judgements with the heard text fenced as data; eval evals/test_voice_judges.py. - Specs (conversation, discord core, voice worker), docs/llm_contexts.md and the roadmap updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -105,6 +105,46 @@ async fn audio_and_tts_round_trip_through_the_python_server() {
|
||||
.await
|
||||
.expect("speech end");
|
||||
assert_eq!((end.played, end.cancelled, end.failed), (2, false, false));
|
||||
|
||||
// A spoken brain answer plays under the adopted id, like a TTS request.
|
||||
let id = p.adopt();
|
||||
assert!(c.reply(&id, 42, "자비스 안녕", true));
|
||||
let end = tokio::time::timeout(Duration::from_secs(5), async {
|
||||
loop {
|
||||
match rx.recv().await.unwrap() {
|
||||
WorkerEvent::TtsAudio { id, seq, pcm } => {
|
||||
p.audio(&id, seq, pcm);
|
||||
p.clip_ended();
|
||||
}
|
||||
WorkerEvent::TtsDone(d) => p.done(&d),
|
||||
_ => {}
|
||||
}
|
||||
if let Some(PlaybackEvent::End(e)) = p.take_events().into_iter().find(|e| matches!(e, PlaybackEvent::End(_))) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
})
|
||||
.await
|
||||
.expect("answer end");
|
||||
assert_eq!((end.id.as_str(), end.played, end.failed), (id.as_str(), 2, false));
|
||||
|
||||
// The two judgements come back under their ids.
|
||||
assert!(c.addressed("q1", 42, "불 켜 줘"));
|
||||
assert!(c.rank("k1", &[("1".into(), 42, "a".into()), ("2".into(), 43, "b".into())]));
|
||||
let (mut addressed, mut ranked) = (None, None);
|
||||
tokio::time::timeout(Duration::from_secs(5), async {
|
||||
while addressed.is_none() || ranked.is_none() {
|
||||
match rx.recv().await.unwrap() {
|
||||
WorkerEvent::Addressed { id, addressed: a } => addressed = Some((id, a)),
|
||||
WorkerEvent::Ranked { id, order } => ranked = Some((id, order)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
})
|
||||
.await
|
||||
.expect("judgements");
|
||||
assert_eq!(addressed, Some(("q1".to_string(), true)));
|
||||
assert_eq!(ranked, Some(("k1".to_string(), vec!["2".to_string(), "1".to_string()])));
|
||||
c.close();
|
||||
let _ = child.kill().await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user