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:
@@ -7,6 +7,7 @@ import { FileViewer } from '@/ui/components/file-viewer'
|
||||
import { FileViewerLeftSidebar } from '@/ui/components/file-viewer-left-sidebar'
|
||||
import { FileViewerRightSidebar } from '@/ui/components/file-viewer-right-sidebar'
|
||||
import { MobileFileDetail } from '@/ui/components/file-viewer/mobile-file-detail'
|
||||
import { ResizableTranscriptPanel } from '@/ui/components/file-viewer/resizable-transcript-panel'
|
||||
import { FileDetailSkeleton } from '@/ui/components/loading-skeletons'
|
||||
import { ResizeHandle } from '@/ui/components/resize-handle'
|
||||
import { ShareLinkCreatedDialog } from '@/ui/components/share-link-created-dialog'
|
||||
@@ -14,6 +15,7 @@ import { useArchiveConfig } from '@/ui/hooks/use-archive-config'
|
||||
import { useIsMobile } from '@/ui/hooks/use-mobile'
|
||||
import { usePermissions } from '@/ui/hooks/use-permissions'
|
||||
import { useShareLinkActions } from '@/ui/hooks/use-share-link-actions'
|
||||
import { useVideoTranscript } from '@/ui/hooks/use-video-transcript'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { useAnnotationStore } from '@/ui/stores/annotation-store'
|
||||
import { useChatbotStore } from '@/ui/stores/chatbot'
|
||||
@@ -81,6 +83,7 @@ function FileViewPage() {
|
||||
} = useShareLinkActions({ projectId, enabled: canEdit })
|
||||
const { teamId, ensureTeamIdForProject } = useTeamContextStore()
|
||||
const [rightSidebarWidth, setRightSidebarWidth] = useState(360)
|
||||
const [transcriptWidthPercent, setTranscriptWidthPercent] = useState(30)
|
||||
const [annotations, setAnnotations] = useState<Annotation[]>([])
|
||||
const { fileViewRightSidebarCollapsed } = useUiStore()
|
||||
const { isChatbotOpen } = useChatbotStore()
|
||||
@@ -211,6 +214,9 @@ function FileViewPage() {
|
||||
const isError = isStackError || (!!versionAssetId && isVersionError)
|
||||
const isFetching = isStackFetching || (!!versionAssetId && isVersionFetching)
|
||||
const fileData = versionData || stackData
|
||||
const transcript = useVideoTranscript(
|
||||
!isMobile && !isCompareMode && fileData?.id === activeFileId ? fileData : undefined,
|
||||
)
|
||||
const versionsDataList = versionAssetId ? versionsList : stackData?.versionStack?.versions
|
||||
|
||||
const parentFolderId = fileData?.ancestorFolders?.[0]?.id ?? projectInfo?.rootFolder ?? ''
|
||||
@@ -817,7 +823,7 @@ function FileViewPage() {
|
||||
return (
|
||||
<div className="h-full flex flex-1 flex-col bg-background">
|
||||
<div className="h-full flex flex-1 overflow-hidden">
|
||||
<div className="flex-1 relative">
|
||||
<div className="relative min-w-0 flex-1">
|
||||
{isFetching && !isCompareMode && (
|
||||
<div className="absolute inset-0 z-10 flex items-center justify-center bg-background/50">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-foreground" />
|
||||
@@ -851,15 +857,28 @@ function FileViewPage() {
|
||||
onSeek={handleSeek}
|
||||
annotations={annotations}
|
||||
startTime={startTime}
|
||||
transcriptToggle={transcript?.toggle}
|
||||
>
|
||||
<FileViewerLeftSidebar
|
||||
projectId={projectId}
|
||||
currentAssetId={activeFileId}
|
||||
parentFolderId={parentFolderId}
|
||||
initialFiles={carouselState.files}
|
||||
initialNextCursor={carouselState.nextCursor}
|
||||
isLoading={isCarouselLoading}
|
||||
/>
|
||||
{transcript?.panel && (
|
||||
<ResizableTranscriptPanel
|
||||
key={transcript.panel.assetId}
|
||||
{...transcript.panel}
|
||||
canEdit={canEdit}
|
||||
mediaControllerRef={mediaControllerRef}
|
||||
widthPercent={transcriptWidthPercent}
|
||||
setWidthPercent={setTranscriptWidthPercent}
|
||||
/>
|
||||
)}
|
||||
<div className={transcript?.panel ? 'hidden' : 'contents'}>
|
||||
<FileViewerLeftSidebar
|
||||
projectId={projectId}
|
||||
currentAssetId={activeFileId}
|
||||
parentFolderId={parentFolderId}
|
||||
initialFiles={carouselState.files}
|
||||
initialNextCursor={carouselState.nextCursor}
|
||||
isLoading={isCarouselLoading}
|
||||
/>
|
||||
</div>
|
||||
</FileViewer>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user