Enable reviewed Liam dances and add playback-driven voice status
This commit is contained in:
@@ -39,6 +39,25 @@ class AvatarCleanUiInstrumentation : Instrumentation() {
|
||||
val renderer=checkNotNull(currentRenderer())
|
||||
await { gear()!=null }
|
||||
assertClean()
|
||||
runOnMainSync {
|
||||
val indicator=VoiceStatusView(activity)
|
||||
indicator.animate=false
|
||||
val size=(36*activity.resources.displayMetrics.density).toInt()
|
||||
indicator.measure(View.MeasureSpec.makeMeasureSpec(size,View.MeasureSpec.EXACTLY),View.MeasureSpec.makeMeasureSpec(size,View.MeasureSpec.EXACTLY))
|
||||
indicator.layout(0,0,size,size)
|
||||
val bitmap=android.graphics.Bitmap.createBitmap(size,size,android.graphics.Bitmap.Config.ARGB_8888)
|
||||
val canvas=android.graphics.Canvas(bitmap)
|
||||
check(indicator.visibility==View.GONE)
|
||||
for(state in listOf(VoiceStatusView.State.LISTENING,VoiceStatusView.State.SPEAKING)) {
|
||||
indicator.state=state;indicator.speechLevel=.5f
|
||||
bitmap.eraseColor(android.graphics.Color.TRANSPARENT);indicator.draw(canvas)
|
||||
val pixels=IntArray(size*size);bitmap.getPixels(pixels,0,size,0,0,size,size)
|
||||
check(pixels.any { android.graphics.Color.alpha(it)>0 })
|
||||
check(indicator.visibility==View.VISIBLE && !indicator.contentDescription.isNullOrBlank())
|
||||
}
|
||||
indicator.state=VoiceStatusView.State.IDLE;check(indicator.visibility==View.GONE)
|
||||
bitmap.recycle()
|
||||
}
|
||||
val gear=checkNotNull(gear()); val bounds=android.graphics.Rect();gear.getBoundsInScreen(bounds)
|
||||
val minimum=(48*targetContext.resources.displayMetrics.density).toInt()-1
|
||||
check(bounds.width()>=minimum && bounds.height()>=minimum) { "Gear touch target below 48dp" }
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.gorios.lanvoice
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.graphics.RectF
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.sin
|
||||
|
||||
/** Overlay at TOP|END. No microphone permission or network access required. */
|
||||
class VoiceStatusView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null
|
||||
) : View(context, attrs) {
|
||||
enum class State { IDLE, LISTENING, SPEAKING }
|
||||
var state: State = State.IDLE
|
||||
set(value) {
|
||||
if (field == value) return
|
||||
field = value
|
||||
contentDescription = when (value) {
|
||||
State.IDLE -> ""
|
||||
State.LISTENING -> "数字角色聆听中"
|
||||
State.SPEAKING -> "数字角色正在说话"
|
||||
}
|
||||
visibility = if (value == State.IDLE) GONE else VISIBLE
|
||||
epoch = android.os.SystemClock.uptimeMillis()
|
||||
invalidate()
|
||||
}
|
||||
/** Supply normalized TTS playback amplitude [0..1] for synchronized speech bars. */
|
||||
var speechLevel: Float? = null
|
||||
set(value) { field = value?.takeIf { it.isFinite() }?.coerceIn(0f, 1f); invalidate() }
|
||||
var animate: Boolean = true
|
||||
set(value) { field = value; invalidate() }
|
||||
private val d = resources.displayMetrics.density
|
||||
private val p = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||
private var epoch = android.os.SystemClock.uptimeMillis()
|
||||
private val cyan = Color.rgb(130, 237, 224)
|
||||
private val violet = Color.rgb(203, 187, 255)
|
||||
init { visibility = GONE; importantForAccessibility = IMPORTANT_FOR_ACCESSIBILITY_YES }
|
||||
override fun onMeasure(w: Int, h: Int) {
|
||||
setMeasuredDimension(resolveSize((36*d).toInt(), w), resolveSize((36*d).toInt(), h))
|
||||
}
|
||||
override fun onDraw(c: Canvas) {
|
||||
super.onDraw(c)
|
||||
if (state == State.IDLE) return
|
||||
val save = c.save()
|
||||
c.scale(width / 36f, height / 36f)
|
||||
val t = if (animate) (android.os.SystemClock.uptimeMillis()-epoch)/1000f else 0f
|
||||
val accent = if (state == State.LISTENING) cyan else violet
|
||||
p.style = Paint.Style.STROKE
|
||||
p.color = accent; p.strokeWidth = 1.7f; p.strokeCap = Paint.Cap.ROUND
|
||||
if (state == State.LISTENING) {
|
||||
// Recognizable microphone; two gentle rings convey attentive listening.
|
||||
c.drawRoundRect(RectF(15f,9f,21f,20f),3f,3f,p)
|
||||
c.drawArc(RectF(12f,12f,24f,25f),0f,180f,false,p)
|
||||
c.drawLine(18f,25f,18f,28f,p); c.drawLine(15f,28f,21f,28f,p)
|
||||
for (i in 0..1) {
|
||||
val phase = (t/1.8f+i*.5f)%1f
|
||||
p.color = Color.argb(((1-phase)*65).toInt(),130,237,224)
|
||||
c.drawCircle(18f,18f,11f+phase*5f,p)
|
||||
}
|
||||
} else {
|
||||
p.style = Paint.Style.FILL; p.color = accent
|
||||
for (i in 0..4) {
|
||||
val wave = (.5f+.5f*sin(t*2*PI*1.2+i*1.35)).toFloat()
|
||||
val level = speechLevel
|
||||
val bar = if (level != null) 4f+18f*level*(.45f+.55f*wave) else 5f+17f*wave
|
||||
val x = 7.4f+i*4.6f
|
||||
c.drawRoundRect(RectF(x,18f-bar/2,x+2.8f,18f+bar/2),1.4f,1.4f,p)
|
||||
}
|
||||
}
|
||||
c.restoreToCount(save)
|
||||
if (animate && isAttachedToWindow && isShown && windowVisibility == VISIBLE) postInvalidateOnAnimation()
|
||||
}
|
||||
override fun onWindowVisibilityChanged(visibility: Int) {
|
||||
super.onWindowVisibilityChanged(visibility)
|
||||
if (visibility == VISIBLE) invalidate()
|
||||
}
|
||||
override fun onVisibilityChanged(changedView: View, visibility: Int) {
|
||||
super.onVisibilityChanged(changedView, visibility)
|
||||
if (visibility == VISIBLE) invalidate()
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ class AudioPlayback(
|
||||
private val onError: (generation: Long, error: Exception) -> Unit,
|
||||
private val onProgress: (turnId: Long, generation: Long, message: String) -> Unit = { _, _, _ -> },
|
||||
private val onActivity: (PlaybackActivity) -> Unit = {},
|
||||
private val onPlaying: (turnId: Long, generation: Long, playing: Boolean) -> Unit = { _, _, _ -> },
|
||||
) {
|
||||
private val lock = Object()
|
||||
private val queue = ArrayDeque<ByteArray>()
|
||||
@@ -33,6 +34,7 @@ class AudioPlayback(
|
||||
private val headCounter = PlaybackHead()
|
||||
private val activity = PcmActivityTimeline()
|
||||
private var audible = false
|
||||
private var playing = false
|
||||
|
||||
init {
|
||||
Thread(::play, "lan-voice-playback").apply { isDaemon = true; start() }
|
||||
@@ -93,6 +95,7 @@ class AudioPlayback(
|
||||
headCounter.reset()
|
||||
activity.reset()
|
||||
audible = false
|
||||
playing = false
|
||||
track?.let {
|
||||
try { it.pause(); it.flush() } catch (_: IllegalStateException) { }
|
||||
}
|
||||
@@ -142,6 +145,10 @@ class AudioPlayback(
|
||||
val head = headCounter.read(device.playbackHeadPosition)
|
||||
if (lastAdvanceMs == 0L || head != lastHead || writtenSamples <= head) lastAdvanceMs = now
|
||||
lastHead = head
|
||||
if(!playing && head > 0) {
|
||||
playing = true
|
||||
onPlaying(id,epoch,true)
|
||||
}
|
||||
val active = activity.sample(head, writtenSamples, now)
|
||||
if (active != audible) {
|
||||
audible = active
|
||||
@@ -235,6 +242,7 @@ class AudioPlayback(
|
||||
audible = false
|
||||
onActivity(PlaybackActivity(id, epoch, false, played, writtenSamples))
|
||||
}
|
||||
if(playing) { playing = false; onPlaying(id,epoch,false) }
|
||||
drained = true
|
||||
true
|
||||
} else false
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.gorios.lanvoice.expression.PresenceOutcome
|
||||
import com.gorios.lanvoice.expression.PresenceServerReason
|
||||
|
||||
enum class VoicePhase { IDLE, LISTENING, RECOGNIZING, THINKING, ANSWERING }
|
||||
enum class VoiceIndicatorState { IDLE, LISTENING, SPEAKING }
|
||||
|
||||
data class VoiceUiState(
|
||||
val connection: ConnectionStatus = ConnectionStatus.DISCONNECTED,
|
||||
@@ -38,7 +39,15 @@ data class VoiceUiState(
|
||||
val microphoneMuted: Boolean = false,
|
||||
val actionActive: Boolean = false,
|
||||
val turnId: Long? = null,
|
||||
val captureActive: Boolean = false,
|
||||
val playbackRunning: Boolean = false,
|
||||
) {
|
||||
val voiceIndicator: VoiceIndicatorState get() = when {
|
||||
!voiceActive || connection != ConnectionStatus.CONNECTED || actionActive -> VoiceIndicatorState.IDLE
|
||||
phase == VoicePhase.ANSWERING && playbackRunning -> VoiceIndicatorState.SPEAKING
|
||||
phase == VoicePhase.LISTENING && captureActive && !microphoneMuted -> VoiceIndicatorState.LISTENING
|
||||
else -> VoiceIndicatorState.IDLE
|
||||
}
|
||||
val roleLabel: String get() = when {
|
||||
phase == VoicePhase.ANSWERING && replyEmotion.turnId != null -> replyEmotion.label
|
||||
voiceActive && phase in setOf(VoicePhase.RECOGNIZING, VoicePhase.THINKING, VoicePhase.ANSWERING) -> "等待回复"
|
||||
@@ -106,6 +115,7 @@ class VoiceSession(
|
||||
private val actions = ActionController(reviewedActionPack, actionPlayer, SystemClock::elapsedRealtime,
|
||||
stopCapture = { confirmed ->
|
||||
captureEpoch++; capturing = false
|
||||
if(state.captureActive) update(state.copy(captureActive = false))
|
||||
diagnostic("action_capture state=stop_pending turn=$currentTurn epoch=$captureEpoch")
|
||||
capture.stopAndConfirm { stopped -> main.post {
|
||||
diagnostic("action_capture state=${if(stopped) "stop_confirmed" else "stop_failed"} turn=$currentTurn epoch=$captureEpoch")
|
||||
@@ -163,6 +173,14 @@ class VoiceSession(
|
||||
if(reason=="accepted") update(state.copy(playbackActivity = activity))
|
||||
}
|
||||
},
|
||||
onPlaying = { turn, epoch, playing ->
|
||||
main.post {
|
||||
if(isActive() && !actions.active && playbackIsCurrent(turn,epoch) &&
|
||||
currentTurn==turn && blockedTurn!=turn && emotionEndedTurn!=turn) {
|
||||
update(state.copy(playbackRunning = playing))
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
private val dialogue: DialogueClient = DialogueClient(
|
||||
host, port,
|
||||
@@ -516,6 +534,8 @@ class VoiceSession(
|
||||
onFrame = { pcm ->
|
||||
main.post {
|
||||
if (epoch == captureEpoch && captureTurn == currentTurn && capturing && isActive()) {
|
||||
// First real recorder frame, rather than a listen command or permission.
|
||||
if(!state.captureActive) update(state.copy(captureActive = true))
|
||||
if (dialogue.sendAudio(pcm, captureTurn, sequence)) {
|
||||
sequence = (sequence + 1) and UINT32_MASK
|
||||
}
|
||||
@@ -541,6 +561,7 @@ class VoiceSession(
|
||||
private fun stopCapture() {
|
||||
captureEpoch++
|
||||
capturing = false
|
||||
if(state.captureActive) update(state.copy(captureActive = false))
|
||||
capture.stop()
|
||||
}
|
||||
|
||||
@@ -769,7 +790,7 @@ class VoiceSession(
|
||||
val expression = state.replyEmotion
|
||||
val played = preparedPlaybackTurn == currentTurn && expression.turnId == currentTurn
|
||||
if (expression.turnId != null) diagnostic("role reset reason=$reason turn=${expression.turnId} played=$played")
|
||||
update(state.copy(replyEmotion = ReplyEmotion(), playbackActivity = null,
|
||||
update(state.copy(replyEmotion = ReplyEmotion(), playbackActivity = null, playbackRunning = false,
|
||||
previousReplyEmotion = if (played) expression else state.previousReplyEmotion))
|
||||
}
|
||||
|
||||
|
||||
@@ -43,10 +43,14 @@ private val NoUiAction: ()->Unit = {}
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
private fun CleanAvatarScaffold(avatar: @Composable ()->Unit,settings: @Composable ()->Unit,
|
||||
startupStage: String="ready",connecting: Boolean=false) {
|
||||
startupStage: String="ready",connecting: Boolean=false,
|
||||
voiceStatus: com.gorios.lanvoice.VoiceStatusView.State=com.gorios.lanvoice.VoiceStatusView.State.IDLE) {
|
||||
var settingsOpen by rememberSaveable { mutableStateOf(false) }
|
||||
Box(Modifier.fillMaxSize().background(Color.White).testTag("avatar_home")) {
|
||||
avatar()
|
||||
AndroidView(factory={com.gorios.lanvoice.VoiceStatusView(it)},update={it.state=voiceStatus},
|
||||
modifier=Modifier.align(Alignment.TopEnd).windowInsetsPadding(WindowInsets.safeDrawing)
|
||||
.padding(12.dp).size(36.dp).testTag("voice_status"))
|
||||
StartupStatus(startupStage,connecting,Modifier.align(Alignment.BottomStart)
|
||||
.windowInsetsPadding(WindowInsets.safeDrawing).padding(start=16.dp,end=88.dp,bottom=16.dp))
|
||||
IconButton(onClick={settingsOpen=true},modifier=Modifier.align(Alignment.BottomEnd)
|
||||
@@ -201,7 +205,8 @@ fun CallScreen(state: VoiceUiState,entry: EntryPhase,permissionMessage: String?,
|
||||
TextButton(onClick=onOfflinePreview) { Text("离线播放检查(停止当前会话)") }
|
||||
reportResult?.let { Text(it,fontSize=12.sp) }
|
||||
Text(logs.takeLast(10).joinToString("\n"),fontSize=11.sp)
|
||||
},startupStage=startupStage,connecting=BuildConfig.AVATAR_STARTUP_FIX && entry==EntryPhase.CONNECTING)
|
||||
},startupStage=startupStage,connecting=BuildConfig.AVATAR_STARTUP_FIX && entry==EntryPhase.CONNECTING,
|
||||
voiceStatus=com.gorios.lanvoice.VoiceStatusView.State.valueOf(state.voiceIndicator.name))
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
# Liam code38:联网舞蹈与语音状态
|
||||
|
||||
2026-10-14。基线 `5c4ea077ee64271dd07b63c6095f9d23215da405`。开始时 `git status --short` 无输出、`git stash list` 无输出:杨密 framing145 已提交,没有未提交内容需要 stash,本轮未创建、应用或删除 stash。已发布杨密 code37 保持不变。
|
||||
|
||||
## 构建与资产隔离
|
||||
|
||||
用户明确授权 `char-expressions-r02.networkActionsAllowed=true`,服务端已登记精确 pin `f8a69041da51e1a551c6991bfad6d7f034f0f320f726f58568afd43d81cb9604`。只读获取 live `reviewed_action_packs.json`,确认该 pin 的 `asset_01`、`asset_02` 均为8042ms;该文件 SHA256 为 `bb6889eca53b29be2546a89ab9458301b133045700ad4e6951ede27000590f8b`。没有修改或重启 gateway,也没有改 provider、时间、persona、音色、相机、presence 或素材。
|
||||
|
||||
Liam 使用独立 `app/build/characters/liam-test/`,显式选择 char-expression 媒体。真实 APK DEX 验证 persona=liam、联网动作=true、framing=1.0/centerY=0.5,杨密1.45倍构图未应用到 Liam。3190个 assets 和全部 poster 与 code36 逐字节一致,透明嘴层段继续保留原生表情,原 runtimeReady 字段不改。
|
||||
|
||||
## 语音标记
|
||||
|
||||
原生 Canvas 组件来自用户提供的 `/home/ubuntu/asset-inbox/voice-status-ui/`,仅修改 package 为 `com.gorios.lanvoice`。输入 `VoiceStatusView.kt` SHA256:`e61be06b9a953f023a4478f03f79d5b010669f98acaf6e6518ca860f1f2c9817`;README SHA256:`9d2fb86cf0efc69f5a5c62d15a8ab634bdc70cf9ce411b900042846683823040`。未引入图片、动画框架或新依赖。
|
||||
|
||||
`CallScreen.CleanAvatarScaffold` 在角色视频上方添加原生 View,Compose TopEnd 对齐,安全边距内12dp,尺寸36dp,透明底,不可点击。设置开合不重新创建角色 renderer。离线预览沿默认 IDLE 隐藏;主包后续构建可复用同一组件,本轮只交付 Liam APK。
|
||||
|
||||
- LISTENING:当前有效录音 epoch 收到首个真实 PCM 帧,且 session 已连接、处于聆听、未静音、无舞蹈。
|
||||
- SPEAKING:生产 `AudioPlayback` 首次看到当前 AudioTrack 播放头推进;收到 TTS start 或仅排队 PCM 不显示。自然结束在真实 native drain 后隐藏;句间短静音不闪回聆听。
|
||||
- IDLE:识别/生成、未实际收音、静音、舞蹈、离线、错误或后台。打断沿既有 pause/flush 与 turn/epoch fences 清掉 SPEAKING,有效录音仍在时回 LISTENING;录音需重启时等首个真实帧。
|
||||
|
||||
输入端只新增 UI 的 first-frame/stop 状态,输出端只新增首个 native head/真实 drain 观察回调;不改 PCM、采样率、TTS、嘴时钟、RMS/TALK gate、动作录音互斥和媒体释放流程。所有 UI 更新经原 main-thread session 处理,旧 turn/generation 回调不能复活标记。声波使用交付组件自带装饰动效,尚未接逐样本 speechLevel,不把动效幅度当作实际音量测量。
|
||||
|
||||
## 验证
|
||||
|
||||
| 检查 | 实际结果 |
|
||||
|---|---|
|
||||
| SDK 构建 | assembleDebug 与 compileDebugAndroidTestKotlin 通过;原生 Canvas 组件已真实编译 |
|
||||
| JVM/UI | 11入口通过;生产 VoiceSession 回放 first capture、生成、queued PCM、实际 head、drain、打断、静音、后台、旧 epoch、舞蹈门禁;AudioPlayback 验证 head=0不显示、head推进仅开始一次、短静音不结束、真实drain结束一次 |
|
||||
| UI 合同 | TopEnd/36dp/12dp、层级、默认隐藏和离线隐藏通过;首轮新增测试误把参数默认值查在函数 body,修正测试查找范围后通过,未因该测试改 App |
|
||||
| 包装 | 全量79项通过;实际DEX/manifest、appId/persona/pin/联网标志、默认framing、3190文件、poster、证书、ABI验证通过 |
|
||||
| GLES | 10个真实runtime ×40=400项离屏生产shader pixel golden通过;软件 EGL/2D surrogate,非手机 OES/GPU证明 |
|
||||
| 隔离握手 | 6组生产 Android AUTH→HELLO、8次 canonical ASGI WS通过;使用原 canonical 副本及此次只读获取的 registry,明确断言新pin ready/pending准入;Liam英语/服务端voice锁/fresh CID/busy释放通过;0 ASR/LLM/TTS调用 |
|
||||
| APK回放 | 实际包字节加载,happy/sad、idle/newturn、两dance分别从neutral/happy进入,4×193=772帧ACTION独占,媒体释放后returnA/completed;codec/Surface/music/录音为host doubles |
|
||||
| 启动 | cold main_asset_reads=0、patch_reads=2570;可信receipt patch_reads=0,同进程不重复读取;非手机计时 |
|
||||
| 未测 | instrumentation只编译未运行;未安装设备,真实手机UI位置/Canvas/GPU、音色听测及联网模型选择舞蹈未测 |
|
||||
|
||||
37个既有APK及sidecar重新核hash全部通过,包括杨密code37、Liam35/36、吕布与camera-probe。人物素材、APK、原始输入文件和日志不入Git,仅代码、测试、catalog及本文入Git。
|
||||
|
||||
## 产物与复现
|
||||
|
||||
| 字段 | 值 |
|
||||
|---|---|
|
||||
| APK | lan-voice-v0714-liam-test-code38-arm64-debug.apk |
|
||||
| URL | http://192.168.31.124:8080/lan-voice-v0714-liam-test-code38-arm64-debug.apk |
|
||||
| SHA256 | bfc5d86d9b885545591ef1412c85adca0b49005436a47eb94cb90c1ad4d53de1 |
|
||||
| 字节数 | 57,753,802 |
|
||||
| applicationId | com.gorios.lanvoice.liamtest |
|
||||
| versionName / code | 0.7.14-liam-test / 38 |
|
||||
| min / target / ABI | 26 / 34 / arm64-v8a |
|
||||
| debug证书SHA256 | b9608336bc1ed1de3269bb4594f9fe718daaa5439511c5187aa385d2b799dcf1 |
|
||||
|
||||
APK与同URL `.sha256` 的 HTTP 字节均已核验。重建示例,已发布同名产物不可覆盖:
|
||||
|
||||
```sh
|
||||
python3 scripts/package-character-test.py --profile liam-test --version-code 38 \
|
||||
--media-bundle char-expressions-r02 --build --output logs/liam-code38-rebuild.json
|
||||
```
|
||||
|
||||
协调者核SHA后USB升级独立 Liam 包;正常启动沿既有权限流程可能启麦克风/相机,先结束另一APK的会话。检查聆听标记、生成隐藏、真实播放标记、打断回聆听,再请求舞蹈观察标记隐藏与实际播放。独立 main/Lvbu 不受安装覆盖。回退保留的Liam code36需遵循Android debug降级限制,不自动卸载或清数据;code36原先的联网舞蹈关闭行为不被本轮改写。
|
||||
|
||||
本轮忽略证据位于 `logs/liam-code38/`,只读 canonical fixture 位于 `.runtime/liam-code38-canonical-gateway/`;均不入Git。生成费用及模型调用为零。
|
||||
@@ -66,14 +66,14 @@
|
||||
"assetRoot": "avatar/char-expressions-r02/",
|
||||
"indexSha256": "f8a69041da51e1a551c6991bfad6d7f034f0f320f726f58568afd43d81cb9604",
|
||||
"userAuthorizedDebug": true,
|
||||
"networkActionsAllowed": false,
|
||||
"networkActionsAllowed": true,
|
||||
"minimumVersionCode": 36,
|
||||
"bootstrapRoot": "avatar/startup-char-expressions-r02/",
|
||||
"bootstrapSha256": "ea615313caa5d9d79f7e28458d8f15f52a666a21fbd007c5f581cbe59dbab4a5",
|
||||
"bootstrapMetadata": "manifests/startup-char-expressions-r02.json",
|
||||
"resourceDirectory": "app/src/characterAssets/char-expressions-r02/res",
|
||||
"posterResource": "startup_char_expressions_r02_poster",
|
||||
"settingsNote": "Liam 英语人设与服务端绑定音色测试;char 多表情素材候选,联网舞蹈尚未登记。"
|
||||
"settingsNote": "Liam 英语人设与服务端绑定音色测试;char 多表情素材候选,联网舞蹈已授权登记,音乐听审与真机自然度待验。"
|
||||
}
|
||||
},
|
||||
"commonAssets": {
|
||||
|
||||
@@ -41,6 +41,10 @@ assert text(home).count('IconButton(')==1
|
||||
assert 'Alignment.BottomEnd' in text(home) and 'size(48.dp)' in text(home)
|
||||
assert 'WindowInsets.safeDrawing' in text(home)
|
||||
assert 'settingsOpen=true' in text(home)
|
||||
assert text(home).index('avatar()') < text(home).index('VoiceStatusView(it)')
|
||||
assert 'Alignment.TopEnd' in text(home) and '.padding(12.dp).size(36.dp)' in text(home)
|
||||
assert 'update={it.state=voiceStatus}' in text(home)
|
||||
assert 'voiceStatus: com.gorios.lanvoice.VoiceStatusView.State=com.gorios.lanvoice.VoiceStatusView.State.IDLE' in source
|
||||
no_calls(home,['Text','TextButton','Button','OutlinedButton','AvatarDiagnostics','ExpressionControls','settings'])
|
||||
assert 'rememberSaveable { mutableStateOf(false) }' in text(scaffold)
|
||||
assert text(sheet).count('settings()')==1 and text(sheet).count('settingsOpen=false')==2
|
||||
@@ -91,6 +95,8 @@ status=text(block('fun StartupStatus'))
|
||||
assert 'if(stage!="preparing" && !connecting) return' in status
|
||||
assert 'if(stage=="preparing")' in status and 'if(connecting)' in status
|
||||
assert 'end=88.dp' in text(home) and 'StartupStatus(' in text(home)
|
||||
assert 'VoiceStatusView.State.valueOf(state.voiceIndicator.name)' in text(block('fun CallScreen'))
|
||||
assert 'voiceStatus=' not in text(block('fun EngineeringPreviewScreen'))
|
||||
assert 'remember(mediaBinding) { StartupAvatarView' in source
|
||||
assert 'LaunchedEffect(resumed,restart,override,danceActive,pack)' in source
|
||||
assert 'if(!BuildConfig.AVATAR_STARTUP_FIX) avatarPack = AvatarPack.load(this)' in activity
|
||||
|
||||
@@ -20,10 +20,15 @@ parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--gateway-source',type=Path,default=ROOT/'gateway',
|
||||
help='Existing canonical source or read-only snapshot; never changes/deploys the gateway')
|
||||
parser.add_argument('--unreviewed-index-sha',default='',help='Also replay actual no-action Liam HELLO and ready/pending offers of this unregistered pin')
|
||||
parser.add_argument('--reviewed-index-sha',default='',help='Existing registered exact pin to offer in actual production HELLO; does not change the registry')
|
||||
args=parser.parse_args()
|
||||
if args.unreviewed_index_sha:
|
||||
import re
|
||||
assert re.fullmatch('[0-9a-f]{64}',args.unreviewed_index_sha)
|
||||
if args.reviewed_index_sha:
|
||||
import re
|
||||
assert re.fullmatch('[0-9a-f]{64}',args.reviewed_index_sha)
|
||||
assert args.reviewed_index_sha in json.loads((args.gateway_source/'reviewed_action_packs.json').read_text())
|
||||
gateway_root=args.gateway_source.resolve(strict=True)
|
||||
snapshot=gateway_root/'SNAPSHOT.json'
|
||||
if snapshot.exists():
|
||||
@@ -57,6 +62,7 @@ with tempfile.TemporaryDirectory(prefix='character-handshake-') as folder:
|
||||
hello_file=stage/'hello.jsonl'
|
||||
subprocess.run([ns['JAVA'],'-Dcharacter.helloFile='+str(hello_file),
|
||||
'-Dcharacter.unreviewedPin='+args.unreviewed_index_sha,
|
||||
'-Dcharacter.reviewedPin='+args.reviewed_index_sha,
|
||||
'-Dcharacter.personas='+','.join(personas),'-cp',
|
||||
str(stage/'classes')+':'+ns['cp'],'HandshakeCheckKt'],check=True,timeout=30)
|
||||
hellos=[json.loads(row) for row in hello_file.read_text().splitlines()]
|
||||
@@ -108,6 +114,9 @@ for hello in hellos:
|
||||
assert profile.call_count==(1 if persona=='default' else 0)
|
||||
assert ack['action_available']==bool(negotiate(hello,configured_packs()))
|
||||
assert ack['action_pending']==bool(pending_pin(hello,configured_packs()))
|
||||
if REVIEWED:
|
||||
assert ack['action_available']==('action_pack_sha256' in hello)
|
||||
assert ack['action_pending']==('action_pending_pack_sha256' in hello)
|
||||
if hello.get('action_pack_sha256')==UNREVIEWED or hello.get('action_pending_pack_sha256')==UNREVIEWED:
|
||||
assert not ack['action_available'] and not ack['action_pending']
|
||||
assert ack['conversation_id'] not in ids;ids.append(ack['conversation_id'])
|
||||
@@ -127,5 +136,5 @@ for persona in sorted({x['persona'] for x in hellos}-{'default'}):
|
||||
ws.receive_json();ids.append(ack['conversation_id'])
|
||||
assert state.busy is False
|
||||
print('PASS: '+str(len(ids))+' canonical ASGI WS handshakes from actual Android HELLO; personas='+','.join(sorted({x["persona"] for x in hellos}))+'; explicit persona ignores active_profile, server-locks voice/language, fresh CID, ready/pending exact pin and disconnect busy cleanup; 0 ASR/LLM/TTS calls, synthetic-only')
|
||||
'''.replace('UNREVIEWED',repr(args.unreviewed_index_sha))
|
||||
'''.replace('UNREVIEWED',repr(args.unreviewed_index_sha)).replace('REVIEWED',repr(args.reviewed_index_sha))
|
||||
subprocess.run([sys.executable,'-c',runner],cwd=stage,check=True,timeout=30)
|
||||
|
||||
@@ -20,7 +20,8 @@ private fun DialogueClient.listener(epoch: Long)=javaClass.getDeclaredMethod("li
|
||||
|
||||
fun main() {
|
||||
val wires=mutableListOf<String>()
|
||||
val pin="208f703ed92bf795bfeb78a1cef89b67bed2e45da80038a56157fd1ecd4cfa93"
|
||||
val pin=System.getProperty("character.reviewedPin","").ifEmpty { "208f703ed92bf795bfeb78a1cef89b67bed2e45da80038a56157fd1ecd4cfa93" }
|
||||
check(pin.matches(Regex("[0-9a-f]{64}")))
|
||||
val personas=System.getProperty("character.personas","default,lvbu,liam").split(",")
|
||||
check(personas.isNotEmpty() && personas.all { it in setOf("default","lvbu","liam") })
|
||||
for(persona in personas) for(pending in listOf(false,true)) {
|
||||
|
||||
@@ -160,11 +160,11 @@ class CharacterProfilesTests(unittest.TestCase):
|
||||
with Image.open(root/level['path']) as image:
|
||||
self.assertEqual(image.getchannel('A').getextrema(),(0,0))
|
||||
|
||||
def test_char_has_no_network_dance_authorization(self):
|
||||
def test_char_has_explicit_network_dance_authorization(self):
|
||||
spec=importlib.util.spec_from_file_location('char_pack',ROOT/'scripts/package-character-test.py')
|
||||
pack=importlib.util.module_from_spec(spec);spec.loader.exec_module(pack)
|
||||
flags=pack.flags('liam-test',36,'char-expressions-r02')
|
||||
self.assertIn('-PavatarUserNetworkActions=false',flags)
|
||||
flags=pack.flags('liam-test',38,'char-expressions-r02')
|
||||
self.assertIn('-PavatarUserNetworkActions=true',flags)
|
||||
self.assertIn('-PcharacterMediaBundle=char-expressions-r02',flags)
|
||||
self.assertFalse(select.catalog()['mediaBundles']['char-expressions-r02']['networkActionsAllowed'])
|
||||
self.assertTrue(select.catalog()['mediaBundles']['char-expressions-r02']['networkActionsAllowed'])
|
||||
self.assertIn('Network dance requires separate reviewed media registration',(ROOT/'app/build.gradle').read_text())
|
||||
|
||||
@@ -62,14 +62,18 @@ fun checkActualActivityPlayback() {
|
||||
val activities = CopyOnWriteArrayList<com.gorios.lanvoice.audio.PlaybackActivity>()
|
||||
val drains = CopyOnWriteArrayList<Long>()
|
||||
val errors = CopyOnWriteArrayList<Exception>()
|
||||
val player = AudioPlayback({ turn, _ -> drains.add(turn) }, { _, error -> errors.add(error) }, onActivity = activities::add)
|
||||
val playing = CopyOnWriteArrayList<Boolean>()
|
||||
val player = AudioPlayback({ turn, _ -> drains.add(turn) }, { _, error -> errors.add(error) }, onActivity = activities::add,
|
||||
onPlaying={turn,_,value->check(turn==70L);playing.add(value)})
|
||||
try {
|
||||
player.beginTurn(70); player.enqueue(DownlinkFrame(70,1,publicTone(960)))
|
||||
awaitCheck { AudioTrack.latest?.samples == 960 }
|
||||
check(activities.isEmpty())
|
||||
check(activities.isEmpty() && playing.isEmpty())
|
||||
AudioTrack.manualHead = 960
|
||||
awaitCheck { activities.lastOrNull()?.audible == true }
|
||||
check(playing==listOf(true))
|
||||
awaitCheck { activities.lastOrNull()?.audible == false } // software queue empty but TTS remains open
|
||||
check(playing==listOf(true))
|
||||
check(drains.isEmpty())
|
||||
player.enqueue(DownlinkFrame(70,2,ByteArray(1920)))
|
||||
awaitCheck { AudioTrack.latest?.samples == 1920 }
|
||||
@@ -83,10 +87,11 @@ fun checkActualActivityPlayback() {
|
||||
awaitCheck { activities.lastOrNull()?.audible == true }
|
||||
AudioTrack.manualHead = 2880
|
||||
awaitCheck { drains == listOf(70L) }
|
||||
check(playing==listOf(true,false))
|
||||
check(!activities.last().audible && errors.isEmpty())
|
||||
val count = activities.size
|
||||
player.interrupt(); Thread.sleep(30)
|
||||
check(activities.size == count)
|
||||
check(activities.size == count && playing==listOf(true,false))
|
||||
println("PASS: actual AudioPlayback head sampling continues during empty queue; queued PCM held silent, underrun idle, resumed speech talk, downlink end preserves buffered activity, drained/interrupt fences")
|
||||
} finally { player.release(); AudioTrack.manualHead = null }
|
||||
}
|
||||
|
||||
@@ -13,11 +13,12 @@ class AudioCapture {
|
||||
fun stop() {}
|
||||
fun release() {}
|
||||
}
|
||||
class AudioPlayback(onDrained: (Long, Long) -> Unit, onError: (Long, Exception) -> Unit, onProgress: (Long, Long, String) -> Unit = { _, _, _ -> }, onActivity: (PlaybackActivity) -> Unit = {}) {
|
||||
class AudioPlayback(onDrained: (Long, Long) -> Unit, onError: (Long, Exception) -> Unit, onProgress: (Long, Long, String) -> Unit = { _, _, _ -> }, onActivity: (PlaybackActivity) -> Unit = {}, onPlaying: (Long,Long,Boolean)->Unit={_,_,_->}) {
|
||||
companion object { var interrupts = 0; var enqueued = 0; var lastDrained: ((Long, Long) -> Unit)? = null
|
||||
var lastActivity: ((PlaybackActivity) -> Unit)? = null
|
||||
var lastPlaying: ((Long,Long,Boolean)->Unit)? = null
|
||||
var activityFence: ((Long,Long)->Boolean)? = null }
|
||||
init { lastDrained = onDrained; lastActivity = onActivity }
|
||||
init { lastDrained = onDrained; lastActivity = onActivity; lastPlaying = onPlaying }
|
||||
fun beginTurn(turn: Long) {}
|
||||
fun endTurn(turn: Long) {}
|
||||
fun enqueue(frame: DownlinkFrame): Boolean { enqueued++; return true }
|
||||
|
||||
@@ -84,4 +84,45 @@ fun checkCallControls() {
|
||||
}
|
||||
println("PASS: lvbu/liam background/permission pause disconnects actual session/client; late capture/playback/HELLO cannot revive it; default retention covered separately")
|
||||
println("PASS: real VoiceSession explicit start/duplicate dial, mute discards queued capture/keeps seq/no restart while answering, audio turn/generation/abort/hangup/late-frame fences")
|
||||
checkVoiceIndicator()
|
||||
}
|
||||
|
||||
private fun checkVoiceIndicator() {
|
||||
val states=mutableListOf<VoiceUiState>()
|
||||
val session=VoiceSession("localhost",5011,states::add,persona="liam",keepPermissionConnection=false)
|
||||
fun field(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)
|
||||
field("foreground",true);field("state",VoiceUiState(connection=ConnectionStatus.CONNECTED))
|
||||
val event=session.javaClass.getDeclaredMethod("onEvent",ServerEvent::class.java).apply { isAccessible=true }
|
||||
fun send(kind: EventKind,action: String,turn: Long=42)=event.invoke(session,ServerEvent(kind.name.lowercase(),kind,Payload(turn=turn,state=action)))
|
||||
val frame=session.javaClass.getDeclaredMethod("onFrame",DownlinkFrame::class.java).apply { isAccessible=true }
|
||||
fun status(expected: VoiceIndicatorState) { check(states.last().voiceIndicator==expected) }
|
||||
session.startVoice();send(EventKind.LISTEN,"start");status(VoiceIndicatorState.IDLE)
|
||||
checkNotNull(AudioCapture.lastFrame)(ByteArray(640));Handler.drain();status(VoiceIndicatorState.LISTENING)
|
||||
send(EventKind.LLM,"start");send(EventKind.TTS,"start");status(VoiceIndicatorState.IDLE)
|
||||
frame.invoke(session,DownlinkFrame(42));status(VoiceIndicatorState.IDLE) // queued PCM is not native playback
|
||||
val playing=checkNotNull(AudioPlayback.lastPlaying)
|
||||
AudioPlayback.activityFence={_,epoch->epoch==7L}
|
||||
playing(42,6,true);Handler.drain();status(VoiceIndicatorState.IDLE)
|
||||
playing(42,7,true);Handler.drain();status(VoiceIndicatorState.SPEAKING)
|
||||
checkNotNull(AudioPlayback.lastActivity)(PlaybackActivity(42,7,false,960,1920));Handler.drain()
|
||||
status(VoiceIndicatorState.SPEAKING) // silence between words does not blink into listening
|
||||
playing(42,7,false);checkNotNull(AudioPlayback.lastDrained)(42,7);Handler.drain()
|
||||
checkNotNull(AudioCapture.lastFrame)(ByteArray(640));Handler.drain();status(VoiceIndicatorState.LISTENING)
|
||||
send(EventKind.LISTEN,"start",43)
|
||||
checkNotNull(AudioCapture.lastFrame)(ByteArray(640));Handler.drain()
|
||||
frame.invoke(session,DownlinkFrame(43));playing(43,7,true);Handler.drain();status(VoiceIndicatorState.SPEAKING)
|
||||
session.interrupt();status(VoiceIndicatorState.LISTENING)
|
||||
playing(43,7,true);Handler.drain();status(VoiceIndicatorState.LISTENING) // blocked old turn
|
||||
session.setMicrophoneMuted(true);status(VoiceIndicatorState.IDLE)
|
||||
session.setMicrophoneMuted(false);status(VoiceIndicatorState.IDLE)
|
||||
val lateCapture=checkNotNull(AudioCapture.lastFrame)
|
||||
lateCapture(ByteArray(640));session.background();playing(42,7,true);Handler.drain();status(VoiceIndicatorState.IDLE)
|
||||
check(!states.last().captureActive && !states.last().playbackRunning && socket.cancelled)
|
||||
val active=VoiceUiState(connection=ConnectionStatus.CONNECTED,voiceActive=true,phase=VoicePhase.ANSWERING,playbackRunning=true,captureActive=true)
|
||||
check(active.copy(actionActive=true).voiceIndicator==VoiceIndicatorState.IDLE)
|
||||
check(active.copy(connection=ConnectionStatus.DISCONNECTED).voiceIndicator==VoiceIndicatorState.IDLE)
|
||||
session.release();AudioPlayback.activityFence=null
|
||||
println("PASS: production VoiceSession indicator replay: first capture→LISTENING, generating/queued PCM→IDLE, actual head→SPEAKING, drain/interrupt→LISTENING, mute/action/background/old epoch→IDLE or ignored; device=false")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user