feat: add single-call action protocol and Android stage interfaces
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import com.gorios.lanvoice.avatar.*
|
||||
import com.gorios.lanvoice.dialogue.RoleEmotion
|
||||
|
||||
fun actionCheck() {
|
||||
val sha="a".repeat(64)
|
||||
val statuses=mutableListOf<ActionStatus>()
|
||||
var now=100L; var confirm: ((Boolean)->Unit)?=null
|
||||
var playing=false;var finish: ((ActionEnd)->Unit)?=null
|
||||
var release: (()->Unit)?=null
|
||||
val picked=mutableListOf<String>()
|
||||
val player=object: ActionPlayer {
|
||||
override fun play(asset: ActionAsset, finished: (ActionEnd)->Unit, failed: ()->Unit) {
|
||||
check(!playing);playing=true;picked.add(asset.id);finish=finished
|
||||
}
|
||||
override fun stop(released: ()->Unit) { release={ playing=false;released() } }
|
||||
}
|
||||
val pack=ReviewedActionPack(sha,listOf(ActionAsset("asset_01",1000),ActionAsset("asset_02",1200)))
|
||||
val controller=ActionController(pack,player,{now},{confirm=it},{statuses.add(it)},choose={0})
|
||||
fun plan(turn: Long)=ActionPlan("id".repeat(12)+turn,turn,sha,10000)
|
||||
check(controller.offer(plan(1)))
|
||||
check(controller.active && !playing && statuses.isEmpty()) // Intent is not recording-stop evidence.
|
||||
confirm!!(true);check(playing && statuses.single().status=="started")
|
||||
now+=1000;playing=false;finish!!(ActionEnd(true,true,true))
|
||||
check(!controller.active && statuses.last().status=="completed")
|
||||
check(controller.offer(plan(2)));confirm!!(true)
|
||||
check(picked==listOf("asset_01","asset_02"))
|
||||
val stale=finish!!
|
||||
controller.cancel();check(controller.active) // No recording resume before music release fence.
|
||||
check(statuses.last().status=="started")
|
||||
release!!();check(!controller.active && statuses.last().status=="cancelled")
|
||||
stale(ActionEnd(true,true,true));check(statuses.last().status=="cancelled")
|
||||
check(controller.offer(plan(3)));confirm!!(false);release!!()
|
||||
check(statuses.last().status=="failed" && picked.size==2)
|
||||
check(controller.offer(plan(4)));confirm!!(true)
|
||||
now+=10001;controller.tick();release!!();check(statuses.last().status=="failed")
|
||||
val missing=ActionController(null,player,{now},{confirm=it},{statuses.add(it)})
|
||||
check(missing.capability==null && !missing.offer(plan(5)))
|
||||
|
||||
val pts=List(97) { it*1_000_000L/24 }
|
||||
val neutral=TalkPackage("neutral",RoleEmotion.NEUTRAL,sha,sha,pts,pts,true)
|
||||
val happy=TalkPackage("happy",RoleEmotion.HAPPY,"b".repeat(64),"b".repeat(64),pts,pts,true)
|
||||
val slight=RoleVisualSelector.select(RoleEmotion.HAPPY,2,listOf(neutral,happy),"neutral")
|
||||
check(slight.selectedIntensity==2 && slight.visualIntensity==1 && slight.reason=="slight_only")
|
||||
val mismatch=RoleVisualSelector.select(RoleEmotion.HAPPY,1,listOf(neutral,happy.copy(mouthBodySha=sha)),"neutral")
|
||||
check(mismatch.selectedEmotion==RoleEmotion.HAPPY && mismatch.visualEmotion==RoleEmotion.NEUTRAL && mismatch.degraded)
|
||||
val shifted=RoleVisualSelector.select(RoleEmotion.HAPPY,1,listOf(neutral,happy.copy(mouthPtsUs=pts.map { it+1 })),"neutral")
|
||||
check(shifted.packageId=="neutral")
|
||||
println("PASS: action fixture record-stop/music-release/return-A/TTL/cancel/stale/no-repeat and expression own-body/PTS/slight-only selection; no device/naturalness claim")
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import android.media.MediaPlayer
|
||||
import android.view.TextureView
|
||||
|
||||
fun main() {
|
||||
actionCheck()
|
||||
emotionActionCheck()
|
||||
checkContinuous()
|
||||
checkEngineering()
|
||||
checkSafeDriver()
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import com.gorios.lanvoice.avatar.*
|
||||
|
||||
fun emotionActionCheck() {
|
||||
val sha="b".repeat(64)
|
||||
val runtime=continuousPack().let { old -> old.copy(apertureMode=true,patches=old.patches.map { patch ->
|
||||
patch.copy(levels=List(5) { MouthPatchLevel(it,it/4f,"patches/${patch.frameIndex}-$it.png",sha) })
|
||||
}) }
|
||||
fun clip(audio: Boolean)=mapOf<String,Any?>("path" to "clips/bridge.mp4","sha256" to sha,"hasAudio" to audio,
|
||||
"frameCount" to 48,"ptsUs" to List(48) { it*1_000_000L/24 },"durationUs" to 2_000_000L)
|
||||
fun edge(id: String,from: String,to: String)=mapOf<String,Any?>("id" to id,"from" to from,"to" to to,
|
||||
"fromAnchor" to "A","toAnchor" to "A","fromFrame" to 96,"toFrame" to 0,"clip" to clip(false))
|
||||
fun conversation(id: String)=mapOf<String,Any?>("id" to id,"emotion" to if(id=="neutral") "neutral" else "happy",
|
||||
"visualIntensity" to if(id=="neutral") 0 else 1,"mouthBodySha256" to sha,
|
||||
"runtimeManifest" to mapOf("path" to "$id/manifest.json","sha256" to sha),"entryAnchor" to "A","exitAnchor" to "A",
|
||||
"legalExitFrames" to listOf(96),"loopEdge" to "$id-loop")
|
||||
val edges=listOf(edge("neutral-loop","neutral","neutral"),edge("happy-loop","happy","happy"),
|
||||
edge("in","neutral","happy"),edge("out","happy","neutral"))
|
||||
val actions=listOf("asset_01","asset_02").map { mapOf<String,Any?>("id" to it,"kind" to "dance",
|
||||
"mouthAllowed" to false,"disallowTALK" to true,"entryAnchor" to "A","returnAnchor" to "A",
|
||||
"clip" to clip(true),"audioEndUs" to 1_900_000L) }
|
||||
val root=mapOf<String,Any?>("schemaVersion" to 2,"identityId" to "a01","packId" to "a01-expression-action-v1",
|
||||
"fallbackPackageId" to "neutral","conversationPackages" to listOf(conversation("neutral"),conversation("happy")),
|
||||
"edges" to edges,"actions" to actions)
|
||||
fun read(data: Map<String,Any?>,pin: String=sha)=EmotionActionManifest.read(data,sha,pin) { _,hash -> if(hash==sha) runtime else null }
|
||||
check(read(root)?.actionPack?.assets?.size==2)
|
||||
check(read(root+("actions" to emptyList<Any>()))?.actionPack==null)
|
||||
check(read(root,"a".repeat(64))==null)
|
||||
check(read(root+("approved" to true),"")==null)
|
||||
check(read(root+("conversationPackages" to listOf(conversation("neutral"),conversation("happy")+("mouthBodySha256" to "a".repeat(64)))))==null)
|
||||
check(read(root+("edges" to edges.dropLast(1)))==null)
|
||||
for(change in listOf(mapOf("mouthAllowed" to true),mapOf("disallowTALK" to false),mapOf("returnAnchor" to "B"),
|
||||
mapOf("audioEndUs" to 2_000_001L),mapOf("clip" to clip(false)),mapOf("clip" to clip(true)+("path" to "../escape.mp4")))) {
|
||||
check(read(root+("actions" to listOf(actions[0]+change,actions[1])))==null)
|
||||
}
|
||||
println("PASS: production v2 index exact external pin/own body-mouth SHA/runtime04/complete bridges/music bounds/no TALK, synthetic metadata only")
|
||||
}
|
||||
Reference in New Issue
Block a user