transcript-viewer
elevenlabs/transcript-viewerFreeComponent
shadcn/ui publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/elevenlabs/ui/main/apps/www/public/r/transcript-viewer.jsonSource
1"use client"23import {4 createContext,5 useContext,6 useMemo,7 type ComponentPropsWithoutRef,8 type ComponentPropsWithRef,9 type HTMLAttributes,10 type ReactNode,11} from "react"12import type { CharacterAlignmentResponseModel } from "@elevenlabs/elevenlabs-js/api/types/CharacterAlignmentResponseModel"13import { Pause, Play } from "lucide-react"1415import { cn } from "@/lib/utils"16import {17 useTranscriptViewer,18 type SegmentComposer,19 type TranscriptSegment,20 type TranscriptWord as TranscriptWordType,21 type UseTranscriptViewerResult,22} from "@/registry/elevenlabs-ui/hooks/use-transcript-viewer"23import { Button } from "@/components/ui/button"24import {25 ScrubBarContainer,26 ScrubBarProgress,27 ScrubBarThumb,28 ScrubBarTimeLabel,29 ScrubBarTrack,30} from "@/components/ui/scrub-bar"3132type TranscriptGap = Extract<TranscriptSegment, { kind: "gap" }>3334type TranscriptViewerContextValue = UseTranscriptViewerResult & {35 audioProps: Omit<ComponentPropsWithRef<"audio">, "children" | "src">36}3738const TranscriptViewerContext =39 createContext<TranscriptViewerContextValue | null>(null)4041function useTranscriptViewerContext() {42 const context = useContext(TranscriptViewerContext)43 if (!context) {44 throw new Error(45 "useTranscriptViewerContext must be used within a TranscriptViewer"46 )47 }48 return context49}5051type TranscriptViewerProviderProps = {52 value: TranscriptViewerContextValue53 children: ReactNode54}5556function TranscriptViewerProvider({57 value,58 children,59}: TranscriptViewerProviderProps) {60 return (61 <TranscriptViewerContext.Provider value={value}>62 {children}63 </TranscriptViewerContext.Provider>64 )65}6667type AudioType =68 | "audio/mpeg"69 | "audio/wav"70 | "audio/ogg"71 | "audio/mp3"72 | "audio/m4a"73 | "audio/aac"74 | "audio/webm"7576type TranscriptViewerContainerProps = {77 audioSrc: string78 audioType: AudioType79 alignment: CharacterAlignmentResponseModel80 segmentComposer?: SegmentComposer81 hideAudioTags?: boolean82 children?: ReactNode83} & Omit<ComponentPropsWithoutRef<"div">, "children"> &84 Pick<85 Parameters<typeof useTranscriptViewer>[0],86 "onPlay" | "onPause" | "onTimeUpdate" | "onEnded" | "onDurationChange"87 >8889function TranscriptViewerContainer({90 audioSrc,91 audioType = "audio/mpeg",92 alignment,93 segmentComposer,94 hideAudioTags = true,95 children,96 className,97 onPlay,98 onPause,99 onTimeUpdate,100 onEnded,101 onDurationChange,102 ...props103}: TranscriptViewerContainerProps) {104// … truncated
What it pulls in
Other registry items
Files it writes
More from shadcn/ui
All 50 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| audio-playeraudio-player | shadcn/ui | Components | Free | 2 deps | |
| bar-visualizerbar-visualizer | shadcn/ui | Components | Free | no deps | |
| conversationconversation | shadcn/ui | Components | Free | 1 dep | |
| conversation-barconversation-bar | shadcn/ui | Components | Free | 1 dep | |
| live-waveformlive-waveform | shadcn/ui | Components | Free | no deps | |
| matrixmatrix | shadcn/ui | Components | Free | no deps | |
| messagemessage | shadcn/ui | Components | Free | 1 dep | |
| mic-selectormic-selector | shadcn/ui | Components | Free | no deps |
