Files
baji-vc/tests/avatar/EmotionActionCheck.kt
T

39 lines
3.1 KiB
Kotlin

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,
"width" to 480,"height" to 848,"fpsNumerator" to 24,"fpsDenominator" to 1,"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,
"fromPtsUs" to 4_000_000L,"toPtsUs" to 0L,"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",
"sourcePackageId" to "neutral","sourceFrame" to 96,"sourcePtsUs" to 4_000_000L,
"returnPackageId" to "neutral","returnFrame" to 0,"returnPtsUs" to 0L,
"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")
}