@waveform-playlist/annotations 12.0.2 → 12.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -0
- package/package.json +5 -5
package/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# @waveform-playlist/annotations
|
|
2
|
+
|
|
3
|
+
Time-synchronized text annotations for waveform-playlist — mark up an audio timeline with draggable, editable regions for transcripts, podcast chapters, cue points, or music markers.
|
|
4
|
+
|
|
5
|
+
Used with [`@waveform-playlist/browser`](https://www.npmjs.com/package/@waveform-playlist/browser): wrap your playlist in `AnnotationProvider` and pass `annotationList` to `WaveformPlaylistProvider` — `<Waveform />` then renders annotation boxes and text automatically.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Timeline annotation boxes** — draggable regions overlaid on the waveform, with boundary resize handles
|
|
10
|
+
- **Editable text list** — a scrollable, auto-scrolling list of annotation text synced to playback
|
|
11
|
+
- **Drag-to-edit boundaries** — resize annotation start/end by dragging, with optional linked endpoints so adjacent segments stay contiguous
|
|
12
|
+
- **Continuous play mode** — automatically advance to the next annotation during playback
|
|
13
|
+
- **Aeneas import/export** — `parseAeneas` / `serializeAeneas` for the Aeneas forced-alignment JSON format
|
|
14
|
+
- **Prebuilt controls** — checkboxes for continuous play, linked endpoints, editable mode, and a JSON download button
|
|
15
|
+
- **Composable building blocks** — use `AnnotationsTrack`, `AnnotationBox`, `AnnotationBoxesWrapper`, and `AnnotationText` directly for custom annotation UIs
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @waveform-playlist/annotations
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Peer dependencies: `react` (^18.0.0), `styled-components` (^6.0.0), `@dnd-kit/react` (^0.3.0), and `@waveform-playlist/browser` (matching major version).
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { useState } from 'react';
|
|
29
|
+
import { WaveformPlaylistProvider, Waveform, useAudioTracks } from '@waveform-playlist/browser';
|
|
30
|
+
import { AnnotationProvider } from '@waveform-playlist/annotations';
|
|
31
|
+
|
|
32
|
+
function AnnotatedPlaylist() {
|
|
33
|
+
const { tracks, loading } = useAudioTracks([{ src: '/audio/podcast.mp3', name: 'Podcast' }]);
|
|
34
|
+
|
|
35
|
+
const [annotations, setAnnotations] = useState([
|
|
36
|
+
{ id: '1', start: 0, end: 5, lines: ['Introduction'] },
|
|
37
|
+
{ id: '2', start: 5, end: 15, lines: ['Topic Overview'] },
|
|
38
|
+
{ id: '3', start: 15, end: 30, lines: ['Main Discussion'] },
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
if (loading) return <div>Loading...</div>;
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<WaveformPlaylistProvider
|
|
45
|
+
tracks={tracks}
|
|
46
|
+
timescale
|
|
47
|
+
annotationList={{
|
|
48
|
+
annotations,
|
|
49
|
+
editable: true,
|
|
50
|
+
linkEndpoints: false,
|
|
51
|
+
}}
|
|
52
|
+
onAnnotationsChange={setAnnotations} // required for edits to persist
|
|
53
|
+
>
|
|
54
|
+
<AnnotationProvider>
|
|
55
|
+
<Waveform />
|
|
56
|
+
</AnnotationProvider>
|
|
57
|
+
</WaveformPlaylistProvider>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Each annotation is a plain object:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
interface AnnotationData {
|
|
66
|
+
id: string; // Unique identifier
|
|
67
|
+
start: number; // Start time in seconds
|
|
68
|
+
end: number; // End time in seconds
|
|
69
|
+
lines: string[]; // Text content as array of lines
|
|
70
|
+
language?: string; // Optional language code (e.g., 'en', 'es')
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
For building a custom UI outside the integrated `<Waveform />` pattern, use `useAnnotationControls` plus the standalone components directly:
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import {
|
|
78
|
+
useAnnotationControls,
|
|
79
|
+
ContinuousPlayCheckbox,
|
|
80
|
+
LinkEndpointsCheckbox,
|
|
81
|
+
EditableCheckbox,
|
|
82
|
+
DownloadAnnotationsButton,
|
|
83
|
+
} from '@waveform-playlist/annotations';
|
|
84
|
+
|
|
85
|
+
const { continuousPlay, linkEndpoints, setContinuousPlay, setLinkEndpoints } =
|
|
86
|
+
useAnnotationControls();
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Examples & Documentation
|
|
90
|
+
|
|
91
|
+
- [Annotations guide](https://naomiaro.github.io/waveform-playlist/docs/react/guides/annotations) — full provider configuration, keyboard controls, styling, and Aeneas import/export
|
|
92
|
+
- [Live Annotations example](https://naomiaro.github.io/waveform-playlist/examples/annotations)
|
|
93
|
+
- [naomiaro.github.io/waveform-playlist](https://naomiaro.github.io/waveform-playlist/) — full documentation
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waveform-playlist/annotations",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.4",
|
|
4
4
|
"description": "Annotation support for waveform-playlist",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -40,17 +40,17 @@
|
|
|
40
40
|
"tsup": "^8.5.1",
|
|
41
41
|
"typescript": "^5.9.3",
|
|
42
42
|
"vitest": "^3.2.6",
|
|
43
|
-
"@waveform-playlist/browser": "
|
|
43
|
+
"@waveform-playlist/browser": "15.3.1"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@waveform-playlist/core": "12.
|
|
47
|
-
"@waveform-playlist/ui-components": "13.
|
|
46
|
+
"@waveform-playlist/core": "12.6.0",
|
|
47
|
+
"@waveform-playlist/ui-components": "13.1.3"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@dnd-kit/react": "^0.3.0",
|
|
51
51
|
"react": "^18.0.0",
|
|
52
52
|
"styled-components": "^6.0.0",
|
|
53
|
-
"@waveform-playlist/browser": "^
|
|
53
|
+
"@waveform-playlist/browser": "^15.3.1"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "tsup",
|