Project

Represents a single transcription project. Stores both a server-side and a local working copy of the project data (transcript, speakers, waveform), tracks dirty state per data category, and fires callbacks when data changes.

Constructor

new Project(projectIdopt, projectNameopt, callbacks)

Parameters:
NameTypeAttributesDefaultDescription
projectIdstring<optional>
""UUID of the project; assigned by the server on first push.
projectNamestring<optional>
""Human-readable name of the project.
callbacksobjectcallback functions for project state changes
Properties
NameTypeAttributesDefaultDescription
onStateChangecallback<optional>
Callback fired whenever any state changes.
serverServer<optional>
nullReference to the App Server instance.
Properties
NameTypeDescription
projectIdstringUUID of the project; assigned by the server on first push.
projectNamestringHuman-readable name of the project.
createdDatestringISO 8601 timestamp of when the project was created.
modifiedDatestringISO 8601 timestamp of the last modification.
syncedbooleanTrue if the local copy is up to date with the server.
localOnlybooleanTrue if the project has never been pushed to the server.
speakersDirtybooleanTrue if speaker data has unsaved local changes.
transcriptDirtybooleanTrue if transcript data has unsaved local changes.
waveformDirtybooleanTrue if waveform data has unsaved local changes.
hasTranscriptbooleanTrue if a transcript has been loaded.
hasSpeakersbooleanTrue if speakers have been loaded.
hasWaveformbooleanTrue if a waveform has been loaded.
localProjectDataLocal working copy of the project data.
serverProjectDataServer-authoritative copy of the project data.
onStateChangecallbackCallback fired whenever any state changes.
onSpeakersModifiedcallbackCallback fired when speakers are marked dirty.
onTranscriptModifiedcallbackCallback fired when the transcript is marked dirty.
onWaveformModifiedcallbackCallback fired when the waveform is marked dirty.
onSpeakersSavedcallbackCallback fired when speakers are marked clean.
onTranscriptSavedcallbackCallback fired when the transcript is marked clean.
onWaveformSavedcallbackCallback fired when the waveform is marked clean.

Classes

Project

Methods

addSpeaker(id, name, hueopt, sampleopt, localopt)

Adds a new speaker to the project. Auto-assigns a hue if none is provided.
Parameters:
NameTypeAttributesDefaultDescription
idstringspeaker id
namestringdisplay name
huestring | null<optional>
nullhex color; auto-generated if null
sampleobject<optional>
{}voice sample data
localboolean<optional>
trueif true, adds to the local copy; else server copy

changeParagraphSpeaker(paragraph, newSpeakerId)

Reassigns all segments in a paragraph to a different speaker, marks the transcript dirty.
Parameters:
NameTypeDescription
paragraphobjectparagraph object from the transcript
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 the segment to

createCopy(newId, newName, callbacks) → {Project}

Creates a new Project that is a copy of this one with a different id and name.
Parameters:
NameTypeDescription
newIdstringunique identifier for the new copy
newNamestringdisplay name for the new copy
callbacksobjectcallback functions for the new project
Properties
NameTypeDescription
onStateChangecallbackfired whenever state changes in the copy
Returns:
Type: 
Project

getSpeaker(speakerId, local) → {Speaker|undefined}

Gets the speaker object for the speaker with the requested id
Parameters:
NameTypeDefaultDescription
speakerIdstringThe ID of the speaker to get
localbooltrueTrue, if the function should get a local copy, false if it should get a server copy
Returns:
the speaker object, or undefined if not found
Type: 
Speaker | undefined

isDirty() → {boolean}

Returns whether any project sector is dirty
Returns:
true if any sector has unsaved changes
Type: 
boolean

(async) loadLocalAudio(file, onProgressopt)

Loads a local audio file, extracts metadata and peaks, and stores the results in the local ProjectData. The returned object URL is owned by this project; revoke it (URL.revokeObjectURL(this.local.waveformUrl)) when the project is closed or replaced.
Parameters:
NameTypeAttributesDescription
fileFileaudio file to load; any format supported by the browser
onProgressfunction<optional>
progress callback, fraction 0–1 (large files only)

loadTranscriptCSV(transcript_text, localopt)

Parses a CSV string and loads the resulting segments into the project's transcript.
Parameters:
NameTypeAttributesDefaultDescription
transcript_textstringCSV text with columns: start, end, speaker, text
localboolean<optional>
trueif true, loads into the local copy; otherwise the server copy

loadTranscriptJSON(json, localopt)

Parses a transcript JSON object and loads the resulting segments into the project's transcript. Flattens the paragraph > sentence > word hierarchy into a flat segments list.
Parameters:
NameTypeAttributesDefaultDescription
jsonobjecttranscript JSON with a `paragraphs` array
localboolean<optional>
trueif true, loads into the local copy; otherwise the server copy

markAllDirty(dirtyopt)

Sets the dirty (or edited) status of all sectors
Parameters:
NameTypeAttributesDefaultDescription
dirtyboolean<optional>
truetrue to mark dirty, false to mark clean

markClean()

Marks all dirty flags as clean after a successful server upload. Also snapshots the current local state as the new save baseline so revertToLastSave() can restore it later. Call App.pushProjectToServer() to perform the actual upload.

markSpeakersDirty(dirtyopt)

Sets the dirty (or edited) status of the speakers sector
Parameters:
NameTypeAttributesDefaultDescription
dirtyboolean<optional>
truetrue to mark dirty, false to mark clean

markTranscriptDirty(dirtyopt)

