Constructor
new Transcript(segments)
Parameters:
Properties| Name | Type | Description |
|---|---|---|
segments | Array.<object> | Flat list of transcript segments ({start, end, speaker, text}). |
| Name | Type | Description |
|---|---|---|
segments | Array.<object> | Flat list of transcript segments ({start, end, speaker, text}). |
paragraphs | Array.<object> | Contiguous runs of segments sharing the same speaker, split on long gaps. |
speakerBlocks | Array.<object> | Contiguous runs of paragraphs sharing the same speaker. |
sourceFilename | string | Original filename of the transcript source. |
- Source
Classes
Methods
buildTranscript()
Separates transcript segments into paragraphs a speaker blocks ahead of time for easy transcript management.
- Source
changeParagraphSpeaker(paragraph, newSpeakerId)
Reassigns all segments in a paragraph to a different speaker and rebuilds groupings.
Parameters:
| Name | Type | Description |
|---|---|---|
paragraph | object | paragraph object (with .segments array) |
newSpeakerId | string | id of the speaker to assign |
- Source
changeSpeaker(segIdx, newSpeakerId)
Reassigns a segment to a different speaker, marks the transcript dirty, and fully re-renders the transcript and regions.
Parameters:
| Name | Type | Description |
|---|---|---|
segIdx | number | index into loadedSegments |
newSpeakerId | string | id of the speaker to assign to the segment |
- Source
clone(deepopt) → {Transcript}
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
deep | boolean | <optional> | false | If true, returns a deep copy (segments are cloned); otherwise shallow. |
- Source
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.
- Source
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.
- Source
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:
| Name | Type | Description |
|---|---|---|
segIdx | number | index of any segment in the paragraph to merge upward |
- Source
Returns:
- Type:
- Object |
null
mergeSegments(segmentIndexA, segmentIndexB)
Merges two adjacent segments into one and rebuilds groupings.
Parameters:
| Name | Type | Description |
|---|---|---|
segmentIndexA | number | index of the earlier segment |
segmentIndexB | number | index of the later segment |
- Source
restoreParaBreak(segIdx, flag)
Restores a manualParaBreak flag for undo/redo.
Parameters:
| Name | Type | Description |
|---|---|---|
segIdx | number | index into this.segments |
flag | boolean | | the flag value to restore; undefined removes the flag |
- Source
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.
- Source
segmentAtTime(time) → {number|null}
Returns the index of the segment that contains the given time, or null if none.
Parameters:
| Name | Type | Description |
|---|---|---|
time | number | time in seconds |
- Source
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:
| Name | Type | Description |
|---|---|---|
segIdx | number | index of the segment that will start the new paragraph |
- Source
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:
| Name | Type | Description |
|---|---|---|
segmentIndex | number | index of the segment to replace |
newSegmentA | object | first replacement segment (earlier portion) |
newSegmentB | object | second replacement segment (later portion) |
- Source