modusa 0.4.16__py3-none-any.whl → 0.4.18__py3-none-any.whl
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.
- modusa/__init__.py +1 -1
- modusa/tools/audio_player.py +50 -51
- {modusa-0.4.16.dist-info → modusa-0.4.18.dist-info}/METADATA +1 -1
- {modusa-0.4.16.dist-info → modusa-0.4.18.dist-info}/RECORD +7 -7
- {modusa-0.4.16.dist-info → modusa-0.4.18.dist-info}/WHEEL +0 -0
- {modusa-0.4.16.dist-info → modusa-0.4.18.dist-info}/entry_points.txt +0 -0
- {modusa-0.4.16.dist-info → modusa-0.4.18.dist-info}/licenses/LICENSE.md +0 -0
modusa/__init__.py
CHANGED
modusa/tools/audio_player.py
CHANGED
|
@@ -3,59 +3,58 @@
|
|
|
3
3
|
from IPython.display import Audio, HTML, display
|
|
4
4
|
import numpy as np
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Simple audio player with optional clip selection and label,
|
|
9
|
-
displayed neatly in a small table.
|
|
10
|
-
|
|
11
|
-
Parameters
|
|
12
|
-
----------
|
|
13
|
-
y : np.ndarray
|
|
14
|
-
Mono audio data (1D numpy array).
|
|
15
|
-
sr : float
|
|
16
|
-
Sampling rate.
|
|
17
|
-
clip : tuple[float, float] | None
|
|
18
|
-
(start_time, end_time) in seconds. Plays whole audio if None.
|
|
19
|
-
label : str | None
|
|
20
|
-
Optional label to describe the clip (e.g. "Chorus", "Intro").
|
|
6
|
+
from IPython.display import Audio, HTML, display
|
|
7
|
+
import numpy as np
|
|
21
8
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
def play(y: np.ndarray, sr: float, clip: tuple[float, float] | None = None, label: str | None = None) -> None:
|
|
10
|
+
"""
|
|
11
|
+
Audio player with optional clip selection and transcription-style label.
|
|
12
|
+
Displays a clean caption box with bold timing and text, followed by the player.
|
|
13
|
+
"""
|
|
14
|
+
start_time, end_time = 0.0, len(y) / sr
|
|
27
15
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
16
|
+
# Optional clip selection
|
|
17
|
+
if clip is not None:
|
|
18
|
+
if not isinstance(clip, tuple) or len(clip) != 2:
|
|
19
|
+
raise ValueError("`clip` must be a tuple of (start_time, end_time)")
|
|
20
|
+
start_sample = int(clip[0] * sr)
|
|
21
|
+
end_sample = int(clip[1] * sr)
|
|
22
|
+
y = y[start_sample:end_sample]
|
|
23
|
+
start_time, end_time = clip
|
|
24
|
+
|
|
25
|
+
# Build HTML
|
|
26
|
+
audio_html = Audio(data=y, rate=sr)._repr_html_()
|
|
27
|
+
label_html = f"""
|
|
28
|
+
<div style="
|
|
29
|
+
margin-top:4px;
|
|
30
|
+
padding:10px 12px;
|
|
31
|
+
background:#f7f7f7;
|
|
32
|
+
border-radius:6px;
|
|
33
|
+
color:#222;
|
|
34
|
+
font-size:14px;
|
|
35
|
+
line-height:1.5;
|
|
36
|
+
">
|
|
37
|
+
<strong>{start_time:.2f}s → {end_time:.2f}s:</strong>
|
|
38
|
+
<span style="margin-left:6px;">{label if label else ''}</span>
|
|
39
|
+
</div>
|
|
40
|
+
"""
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
html = f"""
|
|
43
|
+
<div style="
|
|
44
|
+
display:inline-block;
|
|
45
|
+
border:1px solid #e0e0e0;
|
|
46
|
+
border-radius:10px;
|
|
47
|
+
padding:12px 16px;
|
|
48
|
+
background:#fff;
|
|
49
|
+
font-family:sans-serif;
|
|
50
|
+
max-width:800px;
|
|
51
|
+
box-shadow:0 1px 3px rgba(0,0,0,0.05);
|
|
52
|
+
">
|
|
53
|
+
{label_html}
|
|
54
|
+
<div style="margin-top:10px;">
|
|
55
|
+
{audio_html}
|
|
54
56
|
</div>
|
|
55
|
-
|
|
57
|
+
</div>
|
|
58
|
+
"""
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
display(HTML(html))
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
modusa-0.4.
|
|
2
|
-
modusa-0.4.
|
|
3
|
-
modusa-0.4.
|
|
4
|
-
modusa-0.4.
|
|
5
|
-
modusa/__init__.py,sha256=
|
|
1
|
+
modusa-0.4.18.dist-info/METADATA,sha256=ijcc3CRYEE39kmdPI-3IbUqNJMLejQsDa3dxTOQMmYc,1467
|
|
2
|
+
modusa-0.4.18.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
|
|
3
|
+
modusa-0.4.18.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
|
|
4
|
+
modusa-0.4.18.dist-info/licenses/LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
|
|
5
|
+
modusa/__init__.py,sha256=Nz1_T0fAmYwdZRz5338H-VemTVvhJQplGeOPKpSXeTQ,324
|
|
6
6
|
modusa/config.py,sha256=bTqK4t00FZqERVITrxW_q284aDDJAa9aMSfFknfR-oU,280
|
|
7
7
|
modusa/decorators.py,sha256=8zeNX_wE37O6Vp0ysR4-WCZaEL8mq8dyCF_I5DHOzks,5905
|
|
8
8
|
modusa/devtools/generate_docs_source.py,sha256=UDflHsk-Yh9-3YJTVBzKL32y8hcxiRgAlFEBTMiDqwM,3301
|
|
@@ -44,7 +44,7 @@ modusa/tools/_plotter_old.py,sha256=KGow7mihA2H1WNq7s5bpivhCgGo2qVIeDaO6iabpsrg,
|
|
|
44
44
|
modusa/tools/ann_loader.py,sha256=BEdwAh_lccx_SnAO3bNMeY3O5zGiJlH2o4snWmXj8eQ,3034
|
|
45
45
|
modusa/tools/audio_converter.py,sha256=415qBoPm2sBIuBSI7m1XBKm0AbmVmPydIPPr-uO8D3c,1778
|
|
46
46
|
modusa/tools/audio_loader.py,sha256=n9Q9t_GmlE8AtioVwRcXX3rnd6PkbGTx-hAoNgUnNOQ,2780
|
|
47
|
-
modusa/tools/audio_player.py,sha256=
|
|
47
|
+
modusa/tools/audio_player.py,sha256=_OpRxImZAxfMB24MK9I8kgU8oqV5cKe8GZtDciCIYak,1512
|
|
48
48
|
modusa/tools/audio_recorder.py,sha256=K_LGqsPdjTdf3figEZTSQLmgMzYWgz18HTO8C1j5fE4,2788
|
|
49
49
|
modusa/tools/audio_saver.py,sha256=ldzfr_AydsHTnKbxmBLJblN-hLzTmOlppOm306xI4Ug,510
|
|
50
50
|
modusa/tools/base.py,sha256=C0ESJ0mIfjjRlAkRbSetNtMoOfS6IrHBjexRp3l_Mh4,1293
|
|
@@ -57,4 +57,4 @@ modusa/utils/excp.py,sha256=L9vhaGjKpv9viJYdmC9n5ndmk2GVbUBuFyZyhAQZmWY,906
|
|
|
57
57
|
modusa/utils/logger.py,sha256=K0rsnObeNKCxlNeSnVnJeRhgfmob6riB2uyU7h3dDmA,571
|
|
58
58
|
modusa/utils/np_func_cat.py,sha256=TyIFgRc6bARRMDnZxlVURO5Z0I-GWhxRONYyIv-Vwxs,1007
|
|
59
59
|
modusa/utils/plot.py,sha256=s_vNdxvKfwxEngvJPgrF1PcmxZNnNaaXPViHWjyjJ-c,5335
|
|
60
|
-
modusa-0.4.
|
|
60
|
+
modusa-0.4.18.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|