feat: 完善群聊日报语音转写缓存

支持空内容的微信语音消息并兼容历史缓存转写结果
将系统通知标记为微信系统消息,排除活跃成员与发言排行
This commit is contained in:
Wxw-Gu
2026-08-11 11:08:55 +08:00
parent 68f0c0b5a3
commit 6192e7cd35
16 changed files with 240 additions and 42 deletions
@@ -74,6 +74,20 @@ describe('daily report voice transcription', () => {
})
})
it('normalizes legacy voice messages without contentData for report facts', async () => {
const legacy = { ...voice('legacy', 4), contentData: undefined }
const result = await transcribeVoiceMessages([legacy], {
getModelStatus: vi.fn(async () => status('ready')),
recognize: vi.fn(async () => ({ success: true, transcript: '日报语音内容' })),
onProgress: vi.fn()
})
expect(result[0]).toMatchObject({
voiceTranscript: '日报语音内容',
contentData: { type: 'voice' }
})
})
it('does not require the model when every transcript is cached', async () => {
const getModelStatus = vi.fn(async () => status('missing'))
const recognize = vi.fn()
@@ -88,6 +102,26 @@ describe('daily report voice transcription', () => {
expect(recognize).not.toHaveBeenCalled()
})
it('hydrates persisted transcript cache before invoking recognition', async () => {
const getModelStatus = vi.fn(async () => status('missing'))
const getCachedTranscript = vi.fn(async () => ({
state: 'transcribed' as const,
transcript: '持久化缓存内容'
}))
const recognize = vi.fn()
const result = await transcribeVoiceMessages([voice('persisted', 8)], {
getModelStatus,
getCachedTranscript,
recognize,
onProgress: vi.fn()
})
expect(result[0].voiceTranscript).toBe('持久化缓存内容')
expect(getCachedTranscript).toHaveBeenCalledOnce()
expect(getModelStatus).not.toHaveBeenCalled()
expect(recognize).not.toHaveBeenCalled()
})
it('stops before recognition when the local model is not ready', async () => {
const recognize = vi.fn()
await expect(