Sets the dirty (or edited) status of the transcript sector
Parameters:
NameTypeAttributesDefaultDescription
dirtyboolean<optional>
truetrue to mark dirty, false to mark clean

markWaveformDirty(dirtyopt)

Sets the dirty (or edited) status of the waveform sector
Parameters:
NameTypeAttributesDefaultDescription
dirtyboolean<optional>
truetrue to mark dirty, false to mark clean

mergeParagraphBefore(segIdx) → {Object|null}

Merges the paragraph containing segIdx with the previous same-speaker paragraph.
Parameters:
NameTypeDescription
segIdxnumberindex of any segment in the paragraph to merge upward
Returns:
undo info, or null if not possible
Type: 
Object | null

mergeSegments(segmentIndexA, segmentIndexB)

Merges two adjacent segments and marks the transcript dirty.
Parameters:
NameTypeDescription
segmentIndexAnumberindex of the earlier segment
segmentIndexBnumberindex of the later segment

metadata() → {object}

Gets the general project metadata as a dictionary (version, id, name, dates, speakers). Waveform details live in waveformMetadata() instead.
Returns:
metadata dictionary with version, id, name, created, modified, and speakers
Type: 
object

(async) packageProject(filepath) → {Promise.<void>}

Packages the project into a downloadable ZIP archive containing: - project.json — all project, waveform, and speaker metadata - peaks.json — waveform amplitude peaks - transcript.csv — recompiled transcript segments -.wav — the main audio file - samples/.wav — speaker audio samples
Parameters:
NameTypeDescription
filepathFileSystemFileHandlefile handle to write the archive to
Returns:
Type: 
Promise.<void>

(async) pullFromServer()

Pulls data from the server and stores it in memory

reassignSegments(speakerId, targetId)

Reassigns all transcript segments from one speaker to another.
Parameters:
NameTypeDescription
speakerIdstringid of the speaker to reassign from
targetIdstringid of the speaker to assign to

registerModifyCallbacks(callbacks)

Registers callbacks that are invoked when each data category is marked dirty or clean.
Parameters:
NameTypeDescription
callbacksobjectcallback functions for data modification events
Properties
NameTypeAttributesDescription
onSpeakersModifiedcallback<optional>
called when speakers are marked dirty
onTranscriptModifiedcallback<optional>
called when the transcript is marked dirty
onWaveformModifiedcallback<optional>
called when the waveform is marked dirty
onSpeakersSavedcallback<optional>
called when speakers are marked clean
onTranscriptSavedcallback<optional>
called when the transcript is marked clean
onWaveformSavedcallback<optional>
called when the waveform is marked clean

removeSpeaker(speakerId)

Removes a speaker from the active speakers dict and marks speakers dirty.
Parameters:
NameTypeDescription
speakerIdstringthe id of the speaker to remove

revertToLastSave()

Discards all local changes since the last save by restoring the local working copy from the saved server snapshot, then re-renders all panels.

segmentAtTime(time) → {number|null}

Returns the index of the local transcript segment at the given time.
Parameters:
NameTypeDescription
timenumberseconds
Returns:
Type: 
number | null

setName(name)

Updates the project name and notifies listeners via the state-change callback.
Parameters:
NameTypeDescription
namestringthe new display name for the project

speakers(local) → {Object.<string, Speaker>}

Helper function to get the speakers from the project data
Parameters:
NameTypeDefaultDescription
localbooltrueTrue, if the function should get a local copy, false if it should get a server copy
Returns:
dictionary of Speaker objects keyed by speaker id
Type: 
Object.<string, Speaker>

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

Forces a paragraph break before the segment at segIdx.
Parameters:
NameTypeDescription
segIdxnumberindex of the segment that will start the new paragraph
Returns:
previous manualParaBreak value for undo
Type: 
boolean | undefined | null

splitSegment(segmentIndex, newSegmentA, newSegmentB)

Splits a segment into two and marks the transcript dirty.
Parameters:
NameTypeDescription
segmentIndexnumberindex of the segment to split
newSegmentAobjectfirst replacement segment (earlier portion)
newSegmentBobjectsecond replacement segment (later portion)

transcript(local) → {Transcript|null}

Helper function to get the transcript from the project data
Parameters:
NameTypeDefaultDescription
localbooltrueTrue, if the function should get a local copy, false if it should get a server copy
Returns:
the transcript object
Type: 
Transcript | null

waveform(local) → {Waveform|null}

Helper function to get the waveform from the project data
Parameters:
NameTypeDefaultDescription
localbooltrueTrue, if the function should get a local copy, false if it should get a server copy
Returns:
the waveform object, or null if none loaded
Type: 
Waveform | null

waveformMetadata() → {Object}

Gets all waveform data — sampleRate, duration, filename, and peaks — for server upload. peaks is stored locally as Float32Array[] (one per channel from the Web Audio API). This converts the mono channel (index 0) to a plain Array so JSON.stringify produces a compact JSON number array instead of a keyed object.
Returns:
waveform metadata object
Type: 
Object

(async, static) unpackageProject(zipFile, callbacksopt) → {Promise.<Project>}

Factory function — the inverse of Project.packageProject(). Reads a packaged .wfs ZIP file (File, Blob, or ArrayBuffer) and reconstructs a fully-populated Project from its contents.
Parameters:
NameTypeAttributesDescription
zipFileFile | Blob | ArrayBufferThe packaged project archive.
callbacksobject<optional>
callback functions for the restored project
Properties
NameTypeAttributesDescription
onStateChangecallback<optional>
fired whenever state changes in the restored project
Returns:
Type: 
Promise.<Project>