modusa 0.4.17__tar.gz → 0.4.19__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.19}/PKG-INFO +1 -1
- {modusa-0.4.17 → modusa-0.4.19}/pyproject.toml +1 -1
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/__init__.py +1 -1
- modusa-0.4.19/src/modusa/images/icon.png +0 -0
- modusa-0.4.19/src/modusa/tools/audio_player.py +102 -0
- modusa-0.4.17/src/modusa/tools/audio_player.py +0 -60
- {modusa-0.4.17 → modusa-0.4.19}/LICENSE.md +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/README.md +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/config.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/decorators.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/generate_docs_source.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/generate_template.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/list_authors.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/list_plugins.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/main.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/templates/generator.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/templates/io.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/templates/model.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/templates/plugin.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/templates/test.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/templates/tool.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/fonts/NotoSansDevanagari-Regular.ttf +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/__init__.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/audio.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/audio_waveforms.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/base.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/ftds.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/s1d.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/s2d.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/s_ax.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/t_ax.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/tds.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/__init__.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/audio.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/base.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/data.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/ftds.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/s1d.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/s2d.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/s_ax.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/t_ax.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/tds.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/plugins/__init__.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/plugins/base.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/__init__.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/_plotter_old.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/ann_loader.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/audio_converter.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/audio_loader.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/audio_recorder.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/audio_saver.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/base.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/math_ops.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/plotter.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/youtube_downloader.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/utils/__init__.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/utils/config.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/utils/excp.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/utils/logger.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/utils/np_func_cat.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/src/modusa/utils/plot.py +0 -0
- {modusa-0.4.17 → modusa-0.4.19}/tests/__init__.py +0 -0
|
Binary file
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from IPython.display import Audio, HTML, display
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
import numpy as np
|
|
13
|
+
import base64
|
|
14
|
+
|
|
15
|
+
def play(
|
|
16
|
+
y: np.ndarray,
|
|
17
|
+
sr: float,
|
|
18
|
+
clip: tuple[float, float] | None = None,
|
|
19
|
+
label: str | None = None,
|
|
20
|
+
) -> None:
|
|
21
|
+
"""
|
|
22
|
+
Audio player with optional clip selection, transcription-style label,
|
|
23
|
+
and an embedded bottom-right logo (../images/icon.png).
|
|
24
|
+
"""
|
|
25
|
+
start_time, end_time = 0.0, len(y) / sr
|
|
26
|
+
|
|
27
|
+
# Optional clip selection
|
|
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
|
+
# Load and embed logo image as base64
|
|
37
|
+
logo_path = Path(__file__).resolve().parent.parent / "images" / "icon.png"
|
|
38
|
+
logo_size = 40
|
|
39
|
+
logo_html = ""
|
|
40
|
+
logo_link = "https://meluron.github.io/modusa"
|
|
41
|
+
|
|
42
|
+
if logo_path.exists():
|
|
43
|
+
with open(logo_path, "rb") as f:
|
|
44
|
+
encoded_logo = base64.b64encode(f.read()).decode("utf-8")
|
|
45
|
+
|
|
46
|
+
# Wrap logo in <a> so it's clickable
|
|
47
|
+
logo_html = f"""
|
|
48
|
+
<a href="{logo_link}" target="_blank" style="text-decoration:none;">
|
|
49
|
+
<img src="data:image/png;base64,{encoded_logo}"
|
|
50
|
+
style="
|
|
51
|
+
position:absolute;
|
|
52
|
+
bottom:8px;
|
|
53
|
+
right:10px;
|
|
54
|
+
width:{logo_size}px;
|
|
55
|
+
height:{logo_size}px;
|
|
56
|
+
opacity:0.8;
|
|
57
|
+
transition:opacity 0.2s ease;
|
|
58
|
+
"
|
|
59
|
+
onmouseover="this.style.opacity=1.0"
|
|
60
|
+
onmouseout="this.style.opacity=0.8"
|
|
61
|
+
/>
|
|
62
|
+
</a>
|
|
63
|
+
"""
|
|
64
|
+
audio_html = Audio(data=y, rate=sr)._repr_html_()
|
|
65
|
+
|
|
66
|
+
label_html = f"""
|
|
67
|
+
<div style="
|
|
68
|
+
margin-top:4px;
|
|
69
|
+
padding:10px 12px;
|
|
70
|
+
background:#f7f7f7;
|
|
71
|
+
border-radius:6px;
|
|
72
|
+
color:#222;
|
|
73
|
+
font-size:14px;
|
|
74
|
+
line-height:1.5;
|
|
75
|
+
">
|
|
76
|
+
<strong>{start_time:.2f}s → {end_time:.2f}s:</strong>
|
|
77
|
+
<span style="margin-left:6px;">{label if label else ''}</span>
|
|
78
|
+
</div>
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
html = f"""
|
|
82
|
+
<div style="
|
|
83
|
+
display:inline-block;
|
|
84
|
+
position:relative;
|
|
85
|
+
border:1px solid #e0e0e0;
|
|
86
|
+
border-radius:10px;
|
|
87
|
+
padding:14px 18px 36px 18px;
|
|
88
|
+
background:#fff;
|
|
89
|
+
font-family:sans-serif;
|
|
90
|
+
max-width:520px;
|
|
91
|
+
box-shadow:0 1px 3px rgba(0,0,0,0.05);
|
|
92
|
+
">
|
|
93
|
+
{label_html}
|
|
94
|
+
<div style="margin-top:10px;">
|
|
95
|
+
{audio_html}
|
|
96
|
+
</div>
|
|
97
|
+
{logo_html}
|
|
98
|
+
</div>
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
display(HTML(html))
|
|
102
|
+
|
|
@@ -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
|