feat: refine role expression and diagnose camera context in 0.5.2
This commit is contained in:
@@ -25,5 +25,13 @@ fun main() {
|
||||
check(result.cue == if(t==800L) FaceCue.BROW_FURROWED else FaceCue.UNKNOWN)
|
||||
}
|
||||
checkUnknown(obs=face(.1f,.4f),t=900)
|
||||
check(rules.evaluate(null,0,false,1000).reason == FaceCueReason.NO_FACE)
|
||||
check(rules.evaluate(face(),2,true,1100).reason == FaceCueReason.MULTIPLE_FACES)
|
||||
check(rules.evaluate(face(),1,false,1200).reason == FaceCueReason.POOR_QUALITY)
|
||||
check(rules.evaluate(face(.1f,.1f),1,true,1300).reason == FaceCueReason.NO_CLEAR_CUE)
|
||||
check(rules.evaluate(face(.9f,.9f),1,true,1400).reason == FaceCueReason.CONFLICT)
|
||||
check(rules.evaluate(face(),1,true,1500).reason == FaceCueReason.STABILIZING)
|
||||
check(rules.evaluate(face(Float.NaN),1,true,1600).reason == FaceCueReason.INVALID_COEFFICIENTS)
|
||||
check(rules.evaluate(FaceObservation(emptyMap(),null),1,true,1700).reason == FaceCueReason.MISSING_COEFFICIENTS)
|
||||
println("PASS: sustained bilateral cues, hysteresis, conflict/multiple/no face/poor quality/invalid score/stale reset; no gaze/eye emotion inference")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import com.gorios.lanvoice.expression.*
|
||||
|
||||
fun main() {
|
||||
val camera = CameraAnalysisDiagnostics()
|
||||
check(camera.snapshot().reason == FaceCueReason.NO_FRAME)
|
||||
var summaries = 0
|
||||
for (time in 0L..600_000L step 100) {
|
||||
camera.received()
|
||||
camera.processed(0, FaceCueObservation(reason = FaceCueReason.NO_FACE), 8)
|
||||
if (camera.summary(time) != null) summaries++
|
||||
}
|
||||
check(summaries == 61) // 10Hz samples, <=1 summary/10s including first.
|
||||
check(camera.snapshot().received == 6001 && camera.snapshot().processed == 6001)
|
||||
check(camera.snapshot().faceCount == 0 && camera.snapshot().reason == FaceCueReason.NO_FACE)
|
||||
camera.processed(1, FaceCueObservation(FaceCue.SMILING, .9f, 900, 0, FaceCueReason.STABLE), 12)
|
||||
camera.failed(CameraFailure.ANALYSIS)
|
||||
check(camera.snapshot().cue == FaceCue.SMILING && camera.snapshot().failures == 1)
|
||||
check(camera.summary(600_001) == null)
|
||||
val final = checkNotNull(camera.summary(600_001, force = true))
|
||||
check("failure=analysis" in final && "cue=smiling" in final)
|
||||
check(listOf("landmark", "blendshape", "image", "prompt", "reply").none { it in final })
|
||||
val send = FaceTransmissionDiagnostics()
|
||||
check(send.snapshot().reason == FaceSendReason.SHARING_OFF)
|
||||
send.record(FaceSendReason.NO_STABLE_CUE)
|
||||
check(send.snapshot().attempts == 0)
|
||||
send.record(FaceSendReason.SENT, FaceCue.SMILING)
|
||||
send.record(FaceSendReason.CLEARED)
|
||||
send.record(FaceSendReason.SEND_FAILED)
|
||||
send.record(FaceSendReason.STALE)
|
||||
check(send.snapshot().attempts == 3 && send.snapshot().sent == 1 && send.snapshot().clears == 1 && send.snapshot().failures == 1)
|
||||
check(send.summary(0) != null && send.summary(9999) == null && send.summary(10000) != null)
|
||||
println("PASS: enum-only camera/frame/send snapshots, failure counters, 10s rate bound, no-face/stable/stale/clear accounting")
|
||||
}
|
||||
@@ -481,6 +481,7 @@ fun runChecks() {
|
||||
}
|
||||
|
||||
fun main() {
|
||||
checkFaceTransmission()
|
||||
run {
|
||||
val normal = com.gorios.lanvoice.dialogue.ReplyEmotion.fromWire(2L, 1L, "neutral", 0, "model")!!
|
||||
val fallback = com.gorios.lanvoice.dialogue.ReplyEmotion.fromWire(2L, 1L, "neutral", 0, "fallback", "invalid_intensity")!!
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import android.os.SystemClock
|
||||
import com.gorios.lanvoice.audio.*
|
||||
import com.gorios.lanvoice.expression.*
|
||||
import com.gorios.lanvoice.net.*
|
||||
|
||||
fun checkFaceTransmission() {
|
||||
val session=VoiceSession("localhost",5011,{})
|
||||
fun set(name: String, value: Any) { session.javaClass.getDeclaredField(name).apply { isAccessible=true }.set(session,value) }
|
||||
val dialogue=session.javaClass.getDeclaredField("dialogue").apply { isAccessible=true }.get(session) as DialogueClient
|
||||
val socket=FakeSocket()
|
||||
dialogue.setField("socket",socket);dialogue.setField("ready",true)
|
||||
fun tick() { session.javaClass.getDeclaredMethod("sendFaceContext").apply { isAccessible=true }.invoke(session) }
|
||||
set("foreground",true);set("faceSupported",true);set("hasTurn",true);set("currentTurn",7L)
|
||||
set("state",VoiceUiState(connection=ConnectionStatus.CONNECTED,voiceActive=true,phase=VoicePhase.LISTENING))
|
||||
session.setFaceSharing(true)
|
||||
tick()
|
||||
check(session.faceDiagnosticsSnapshot().reason == FaceSendReason.NO_STABLE_CUE && socket.sent.isEmpty())
|
||||
session.observeFace(FaceCueObservation(reason=FaceCueReason.NO_FACE));tick()
|
||||
check(session.faceDiagnosticsSnapshot().reason == FaceSendReason.NO_FACE)
|
||||
val stable=FaceCueObservation(FaceCue.SMILING,.9f,900,SystemClock.elapsedRealtime(),FaceCueReason.STABLE)
|
||||
session.observeFace(stable);tick()
|
||||
check(session.faceDiagnosticsSnapshot().sent==1)
|
||||
session.observeFace(stable.copy(observedAtMs=SystemClock.elapsedRealtime()-4000));tick()
|
||||
check(session.faceDiagnosticsSnapshot().reason==FaceSendReason.STALE && session.faceDiagnosticsSnapshot().clears==1)
|
||||
val count=socket.sent.size;tick();check(socket.sent.size==count) // clear only once, retain stale reason.
|
||||
session.observeFace(stable.copy(observedAtMs=SystemClock.elapsedRealtime()));socket.acceptSend=false;tick()
|
||||
check(session.faceDiagnosticsSnapshot().reason==FaceSendReason.SEND_FAILED)
|
||||
socket.acceptSend=true;tick();session.setFaceSharing(false)
|
||||
check(session.faceDiagnosticsSnapshot().reason==FaceSendReason.SHARING_OFF)
|
||||
check(session.faceDiagnosticsSnapshot().clears==2)
|
||||
session.setFaceSharing(true)
|
||||
set("foreground",false);tick();check(session.faceDiagnosticsSnapshot().reason==FaceSendReason.BACKGROUND)
|
||||
set("foreground",true);set("state",VoiceUiState(connection=ConnectionStatus.DISCONNECTED));tick()
|
||||
check(session.faceDiagnosticsSnapshot().reason==FaceSendReason.NOT_CONNECTED)
|
||||
session.setFaceSharing(false);dialogue.release()
|
||||
println("PASS: real coordinator face sharing/no-face/stable-send/failure/TTL one-shot clear/background/disconnect; transport doubles")
|
||||
}
|
||||
Reference in New Issue
Block a user