modusa 0.4.17__tar.gz → 0.4.18__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.
- {modusa-0.4.17 → modusa-0.4.18}/PKG-INFO +1 -1
- {modusa-0.4.17 → modusa-0.4.18}/pyproject.toml +1 -1
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/__init__.py +1 -1
- modusa-0.4.18/src/modusa/tools/audio_player.py +60 -0
- modusa-0.4.17/src/modusa/tools/audio_player.py +0 -60
- {modusa-0.4.17 → modusa-0.4.18}/LICENSE.md +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/README.md +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/config.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/decorators.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/devtools/generate_docs_source.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/devtools/generate_template.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/devtools/list_authors.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/devtools/list_plugins.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/devtools/main.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/devtools/templates/generator.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/devtools/templates/io.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/devtools/templates/model.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/devtools/templates/plugin.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/devtools/templates/test.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/devtools/templates/tool.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/fonts/NotoSansDevanagari-Regular.ttf +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/generators/__init__.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/generators/audio.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/generators/audio_waveforms.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/generators/base.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/generators/ftds.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/generators/s1d.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/generators/s2d.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/generators/s_ax.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/generators/t_ax.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/generators/tds.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/models/__init__.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/models/audio.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/models/base.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/models/data.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/models/ftds.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/models/s1d.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/models/s2d.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/models/s_ax.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/models/t_ax.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/models/tds.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/plugins/__init__.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/plugins/base.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/tools/__init__.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/tools/_plotter_old.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/tools/ann_loader.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/tools/audio_converter.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/tools/audio_loader.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/tools/audio_recorder.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/tools/audio_saver.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/tools/base.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/tools/math_ops.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/tools/plotter.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/tools/youtube_downloader.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/utils/__init__.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/utils/config.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/utils/excp.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/utils/logger.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/utils/np_func_cat.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/src/modusa/utils/plot.py +0 -0
- {modusa-0.4.17 → modusa-0.4.18}/tests/__init__.py +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
from IPython.display import Audio, HTML, display
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
from IPython.display import Audio, HTML, display
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
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
|
|
15
|
+
|
|
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
|
+
"""
|
|
41
|
+
|
|
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}
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
display(HTML(html))
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
from IPython.display import Audio, HTML, display
|
|
4
|
-
import numpy as np
|
|
5
|
-
|
|
6
|
-
def play(y: np.ndarray, sr: float, clip: tuple[float, float] | None = None, label: str | None = None) -> None:
|
|
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").
|
|
21
|
-
|
|
22
|
-
Returns
|
|
23
|
-
-------
|
|
24
|
-
None
|
|
25
|
-
"""
|
|
26
|
-
start_time, end_time = 0.0, len(y) / sr
|
|
27
|
-
|
|
28
|
-
if clip is not None:
|
|
29
|
-
if not isinstance(clip, tuple) or len(clip) != 2:
|
|
30
|
-
raise ValueError("`clip` must be a tuple of (start_time, end_time)")
|
|
31
|
-
start_sample = int(clip[0] * sr)
|
|
32
|
-
end_sample = int(clip[1] * sr)
|
|
33
|
-
y = y[start_sample:end_sample]
|
|
34
|
-
start_time, end_time = clip
|
|
35
|
-
|
|
36
|
-
# Build the HTML table
|
|
37
|
-
audio_html = Audio(data=y, rate=sr)._repr_html_()
|
|
38
|
-
label_html = label if label is not None else "-"
|
|
39
|
-
|
|
40
|
-
table_html = f"""
|
|
41
|
-
<div style="display:inline-block; border:1px solid #ccc; border-radius:6px; overflow:hidden;">
|
|
42
|
-
<table style="border-collapse:collapse; font-family:sans-serif; font-size:14px;">
|
|
43
|
-
<tr style="background-color:#f8f8f8;">
|
|
44
|
-
<th style="padding:6px 12px; text-align:left; min-width:120px;">Timing</th>
|
|
45
|
-
<th style="padding:6px 12px; text-align:left;">Label</th>
|
|
46
|
-
<th style="padding:6px 12px; text-align:left;">Player</th>
|
|
47
|
-
</tr>
|
|
48
|
-
<tr>
|
|
49
|
-
<td style="padding:6px 12px; border-top:1px; solid #ddd; text-align:left">
|
|
50
|
-
{start_time:.2f}s → {end_time:.2f}s
|
|
51
|
-
</td>
|
|
52
|
-
<td style="padding:6px 12px; border-top:1px solid #ddd; text-align:left;">{label_html}</td>
|
|
53
|
-
<td style="padding:6px 12px; border-top:1px solid #ddd;">{audio_html}</td>
|
|
54
|
-
</tr>
|
|
55
|
-
</table>
|
|
56
|
-
</div>
|
|
57
|
-
"""
|
|
58
|
-
|
|
59
|
-
display(HTML(table_html))
|
|
60
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|