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.
Files changed (62) hide show
  1. {modusa-0.4.17 → modusa-0.4.19}/PKG-INFO +1 -1
  2. {modusa-0.4.17 → modusa-0.4.19}/pyproject.toml +1 -1
  3. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/__init__.py +1 -1
  4. modusa-0.4.19/src/modusa/images/icon.png +0 -0
  5. modusa-0.4.19/src/modusa/tools/audio_player.py +102 -0
  6. modusa-0.4.17/src/modusa/tools/audio_player.py +0 -60
  7. {modusa-0.4.17 → modusa-0.4.19}/LICENSE.md +0 -0
  8. {modusa-0.4.17 → modusa-0.4.19}/README.md +0 -0
  9. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/config.py +0 -0
  10. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/decorators.py +0 -0
  11. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/generate_docs_source.py +0 -0
  12. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/generate_template.py +0 -0
  13. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/list_authors.py +0 -0
  14. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/list_plugins.py +0 -0
  15. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/main.py +0 -0
  16. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/templates/generator.py +0 -0
  17. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/templates/io.py +0 -0
  18. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/templates/model.py +0 -0
  19. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/templates/plugin.py +0 -0
  20. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/templates/test.py +0 -0
  21. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/devtools/templates/tool.py +0 -0
  22. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/fonts/NotoSansDevanagari-Regular.ttf +0 -0
  23. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/__init__.py +0 -0
  24. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/audio.py +0 -0
  25. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/audio_waveforms.py +0 -0
  26. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/base.py +0 -0
  27. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/ftds.py +0 -0
  28. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/s1d.py +0 -0
  29. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/s2d.py +0 -0
  30. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/s_ax.py +0 -0
  31. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/t_ax.py +0 -0
  32. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/generators/tds.py +0 -0
  33. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/__init__.py +0 -0
  34. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/audio.py +0 -0
  35. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/base.py +0 -0
  36. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/data.py +0 -0
  37. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/ftds.py +0 -0
  38. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/s1d.py +0 -0
  39. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/s2d.py +0 -0
  40. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/s_ax.py +0 -0
  41. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/t_ax.py +0 -0
  42. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/models/tds.py +0 -0
  43. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/plugins/__init__.py +0 -0
  44. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/plugins/base.py +0 -0
  45. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/__init__.py +0 -0
  46. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/_plotter_old.py +0 -0
  47. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/ann_loader.py +0 -0
  48. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/audio_converter.py +0 -0
  49. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/audio_loader.py +0 -0
  50. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/audio_recorder.py +0 -0
  51. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/audio_saver.py +0 -0
  52. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/base.py +0 -0
  53. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/math_ops.py +0 -0
  54. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/plotter.py +0 -0
  55. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/tools/youtube_downloader.py +0 -0
  56. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/utils/__init__.py +0 -0
  57. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/utils/config.py +0 -0
  58. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/utils/excp.py +0 -0
  59. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/utils/logger.py +0 -0
  60. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/utils/np_func_cat.py +0 -0
  61. {modusa-0.4.17 → modusa-0.4.19}/src/modusa/utils/plot.py +0 -0
  62. {modusa-0.4.17 → modusa-0.4.19}/tests/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: modusa
3
- Version: 0.4.17
3
+ Version: 0.4.19
4
4
  Summary: A modular signal analysis python library.
5
5
  Author-Email: Ankit Anand <ankit0.anand0@gmail.com>
6
6
  License: MIT
@@ -17,7 +17,7 @@ dependencies = [
17
17
  ]
18
18
  requires-python = ">=3.11"
19
19
  readme = "README.md"
20
- version = "0.4.17"
20
+ version = "0.4.19"
21
21
 
22
22
  [project.license]
23
23
  text = "MIT"
@@ -8,4 +8,4 @@ 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.17"
11
+ __version__ = "0.4.19"
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