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:
@@ -31,6 +31,15 @@ describe('FileBrowserContextMenu', () => {
|
||||
updatedAt: '2026-01-01T00:00:00Z',
|
||||
} as AssetInfo
|
||||
|
||||
const fullProxy = {
|
||||
id: 'proxy-480p',
|
||||
url: '/video-480p.mp4',
|
||||
key: 'video-480p.mp4',
|
||||
width: 854,
|
||||
height: 480,
|
||||
size: 100,
|
||||
}
|
||||
|
||||
const renderWithMenu = (
|
||||
item: AssetInfo,
|
||||
props: Partial<React.ComponentProps<typeof FileBrowserContextMenu>> = {},
|
||||
@@ -87,6 +96,71 @@ describe('FileBrowserContextMenu', () => {
|
||||
expect(screen.queryByRole('menuitem', { name: 'Open in new tab' })).toBeNull()
|
||||
})
|
||||
|
||||
it('starts transcription on the displayed video file in a stack', () => {
|
||||
const onGenerateTranscripts = vi.fn()
|
||||
renderWithMenu(
|
||||
{
|
||||
...stackItem,
|
||||
proxyType: 'video',
|
||||
media: { videoTranscodes: [fullProxy] },
|
||||
versionStack: {
|
||||
id: stackItem.id,
|
||||
versions: [
|
||||
{ id: 'old', name: 'old.mp4', version: 1, current: false },
|
||||
{ id: 'current', name: 'current.mp4', version: 2, current: true },
|
||||
],
|
||||
},
|
||||
},
|
||||
{ onGenerateTranscripts },
|
||||
)
|
||||
|
||||
fireEvent.contextMenu(screen.getByTestId('context-trigger'))
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: 'Generate Transcripts' }))
|
||||
|
||||
expect(onGenerateTranscripts).toHaveBeenCalledWith('current', 'current.mp4')
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ status: 'uploaded', media: undefined },
|
||||
{ status: 'processing', media: { videoTranscodes: [fullProxy] } },
|
||||
{ status: 'processed', media: { videoPreview: { url: '/preview.mp4', key: 'preview.mp4' } } },
|
||||
])('disables generation for a $status video until a full proxy is ready', ({ status, media }) => {
|
||||
const onGenerateTranscripts = vi.fn()
|
||||
renderWithMenu(
|
||||
{ ...fileItem, mediaType: 'video/mp4', status, media },
|
||||
{ onGenerateTranscripts },
|
||||
)
|
||||
|
||||
fireEvent.contextMenu(screen.getByTestId('context-trigger'))
|
||||
const action = screen.getByRole('menuitem', { name: 'Generate Transcripts' })
|
||||
expect(action.getAttribute('aria-disabled')).toBe('true')
|
||||
fireEvent.click(action)
|
||||
expect(onGenerateTranscripts).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it.each([
|
||||
{
|
||||
label: 'a read-only member',
|
||||
item: { ...fileItem, proxyType: 'video' as const },
|
||||
canEdit: false,
|
||||
},
|
||||
{ label: 'a non-video asset', item: fileItem, canEdit: true },
|
||||
{
|
||||
label: 'an audio-only upload with a video MIME type',
|
||||
item: { ...fileItem, proxyType: 'audio' as const, mediaType: 'video/mp4' },
|
||||
canEdit: true,
|
||||
},
|
||||
{
|
||||
label: 'an archived video',
|
||||
item: { ...fileItem, proxyType: 'video' as const, status: 'archived' },
|
||||
canEdit: true,
|
||||
},
|
||||
])('hides the action for $label', ({ item, canEdit }) => {
|
||||
renderWithMenu(item, { canEdit, onGenerateTranscripts: vi.fn() })
|
||||
fireEvent.contextMenu(screen.getByTestId('context-trigger'))
|
||||
expect(screen.queryByRole('menuitem', { name: 'Generate Transcripts' })).toBeNull()
|
||||
})
|
||||
|
||||
it('renders Manage versions for version_stack item when canEdit is true', () => {
|
||||
const onManageVersions = vi.fn()
|
||||
renderWithMenu(stackItem, { onManageVersions })
|
||||
|
||||
Reference in New Issue
Block a user