plotwave 0.1.0__tar.gz → 0.1.2__tar.gz

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.
Files changed (48) hide show
  1. {plotwave-0.1.0 → plotwave-0.1.2}/.gitignore +6 -1
  2. {plotwave-0.1.0 → plotwave-0.1.2}/PKG-INFO +43 -13
  3. {plotwave-0.1.0 → plotwave-0.1.2}/README.md +40 -12
  4. plotwave-0.1.2/examples/getting_started.ipynb +3977 -0
  5. plotwave-0.1.2/examples/plotwave_C_VHS.wav +0 -0
  6. plotwave-0.1.2/examples/plotwave_C_piano.wav +0 -0
  7. {plotwave-0.1.0 → plotwave-0.1.2}/pyproject.toml +14 -1
  8. plotwave-0.1.2/scripts/build_pages_demo.py +729 -0
  9. {plotwave-0.1.0 → plotwave-0.1.2}/src/plotwave/__init__.py +5 -1
  10. plotwave-0.1.2/src/plotwave/_core.py +2075 -0
  11. plotwave-0.1.2/src/plotwave/_render.py +990 -0
  12. plotwave-0.1.2/tests/test_api.py +947 -0
  13. plotwave-0.1.0/.github/workflows/pages.yml +0 -53
  14. plotwave-0.1.0/assets/logo_name.png +0 -0
  15. plotwave-0.1.0/assets/logo_name_black.png +0 -0
  16. plotwave-0.1.0/assets/logo_name_transparent.png +0 -0
  17. plotwave-0.1.0/assets/logo_name_white.png +0 -0
  18. plotwave-0.1.0/assets/logo_simple.png +0 -0
  19. plotwave-0.1.0/assets/logo_simple_transparent.png +0 -0
  20. plotwave-0.1.0/docs/apple-touch-icon.png +0 -0
  21. plotwave-0.1.0/docs/assets/logo_name_black.png +0 -0
  22. plotwave-0.1.0/docs/demo.html +0 -379
  23. plotwave-0.1.0/docs/favicon/apple-touch-icon.png +0 -0
  24. plotwave-0.1.0/docs/favicon/favicon-96x96.png +0 -0
  25. plotwave-0.1.0/docs/favicon/favicon.ico +0 -0
  26. plotwave-0.1.0/docs/favicon/favicon.svg +0 -1
  27. plotwave-0.1.0/docs/favicon/site.webmanifest +0 -21
  28. plotwave-0.1.0/docs/favicon/web-app-manifest-192x192.png +0 -0
  29. plotwave-0.1.0/docs/favicon/web-app-manifest-512x512.png +0 -0
  30. plotwave-0.1.0/docs/favicon-96x96.png +0 -0
  31. plotwave-0.1.0/docs/favicon.ico +0 -0
  32. plotwave-0.1.0/docs/favicon.svg +0 -1
  33. plotwave-0.1.0/docs/index.html +0 -266
  34. plotwave-0.1.0/docs/site.webmanifest +0 -21
  35. plotwave-0.1.0/docs/web-app-manifest-192x192.png +0 -0
  36. plotwave-0.1.0/docs/web-app-manifest-512x512.png +0 -0
  37. plotwave-0.1.0/examples/getting_started.ipynb +0 -396
  38. plotwave-0.1.0/examples/progression_pred_vs_label.html +0 -180
  39. plotwave-0.1.0/scripts/build_pages_demo.py +0 -420
  40. plotwave-0.1.0/src/plotwave/_core.py +0 -881
  41. plotwave-0.1.0/src/plotwave/_render.py +0 -464
  42. plotwave-0.1.0/tests/test_api.py +0 -284
  43. plotwave-0.1.0/uv.lock +0 -2007
  44. {plotwave-0.1.0 → plotwave-0.1.2}/DEVELOPERS.md +0 -0
  45. {plotwave-0.1.0 → plotwave-0.1.2}/LICENSE +0 -0
  46. {plotwave-0.1.0 → plotwave-0.1.2}/examples/__init__.py +0 -0
  47. {plotwave-0.1.0 → plotwave-0.1.2}/examples/signal_helpers.py +0 -0
  48. {plotwave-0.1.0 → plotwave-0.1.2}/src/plotwave/py.typed +0 -0
