Constructor
new Project(projectIdopt, projectNameopt, callbacks)
Parameters:
Properties| Name | Type | Attributes | Default | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
projectId | string | <optional> | "" | UUID of the project; assigned by the server on first push. | |||||||||||||||
projectName | string | <optional> | "" | Human-readable name of the project. | |||||||||||||||
callbacks | object | callback functions for project state changesProperties
|
| Name | Type | Description |
|---|---|---|
projectId | string | UUID of the project; assigned by the server on first push. |
projectName | string | Human-readable name of the project. |
createdDate | string | ISO 8601 timestamp of when the project was created. |
modifiedDate | string | ISO 8601 timestamp of the last modification. |
synced | boolean | True if the local copy is up to date with the server. |
localOnly | boolean | True if the project has never been pushed to the server. |
speakersDirty | boolean | True if speaker data has unsaved local changes. |
transcriptDirty | boolean | True if transcript data has unsaved local changes. |
waveformDirty | boolean | True if waveform data has unsaved local changes. |
hasTranscript | boolean | True if a transcript has been loaded. |
hasSpeakers | boolean | True if speakers have been loaded. |
hasWaveform | boolean | True if a waveform has been loaded. |
local | ProjectData | Local working copy of the project data. |
server | ProjectData | Server-authoritative copy of the project data. |
onStateChange | callback | Callback fired whenever any state changes. |
onSpeakersModified | callback | Callback fired when speakers are marked dirty. |
onTranscriptModified | callback | Callback fired when the transcript is marked dirty. |
onWaveformModified | callback | Callback fired when the waveform is marked dirty. |
onSpeakersSaved | callback | Callback fired when speakers are marked clean. |
onTranscriptSaved | callback | Callback fired when the transcript is marked clean. |
onWaveformSaved | callback | Callback fired when the waveform is marked clean. |
- Source
Classes
Methods
addSpeaker(id, name, hueopt, sampleopt, localopt)
Adds a new speaker to the project. Auto-assigns a hue if none is provided.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
id | string | speaker id | ||
name | string | display name | ||
hue | string | | <optional> | null | hex color; auto-generated if null |
sample | object | <optional> | {} | voice sample data |
local | boolean | <optional> | true | if true, adds to the local copy; else server copy |
- Source
changeParagraphSpeaker(paragraph, newSpeakerId)
Reassigns all segments in a paragraph to a different speaker, marks the transcript dirty.
Parameters:
| Name | Type | Description |
|---|---|---|
paragraph | object | paragraph object from the transcript |
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 the segment to |
- Source
createCopy(newId, newName, callbacks) → {Project}
Creates a new Project that is a copy of this one with a different id and name.
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
newId | string | unique identifier for the new copy | ||||||
newName | string | display name for the new copy | ||||||
callbacks | object | callback functions for the new projectProperties
|
- Source
Returns:
- Type:
- Project
getSpeaker(speakerId, local) → {Speaker|undefined}
Gets the speaker object for the speaker with the requested id
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
speakerId | string | The ID of the speaker to get | |
local | bool | true | True, if the function should get a local copy, false if it should get a server copy |
- Source
Returns:
the speaker object, or undefined if not found
- Type:
- Speaker |
undefined
isDirty() → {boolean}
Returns whether any project sector is dirty
- Source
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:
| Name | Type | Attributes | Description |
|---|---|---|---|
file | File | audio file to load; any format supported by the browser | |
onProgress | function | <optional> | progress callback, fraction 0–1 (large files only) |
- Source
loadTranscriptCSV(transcript_text, localopt)
Parses a CSV string and loads the resulting segments into the project's transcript.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
transcript_text | string | CSV text with columns: start, end, speaker, text | ||
local | boolean | <optional> | true | if true, loads into the local copy; otherwise the server copy |
- Source
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:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
json | object | transcript JSON with a `paragraphs` array | ||
local | boolean | <optional> | true | if true, loads into the local copy; otherwise the server copy |
- Source
markAllDirty(dirtyopt)
Sets the dirty (or edited) status of all sectors
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dirty | boolean | <optional> | true | true to mark dirty, false to mark clean |
- Source
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.
- Source
markSpeakersDirty(dirtyopt)
Sets the dirty (or edited) status of the speakers sector
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dirty | boolean | <optional> | true | true to mark dirty, false to mark clean |
- Source
markTranscriptDirty(dirtyopt)
Sets the dirty (or edited) status of the transcript sector
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dirty | boolean | <optional> | true | true to mark dirty, false to mark clean |
- Source
markWaveformDirty(dirtyopt)
Sets the dirty (or edited) status of the waveform sector
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dirty | boolean | <optional> | true | true to mark dirty, false to mark clean |
- Source
mergeParagraphBefore(segIdx) → {Object|null}
Merges the paragraph containing segIdx with the previous same-speaker paragraph.
Parameters:
| Name | Type | Description |
|---|---|---|
segIdx | number | index of any segment in the paragraph to merge upward |
- Source
Returns:
undo info, or null if not possible
- Type:
- Object |
null
mergeSegments(segmentIndexA, segmentIndexB)
Merges two adjacent segments and marks the transcript dirty.
Parameters:
| Name | Type | Description |
|---|---|---|
segmentIndexA | number | index of the earlier segment |
segmentIndexB | number | index of the later segment |
- Source
metadata() → {object}
Gets the general project metadata as a dictionary (version, id, name, dates, speakers). Waveform details live in waveformMetadata() instead.
- Source
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:
| Name | Type | Description |
|---|---|---|
filepath | FileSystemFileHandle | file handle to write the archive to |
- Source
Returns:
- Type:
- Promise.<void>
(async) pullFromServer()
Pulls data from the server and stores it in memory
- Source
reassignSegments(speakerId, targetId)
Reassigns all transcript segments from one speaker to another.
Parameters:
| Name | Type | Description |
|---|---|---|
speakerId | string | id of the speaker to reassign from |
targetId | string | id of the speaker to assign to |
- Source
registerModifyCallbacks(callbacks)
Registers callbacks that are invoked when each data category is marked dirty or clean.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
callbacks | object | callback functions for data modification eventsProperties
|
- Source
removeSpeaker(speakerId)
Removes a speaker from the active speakers dict and marks speakers dirty.
Parameters:
| Name | Type | Description |
|---|---|---|
speakerId | string | the id of the speaker to remove |
- Source
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.
- Source
segmentAtTime(time) → {number|null}
Returns the index of the local transcript segment at the given time.
Parameters:
| Name | Type | Description |
|---|---|---|
time | number | seconds |
- Source
Returns:
- Type:
- number |
null
setName(name)
Updates the project name and notifies listeners via the state-change callback.
Parameters:
| Name | Type | Description |
|---|---|---|
name | string | the new display name for the project |
- Source
speakers(local) → {Object.<string, Speaker>}
Helper function to get the speakers from the project data
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
local | bool | true | True, if the function should get a local copy, false if it should get a server copy |
- Source
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:
| Name | Type | Description |
|---|---|---|
segIdx | number | index of the segment that will start the new paragraph |
- Source
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:
| Name | Type | Description |
|---|---|---|
segmentIndex | number | index of the segment to split |
newSegmentA | object | first replacement segment (earlier portion) |
newSegmentB | object | second replacement segment (later portion) |
- Source
transcript(local) → {Transcript|null}
Helper function to get the transcript from the project data
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
local | bool | true | True, if the function should get a local copy, false if it should get a server copy |
- Source
Returns:
the transcript object
- Type:
- Transcript |
null
waveform(local) → {Waveform|null}
Helper function to get the waveform from the project data
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
local | bool | true | True, if the function should get a local copy, false if it should get a server copy |
- Source
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.
- Source
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:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
zipFile | File | | The packaged project archive. | |||||||||
callbacks | object | <optional> | callback functions for the restored projectProperties
|
- Source
Returns:
- Type:
- Promise.<Project>