mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 06:54:28 +00:00
feat(video): add video transcripts (#559)
* feat(video): generate transcripts with the local embedding server * feat(video): show saved transcripts in the player * fix(video): preserve transcript seek timestamps * fix(video): refine transcript viewing and generation * feat(video): resize transcripts and follow playback earlier * fix(video): animate transcript playback scrolling * fix(video): transcribe from the smallest full proxy * fix(video): refine the sync to playback button * feat(video): edit transcript segment text inline * fix(video): keep transcript segment highlighted over edit button * docs(video): note embedding server version for transcripts
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { createTranscriptTimeline } from './transcript-timeline'
|
||||
|
||||
describe('createTranscriptTimeline', () => {
|
||||
it('uses inclusive starts and exclusive ends for adjacent segments and gaps', () => {
|
||||
const at = createTranscriptTimeline([
|
||||
{ id: 'later', startMs: 2000, endMs: 2500, text: '' },
|
||||
{ id: 'first', startMs: 300, endMs: 1000, text: '' },
|
||||
{ id: 'second', startMs: 1000, endMs: 1700, text: '' },
|
||||
])
|
||||
|
||||
expect(at(0)).toBeUndefined()
|
||||
expect(at(300)).toBe('first')
|
||||
expect(at(1000)).toBe('second')
|
||||
expect(at(1700)).toBeUndefined()
|
||||
expect(at(2000)).toBe('later')
|
||||
expect(at(2500)).toBeUndefined()
|
||||
})
|
||||
|
||||
it('finds the latest active start when a shorter segment overlaps a longer one', () => {
|
||||
const at = createTranscriptTimeline([
|
||||
{ id: 'long', startMs: 0, endMs: 4000, text: '' },
|
||||
{ id: 'short', startMs: 1050, endMs: 1120, text: '' },
|
||||
])
|
||||
|
||||
expect(at(1049.5)).toBe('long')
|
||||
expect(at(1050)).toBe('short')
|
||||
expect(at(1120)).toBe('long')
|
||||
expect(at(4000)).toBeUndefined()
|
||||
expect(createTranscriptTimeline([])(0)).toBeUndefined()
|
||||
})
|
||||
|
||||
it('uses the new segment at an exact millisecond after converting the seek through seconds', () => {
|
||||
const at = createTranscriptTimeline([
|
||||
{ id: 'before', startMs: 1800, endMs: 2010, text: '' },
|
||||
{ id: 'after', startMs: 2010, endMs: 2200, text: '' },
|
||||
])
|
||||
|
||||
expect(at(2009.999)).toBe('before')
|
||||
expect(at((2010 / 1000) * 1000)).toBe('after')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user