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:
@@ -1,5 +1,4 @@
|
||||
import type { AssetInfo } from '@shumai/dtos'
|
||||
import type { ShareLinkInfo } from '@shumai/dtos'
|
||||
import { selectTranscriptVideoProxyKey, type AssetInfo, type ShareLinkInfo } from '@shumai/dtos'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import {
|
||||
ContextMenuContent,
|
||||
@@ -27,6 +26,7 @@ import {
|
||||
Copy,
|
||||
Layers,
|
||||
ScanSearch,
|
||||
Captions,
|
||||
} from 'lucide-react'
|
||||
import { CopyContextMenuSub } from './copy-submenu'
|
||||
import { isImageItem, type CopyKind } from './copy-options'
|
||||
@@ -40,6 +40,7 @@ interface FileBrowserContextMenuProps {
|
||||
onDownload: (items: AssetInfo[]) => void
|
||||
onCopy?: (kind: CopyKind, items: AssetInfo[]) => void
|
||||
onFindSimilar?: (item: AssetInfo) => void
|
||||
onGenerateTranscripts?: (assetId: string, name: string) => void
|
||||
onRestore: (items: AssetInfo[]) => void
|
||||
onArchive?: (items: AssetInfo[]) => void
|
||||
onRestoreArchive?: (items: AssetInfo[]) => void
|
||||
@@ -75,6 +76,7 @@ export function FileBrowserContextMenu({
|
||||
onDownload,
|
||||
onCopy,
|
||||
onFindSimilar,
|
||||
onGenerateTranscripts,
|
||||
onRestore,
|
||||
onArchive,
|
||||
onRestoreArchive,
|
||||
@@ -237,6 +239,18 @@ export function FileBrowserContextMenu({
|
||||
</ContextMenuItem>
|
||||
)
|
||||
|
||||
const videoVersion =
|
||||
item.type === 'version_stack'
|
||||
? item.versionStack?.versions.find((version) => version.current)
|
||||
: undefined
|
||||
const transcriptAssetId = item.type === 'file' ? item.id : videoVersion?.id
|
||||
const transcriptAssetStatus = videoVersion?.status ?? item.status
|
||||
const isTranscriptVideo = item.proxyType
|
||||
? item.proxyType === 'video'
|
||||
: item.mediaType?.startsWith('video/')
|
||||
const transcriptReady =
|
||||
transcriptAssetStatus === 'processed' && Boolean(selectTranscriptVideoProxyKey(item.media))
|
||||
|
||||
const contextMenuContent =
|
||||
isItemSelected && selectedIds.size > 1 ? (
|
||||
<ContextMenuContent
|
||||
@@ -360,6 +374,21 @@ export function FileBrowserContextMenu({
|
||||
<span>{m.download()}</span>
|
||||
</ContextMenuItem>
|
||||
{findSimilarItem}
|
||||
{canEdit &&
|
||||
onGenerateTranscripts &&
|
||||
transcriptAssetId &&
|
||||
['uploading', 'uploaded', 'processing', 'processed'].includes(transcriptAssetStatus) &&
|
||||
isTranscriptVideo && (
|
||||
<ContextMenuItem
|
||||
disabled={!transcriptReady}
|
||||
onSelect={() =>
|
||||
onGenerateTranscripts(transcriptAssetId, videoVersion?.name || item.name)
|
||||
}
|
||||
>
|
||||
<Captions className="mr-2 h-4 w-4" />
|
||||
<span>{m.generate_transcripts()}</span>
|
||||
</ContextMenuItem>
|
||||
)}
|
||||
<CopyContextMenuSub
|
||||
items={itemsToModify}
|
||||
context={{
|
||||
|
||||
Reference in New Issue
Block a user