fix: 修复语音消息取错、时长精度与转写不刷新

- 时长解析:改取 <voicemsg voicelength>(毫秒),不再误取 length(SILK 字节数)
- 时长显示:四舍五入对齐微信口径,有原生时长时不被解码时长覆盖
- 转写:重新识别改为强制重算,跳过身份级缓存短路(音频级缓存仍生效)
- 日报:语音累计秒数显示取整,不再出现小数
This commit is contained in:
Wxw-Gu
2026-09-20 15:40:01 +08:00
parent 9b82d29037
commit 9593ca0f54
21 changed files with 435 additions and 52 deletions
@@ -101,6 +101,49 @@ describe('VoiceRecognitionUseCase transcript updates', () => {
await useCase.dispose()
})
it('forwards force to the pipeline so manual re-recognition can bypass the identity cache', async () => {
const useCase = createUseCase()
const state = useCase as unknown as {
pipeline: { run: ReturnType<typeof vi.fn> }
}
state.pipeline.run.mockResolvedValue({
transcript: '重新识别的文字',
durationMs: 900,
cached: false
})
const reference = { sessionId: 'fixture-contact', localId: 12, createTime: 1_785_895_203 }
const result = await useCase.recognize(reference, { force: true })
expect(result).toMatchObject({ success: true, transcript: '重新识别的文字' })
expect(state.pipeline.run).toHaveBeenCalledWith(
'account-a',
reference,
expect.anything(),
{ force: true }
)
await useCase.dispose()
})
it('leaves force undefined when the caller does not ask for a recompute', async () => {
const useCase = createUseCase()
const state = useCase as unknown as {
pipeline: { run: ReturnType<typeof vi.fn> }
}
state.pipeline.run.mockResolvedValue({ transcript: '缓存文字', durationMs: 900, cached: true })
const reference = { sessionId: 'fixture-contact', localId: 13, createTime: 1_785_895_204 }
await useCase.recognize(reference)
expect(state.pipeline.run).toHaveBeenCalledWith(
'account-a',
reference,
expect.anything(),
{ force: undefined }
)
await useCase.dispose()
})
it('publishes an explicit cached transcript for a coalesced export index refresh', async () => {
const useCase = createUseCase()
const listener = vi.fn().mockResolvedValue(undefined)