modusa 0.4.14__tar.gz → 0.4.16__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.14 → modusa-0.4.16}/PKG-INFO +1 -1
- {modusa-0.4.14 → modusa-0.4.16}/pyproject.toml +1 -1
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/__init__.py +2 -2
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/tools/__init__.py +1 -1
- modusa-0.4.16/src/modusa/tools/audio_player.py +61 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/tools/plotter.py +37 -0
- modusa-0.4.14/src/modusa/tools/audio_player.py +0 -89
- {modusa-0.4.14 → modusa-0.4.16}/LICENSE.md +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/README.md +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/config.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/decorators.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/devtools/generate_docs_source.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/devtools/generate_template.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/devtools/list_authors.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/devtools/list_plugins.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/devtools/main.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/devtools/templates/generator.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/devtools/templates/io.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/devtools/templates/model.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/devtools/templates/plugin.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/devtools/templates/test.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/devtools/templates/tool.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/fonts/NotoSansDevanagari-Regular.ttf +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/generators/__init__.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/generators/audio.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/generators/audio_waveforms.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/generators/base.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/generators/ftds.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/generators/s1d.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/generators/s2d.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/generators/s_ax.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/generators/t_ax.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/generators/tds.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/models/__init__.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/models/audio.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/models/base.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/models/data.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/models/ftds.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/models/s1d.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/models/s2d.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/models/s_ax.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/models/t_ax.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/models/tds.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/plugins/__init__.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/plugins/base.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/tools/_plotter_old.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/tools/ann_loader.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/tools/audio_converter.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/tools/audio_loader.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/tools/audio_recorder.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/tools/audio_saver.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/tools/base.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/tools/math_ops.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/tools/youtube_downloader.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/utils/__init__.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/utils/config.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/utils/excp.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/utils/logger.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/utils/np_func_cat.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/src/modusa/utils/plot.py +0 -0
- {modusa-0.4.14 → modusa-0.4.16}/tests/__init__.py +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from modusa.utils import excp, config
|
|
2
2
|
|
|
3
3
|
#=====Giving access to plot functions to plot multiple signals.=====
|
|
4
|
-
from modusa.tools import dist_plot, hill_plot, fig
|
|
4
|
+
from modusa.tools import dist_plot, hill_plot, plot, fig
|
|
5
5
|
#=====
|
|
6
6
|
|
|
7
7
|
from modusa.tools import play, convert, record, save
|
|
8
8
|
from modusa.tools import download
|
|
9
9
|
from modusa.tools import load, load_ann
|
|
10
10
|
|
|
11
|
-
__version__ = "0.4.
|
|
11
|
+
__version__ = "0.4.16"
|
|
@@ -0,0 +1,61 @@
|
|
|
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;">Timing</th>
|
|
45
|
+
<th style="padding:6px 12px; text-align:left;">Label</th>
|
|
46
|
+
<th style="padding:6px 12px; text-align:left;">Audio</th>
|
|
47
|
+
</tr>
|
|
48
|
+
<tr>
|
|
49
|
+
<td style="padding:6px 12px; border-top:1px solid #ddd;">{start_time:.2f}s → {end_time:.2f}s</td>
|
|
50
|
+
<td style="padding:6px 12px; border-top:1px solid #ddd;">{label_html}</td>
|
|
51
|
+
<td style="padding:6px 12px; border-top:1px solid #ddd;">{audio_html}</td>
|
|
52
|
+
</tr>
|
|
53
|
+
</table>
|
|
54
|
+
</div>
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
display(HTML(table_html))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
@@ -1013,6 +1013,43 @@ def dist_plot(*args, ann=None, xlim=None, ylim=None, ylabel=None, xlabel=None, t
|
|
|
1013
1013
|
return fig
|
|
1014
1014
|
|
|
1015
1015
|
|
|
1016
|
+
# ======== Single Plot ===========
|
|
1017
|
+
def plot(*args):
|
|
1018
|
+
"""
|
|
1019
|
+
To create 1D/2D plot for immediate
|
|
1020
|
+
inspection.
|
|
1021
|
+
|
|
1022
|
+
Parameters
|
|
1023
|
+
----------
|
|
1024
|
+
*args: ndarray
|
|
1025
|
+
- Arrays to be plotted.
|
|
1026
|
+
"""
|
|
1027
|
+
n = len(args)
|
|
1028
|
+
|
|
1029
|
+
if n < 1:
|
|
1030
|
+
raise ValueError("Need atleast 1 positional argument")
|
|
1031
|
+
|
|
1032
|
+
## 1D Array
|
|
1033
|
+
if args[0].ndim == 1:
|
|
1034
|
+
if n > 1: # User also passed the xs
|
|
1035
|
+
fig = Fig("s").add_signal(args[0], args[1])
|
|
1036
|
+
else:
|
|
1037
|
+
fig = Fig("s").add_signal(args[0])
|
|
1038
|
+
|
|
1039
|
+
## 2D Array
|
|
1040
|
+
if args[0].ndim == 2:
|
|
1041
|
+
if n == 1:
|
|
1042
|
+
fig = Fig("m").add_matrix(args[0])
|
|
1043
|
+
elif n == 2: # User also passed the xs
|
|
1044
|
+
fig = Fig("m").add_matrix(args[0], args[1])
|
|
1045
|
+
elif n == 3:
|
|
1046
|
+
fig = Fig("m").add_matrix(args[0], args[1], args[2])
|
|
1047
|
+
|
|
1048
|
+
return fig
|
|
1049
|
+
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
|
|
1016
1053
|
|
|
1017
1054
|
|
|
1018
1055
|
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
import numpy as np
|
|
4
|
-
from IPython.display import display, HTML, Audio
|
|
5
|
-
|
|
6
|
-
def play(y: np.ndarray, sr: float, title = None, t0: float = 0.0, regions = None) -> None:
|
|
7
|
-
"""
|
|
8
|
-
Plays audio clips for given regions in Jupyter Notebooks.
|
|
9
|
-
|
|
10
|
-
Parameters
|
|
11
|
-
----------
|
|
12
|
-
y : np.ndarray
|
|
13
|
-
- Audio data.
|
|
14
|
-
- Mono (1D) numpy array.
|
|
15
|
-
sr: float
|
|
16
|
-
- Sampling rate of the audio.
|
|
17
|
-
title : str | None
|
|
18
|
-
- Title to display above audio players.
|
|
19
|
-
t0: float
|
|
20
|
-
- Starting timestamp, incase the audio is cropped
|
|
21
|
-
- Default: 0.0 → Starts from 0.0 sec
|
|
22
|
-
regions : list[tuple[float, float, str]] | tuple[float, float, str] | None
|
|
23
|
-
- Regions to extract and play (in sec), e.g. [(0, 10.2, "tag")]
|
|
24
|
-
- If there is only one region, a tuple should also work. e.g. (0, 10.2, "tag")
|
|
25
|
-
- Default: None → The entire song is selected.
|
|
26
|
-
|
|
27
|
-
Returns
|
|
28
|
-
-------
|
|
29
|
-
None
|
|
30
|
-
"""
|
|
31
|
-
if title:
|
|
32
|
-
display(HTML(f"<p style='font-size:15px; font-weight:600; text-decoration: underline; margin-left:10px'>{title}</p>"))
|
|
33
|
-
|
|
34
|
-
clip_tags = []
|
|
35
|
-
timings = []
|
|
36
|
-
players = []
|
|
37
|
-
|
|
38
|
-
if isinstance(regions, tuple): regions = [regions] # (10, 20, "Region 1") -> [(10, 20, "Region 1")]
|
|
39
|
-
|
|
40
|
-
if regions is not None:
|
|
41
|
-
for region in regions:
|
|
42
|
-
assert len(region) == 3
|
|
43
|
-
|
|
44
|
-
start_sec = region[0] - t0
|
|
45
|
-
end_sec = region[1] - t0
|
|
46
|
-
tag = region[2]
|
|
47
|
-
|
|
48
|
-
start_sample, end_sample = int(start_sec * sr), int(end_sec * sr)
|
|
49
|
-
clip = y[start_sample: end_sample]
|
|
50
|
-
audio_player = Audio(data=clip, rate=sr)._repr_html_()
|
|
51
|
-
|
|
52
|
-
clip_tags.append(f"<td style='text-align:center; border-right:1px solid #ccc; padding:6px;'>{tag}</td>")
|
|
53
|
-
timings.append(f"<td style='text-align:center; border-right:1px solid #ccc; padding:6px;'>{start_sec:.2f}s → {end_sec:.2f}s</td>")
|
|
54
|
-
players.append(f"<td style='padding:6px;'>{audio_player}</td>")
|
|
55
|
-
else:
|
|
56
|
-
audio_player = Audio(data=y, rate=sr)._repr_html_()
|
|
57
|
-
|
|
58
|
-
start_sec = t0
|
|
59
|
-
end_sec = t0 + y.shape[0] / sr
|
|
60
|
-
|
|
61
|
-
clip_tags.append(f"<td style='text-align:center; border-right:1px solid #ccc; padding:6px;'>1</td>")
|
|
62
|
-
timings.append(f"<td style='text-align:center; border-right:1px solid #ccc; padding:6px;'>{start_sec:.2f}s → {end_sec:.2f}s</td>")
|
|
63
|
-
players.append(f"<td style='padding:6px;'>{audio_player}</td>")
|
|
64
|
-
|
|
65
|
-
# Wrap rows in a table with border
|
|
66
|
-
table_html = f"""
|
|
67
|
-
<div style="display:inline-block; border:1px solid #ccc; border-radius:6px; overflow:hidden;">
|
|
68
|
-
<table style="border-collapse:collapse;">
|
|
69
|
-
<tr style="background-color:#f2f2f2;">
|
|
70
|
-
<th style="text-align:left; padding:6px 12px;">Clip</th>
|
|
71
|
-
{''.join(clip_tags)}
|
|
72
|
-
</tr>
|
|
73
|
-
<tr style="background-color:#fcfcfc;">
|
|
74
|
-
<th style="text-align:left; padding:6px 12px;">Timing</th>
|
|
75
|
-
{''.join(timings)}
|
|
76
|
-
</tr>
|
|
77
|
-
<tr>
|
|
78
|
-
<th style="text-align:left; padding:6px 12px;">Player</th>
|
|
79
|
-
{''.join(players)}
|
|
80
|
-
</tr>
|
|
81
|
-
</table>
|
|
82
|
-
</div>
|
|
83
|
-
"""
|
|
84
|
-
|
|
85
|
-
return HTML(table_html)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|