@@ -9,4 +9,9 @@ __pycache__/
9
9
  dist/
10
10
  build/
11
11
  notebooks/*.html
12
-
12
+ notebook_test
13
+ plotwave-assets/
14
+ docs/*.png
15
+ docs/*.svg
16
+ docs/*.ico
17
+ docs/*.webmanifest
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotwave
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Interactive audio and waveform plotting for notebooks and browsers.
5
5
  Project-URL: Homepage, https://github.com/camilziane/plotwave
6
6
  Project-URL: Repository, https://github.com/camilziane/plotwave
@@ -18,7 +18,9 @@ Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
19
19
  Classifier: Topic :: Scientific/Engineering :: Visualization
20
20
  Requires-Python: >=3.11
21
+ Requires-Dist: lameenc>=1.8.2
21
22
  Requires-Dist: numpy>=1.26
23
+ Requires-Dist: soundfile>=0.12.1
22
24
  Description-Content-Type: text/markdown
23
25
 
24
26
  # plotwave
@@ -39,6 +41,14 @@ Overlay multiple audio tracks or add additional signals (labels, predictions, se
39
41
 
40
42
  Designed for **Jupyter notebooks**, `plotwave` can also be exported to **HTML**, making it easy to share interactive audio visualizations or log them in tools like **MLflow** for experiment analysis.
41
43
 
44
+ ## Why plotwave
45
+
46
+ - Start from a path with `plotwave.audio_file(...)` and get an interactive waveform without manually decoding audio first.
47
+ - Click anywhere in the waveform to audition the exact moment you are inspecting.
48
+ - Click a segment label to loop that labeled region and compare it against the waveform.
49
+ - Overlay predictions, envelopes, scores, or ground-truth labels on the same timeline.
50
+ - Use the same interaction model in notebooks and exported HTML.
51
+
42
52
  ## Install
43
53
 
44
54
  ```bash
@@ -51,41 +61,51 @@ or
51
61
  pip install plotwave
52
62
  ```
53
63
 
54
- ## Smallest useful example
64
+ ## Direct audio file example
55
65
 
56
66
  ```python
57
- import soundfile as sf
58
67
  import plotwave
59
68
 
60
- wav, sr = sf.read("wave.wav", always_2d=False)
61
-
62
- plotwave.plot(wav, sr=sr, name="voice")
69
+ plotwave.audio_file("voice.mp3", name="voice").plot(
70
+ layout={"title": {"text": "Direct file-backed audio"}, "height": 460},
71
+ )
63
72
  ```
64
73
 
65
- `soundfile` is only used here as a convenient audio loader. `plotwave` itself only depends on `numpy`.
74
+ `plotwave.audio_file(...)` uses `soundfile` internally and can open any local audio format that your `soundfile` backend supports, including WAV and MP3. It is the quickest way to go from a local audio file to an interactive player + waveform view.
75
+ Use `soundfile.read(...)` only when you want to derive an extra trace from the samples, like an envelope or model scores.
66
76
 
67
77
  ## Audio + curve
68
78
 
69
79
  ```python
80
+ import numpy as np
81
+ import soundfile as sf
82
+ import plotwave
83
+
84
+ wav, sr = sf.read("voice.mp3", always_2d=False)
70
85
  env = np.abs(wav)
71
86
 
72
87
  plotwave.plot(
73
88
  [
74
- plotwave.audio(wav, sr, name="audio", color="#2563eb"),
75
- plotwave.series(env, name="envelope", color="#f97316", fill="tozeroy"),
89
+ plotwave.audio_file("voice.mp3", name="audio", color="#2563eb"),
90
+ plotwave.series(env, sr=sr, name="envelope", color="#f97316", fill="tozeroy"),
76
91
  ],
77
92
  layout={"title": {"text": "Audio + envelope"}, "height": 520},
78
93
  )
79
94
  ```
80
95
 
81
- If `series(..., time=None)` is plotted next to audio, `plotwave` infers its time axis automatically when the audio timing is unambiguous.
96
+ For `series(...)`, use:
82
97
 
83
- ## Segments
98
+ - `sr=...` when your values are evenly sampled
99
+ - `time=...` when you already have an explicit time axis
100
+
101
+ ## Segments and label looping
84
102
 
85
103
  ```python
104
+ import plotwave
105
+
86
106
  plotwave.plot(
87
107
  [
88
- plotwave.audio(wav, sr, name="audio"),
108
+ plotwave.audio_file("song.mp3", name="audio"),
89
109
  plotwave.segments(
90
110
  [
91
111
  {"start": 0.0, "end": 0.7, "label": "Bm"},
@@ -101,8 +121,8 @@ plotwave.plot(
101
121
 
102
122
  `segments(...)` adds:
103
123
 
124
+ - clickable label boxes that loop the matching audio span
104
125
  - colored background blocks
105
- - label boxes
106
126
  - hoverable segment names
107
127
  - top/bottom lanes for comparisons like prediction vs ground truth
108
128
 
@@ -114,16 +134,26 @@ plot.save("wave.html")
114
134
  html = plot.html()
115
135
  ```
116
136
 
137
+ By default, notebook output, `html()`, and `save()` use compressed audio. You can disable that and control the bitrate explicitly:
138
+
139
+ ```python
140
+ plot = plotwave.audio_file("voice.mp3").plot(compress_audio=False)
141
+ html = plot.html(compress_audio=True, bitrate="48k")
142
+ ```
143
+
117
144
  ## API
118
145
 
119
146
  Public API:
120
147
 
121
148
  - `plotwave.plot(...)`
122
149
  - `plotwave.audio(...)`
150
+ - `plotwave.audio_file(...)`
123
151
  - `plotwave.series(...)`
124
152
  - `plotwave.segments(...)`
125
153
  - `plotwave.Plot`
126
154
 
155
+ All trace types also have `trace.plot(...)` as a shortcut for `plotwave.plot(trace, ...)`.
156
+
127
157
  See [examples/getting_started.ipynb](https://github.com/camilziane/plotwave/blob/main/examples/getting_started.ipynb) for a full walkthrough.
128
158
 
129
159
  Developer workflow: [DEVELOPERS.md](https://github.com/camilziane/plotwave/blob/main/DEVELOPERS.md)
@@ -16,6 +16,14 @@ Overlay multiple audio tracks or add additional signals (labels, predictions, se
16
16
 
17
17
  Designed for **Jupyter notebooks**, `plotwave` can also be exported to **HTML**, making it easy to share interactive audio visualizations or log them in tools like **MLflow** for experiment analysis.
18
18
 
19
+ ## Why plotwave
20
+
21
+ - Start from a path with `plotwave.audio_file(...)` and get an interactive waveform without manually decoding audio first.
22
+ - Click anywhere in the waveform to audition the exact moment you are inspecting.
23
+ - Click a segment label to loop that labeled region and compare it against the waveform.
24
+ - Overlay predictions, envelopes, scores, or ground-truth labels on the same timeline.
25
+ - Use the same interaction model in notebooks and exported HTML.
26
+
19
27
  ## Install
20
28
 
21
29
  ```bash
@@ -28,41 +36,51 @@ or
28
36
  pip install plotwave
29
37
  ```
30
38
 
31
- ## Smallest useful example
39
+ ## Direct audio file example
32
40
 
33
41
  ```python
34
- import soundfile as sf
35
42
  import plotwave
36
43
 
37
- wav, sr = sf.read("wave.wav", always_2d=False)
38
-
39
- plotwave.plot(wav, sr=sr, name="voice")
44
+ plotwave.audio_file("voice.mp3", name="voice").plot(
45
+ layout={"title": {"text": "Direct file-backed audio"}, "height": 460},
46
+ )
40
47
  ```
41
48
 
42
- `soundfile` is only used here as a convenient audio loader. `plotwave` itself only depends on `numpy`.
49
+ `plotwave.audio_file(...)` uses `soundfile` internally and can open any local audio format that your `soundfile` backend supports, including WAV and MP3. It is the quickest way to go from a local audio file to an interactive player + waveform view.
50
+ Use `soundfile.read(...)` only when you want to derive an extra trace from the samples, like an envelope or model scores.
43
51
 
44
52
  ## Audio + curve
45
53
 
46
54
  ```python
55
+ import numpy as np
56
+ import soundfile as sf
57
+ import plotwave
58
+
59
+ wav, sr = sf.read("voice.mp3", always_2d=False)
47
60
  env = np.abs(wav)
48
61
 
49
62
  plotwave.plot(
50
63
  [
51
- plotwave.audio(wav, sr, name="audio", color="#2563eb"),
52
- plotwave.series(env, name="envelope", color="#f97316", fill="tozeroy"),
64
+ plotwave.audio_file("voice.mp3", name="audio", color="#2563eb"),
65
+ plotwave.series(env, sr=sr, name="envelope", color="#f97316", fill="tozeroy"),
53
66
  ],
54
67
  layout={"title": {"text": "Audio + envelope"}, "height": 520},
55
68
  )
56
69
  ```
57
70
 
58
- If `series(..., time=None)` is plotted next to audio, `plotwave` infers its time axis automatically when the audio timing is unambiguous.
71
+ For `series(...)`, use:
59
72
 
60
- ## Segments
73
+ - `sr=...` when your values are evenly sampled
74
+ - `time=...` when you already have an explicit time axis
75
+
76
+ ## Segments and label looping
61
77
 
62
78
  ```python
79
+ import plotwave
80
+
63
81
  plotwave.plot(
64
82
  [
65
- plotwave.audio(wav, sr, name="audio"),
83
+ plotwave.audio_file("song.mp3", name="audio"),
66
84
  plotwave.segments(
67
85
  [
68
86
  {"start": 0.0, "end": 0.7, "label": "Bm"},
@@ -78,8 +96,8 @@ plotwave.plot(
78
96
 
79
97
  `segments(...)` adds:
80
98
 
99
+ - clickable label boxes that loop the matching audio span
81
100
  - colored background blocks
82
- - label boxes
83
101
  - hoverable segment names
84
102
  - top/bottom lanes for comparisons like prediction vs ground truth
85
103
 
@@ -91,16 +109,26 @@ plot.save("wave.html")
91
109
  html = plot.html()
92
110
  ```
93
111
 
112
+ By default, notebook output, `html()`, and `save()` use compressed audio. You can disable that and control the bitrate explicitly:
113
+
114
+ ```python
115
+ plot = plotwave.audio_file("voice.mp3").plot(compress_audio=False)
116
+ html = plot.html(compress_audio=True, bitrate="48k")
117
+ ```
118
+
94
119
  ## API
95
120
 
96
121
  Public API:
97
122
 
98
123
  - `plotwave.plot(...)`
99
124
  - `plotwave.audio(...)`
125
+ - `plotwave.audio_file(...)`
100
126
  - `plotwave.series(...)`
101
127
  - `plotwave.segments(...)`
102
128
  - `plotwave.Plot`
103
129
 
130
+ All trace types also have `trace.plot(...)` as a shortcut for `plotwave.plot(trace, ...)`.
131
+
104
132
  See [examples/getting_started.ipynb](https://github.com/camilziane/plotwave/blob/main/examples/getting_started.ipynb) for a full walkthrough.
105
133
 
106
134
  Developer workflow: [DEVELOPERS.md](https://github.com/camilziane/plotwave/blob/main/DEVELOPERS.md)