Transcript

Holds transcript data and pre-computes paragraph and speaker-block groupings from the flat segment list for efficient rendering.

Constructor

new Transcript(segments)

Parameters:
NameTypeDescription
segmentsArray.<object>Flat list of transcript segments ({start, end, speaker, text}).
Properties
NameTypeDescription
segmentsArray.<object>Flat list of transcript segments ({start, end, speaker, text}).
paragraphsArray.<object>Contiguous runs of segments sharing the same speaker, split on long gaps.
speakerBlocksArray.<object>Contiguous runs of paragraphs sharing the same speaker.
sourceFilenamestringOriginal filename of the transcript source.

Classes

Transcript

Methods

buildTranscript()

Separates transcript segments into paragraphs a speaker blocks ahead of time for easy transcript management.

changeParagraphSpeaker(paragraph, newSpeakerId)

Reassigns all segments in a paragraph to a different speaker and rebuilds groupings.
Parameters:
NameTypeDescription
paragraphobjectparagraph object (with .segments array)
newSpeakerIdstringid of the speaker to assign

changeSpeaker(segIdx, newSpeakerId)

Reassigns a segment to a different speaker, marks the transcript dirty, and fully re-renders the transcript and regions.
Parameters:
NameTypeDescription
segIdxnumberindex into loadedSegments
newSpeakerIdstringid of the speaker to assign to the segment

clone(deepopt) → {Transcript}

Parameters:
NameTypeAttributesDefaultDescription
deepboolean<optional>
falseIf true, returns a deep copy (segments are cloned); otherwise shallow.
Returns:
Type: 
Transcript

compileCSV() → {string}

Serializes segments to a CSV string. Speaker ids are used as-is; fields with commas, quotes, or newlines are RFC 4180 escaped.
Returns:
Type: 
string

compileJSON() → {Object}

Serializes the transcript to the canonical paragraph > sentence > word JSON format. Uses the pre-computed paragraphs array so manual paragraph breaks are preserved.
Returns:
Type: 
Object

mergeParagraphBefore(segIdx) → {Object|null}

Merges the paragraph containing segIdx with the previous paragraph. Only works when the two paragraphs share the same speaker. Returns {segIdx, prevFlag} for undo, or null if the merge is not possible.
Parameters:
NameTypeDescription
segIdxnumberindex of any segment in the paragraph to merge upward
Returns:
Type: 
Object | null

mergeSegments(segmentIndexA, segmentIndexB)

Merges two adjacent segments into one and rebuilds groupings.
Parameters:
NameTypeDescription
segmentIndexAnumberindex of the earlier segment
segmentIndexBnumberindex of the later segment

restoreParaBreak(segIdx, flag)

Restores a manualParaBreak flag for undo/redo.
Parameters:
NameTypeDescription
segIdxnumberindex into this.segments
flagboolean | undefinedthe flag value to restore; undefined removes the flag

saveTranscriptCSV()

Serializes loadedSegments to CSV and triggers a browser file download. Speaker ids are replaced with their display names so renames are preserved. Fields containing commas, quotes, or newlines are RFC 4180 escaped. Clears the dirty flag after saving.

segmentAtTime(time) → {number|null}

Returns the index of the segment that contains the given time, or null if none.
Parameters:
NameTypeDescription
timenumbertime in seconds
Returns:
Type: 
number | null

splitParagraphAt(segIdx) → {boolean|undefined|null}

Forces a paragraph break before the segment at segIdx by setting manualParaBreak = true. Returns the previous flag value so the caller can undo.
Parameters:
NameTypeDescription
segIdxnumberindex of the segment that will start the new paragraph
Returns:
previous manualParaBreak value, or null if segIdx is invalid
Type: 
boolean | undefined | null

splitSegment(segmentIndex, newSegmentA, newSegmentB)

Replaces the segment at segmentIndex with two new segments and rebuilds groupings.
Parameters:
NameTypeDescription
segmentIndexnumberindex of the segment to replace
newSegmentAobjectfirst replacement segment (earlier portion)
newSegmentBobjectsecond replacement segment (later portion)