carnatic-practice 0.1.0__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.
- carnatic_practice-0.1.0/.gitignore +19 -0
- carnatic_practice-0.1.0/LICENSE +21 -0
- carnatic_practice-0.1.0/PKG-INFO +211 -0
- carnatic_practice-0.1.0/README.md +176 -0
- carnatic_practice-0.1.0/THIRD_PARTY_NOTICES.md +36 -0
- carnatic_practice-0.1.0/pyproject.toml +72 -0
- carnatic_practice-0.1.0/src/carnatic_practice/__init__.py +3 -0
- carnatic_practice-0.1.0/src/carnatic_practice/__main__.py +3 -0
- carnatic_practice-0.1.0/src/carnatic_practice/analysis.py +264 -0
- carnatic_practice-0.1.0/src/carnatic_practice/cli.py +107 -0
- carnatic_practice-0.1.0/src/carnatic_practice/reports.py +99 -0
- carnatic_practice-0.1.0/src/carnatic_practice/svg.py +298 -0
- carnatic_practice-0.1.0/tests/conftest.py +46 -0
- carnatic_practice-0.1.0/tests/test_analysis.py +407 -0
- carnatic_practice-0.1.0/tests/test_cli.py +169 -0
- carnatic_practice-0.1.0/tests/test_integration.py +76 -0
- carnatic_practice-0.1.0/tests/test_reports.py +180 -0
- carnatic_practice-0.1.0/tests/test_svg.py +296 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Baiju Muthukadan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: carnatic-practice
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An offline pitch-practice companion for Carnatic music learners
|
|
5
|
+
Project-URL: Homepage, https://github.com/baijum/carnatic-practice
|
|
6
|
+
Project-URL: Repository, https://github.com/baijum/carnatic-practice
|
|
7
|
+
Project-URL: Issues, https://github.com/baijum/carnatic-practice/issues
|
|
8
|
+
Author: Baiju Muthukadan
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: THIRD_PARTY_NOTICES.md
|
|
12
|
+
Keywords: audio,carnatic,music,pitch,practice,swara
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Education
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Education
|
|
23
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Requires-Dist: numpy>=2
|
|
26
|
+
Requires-Dist: soundfile>=0.12
|
|
27
|
+
Requires-Dist: soxr>=0.3
|
|
28
|
+
Requires-Dist: swift-f0<0.4,>=0.3
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: build>=1.2; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
32
|
+
Requires-Dist: ruff>=0.9; extra == 'dev'
|
|
33
|
+
Requires-Dist: twine>=6; extra == 'dev'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# carnatic-practice
|
|
37
|
+
|
|
38
|
+
An offline command-line companion for Carnatic music learners. Give it a WAV
|
|
39
|
+
recording and your **Sa (Shadjam / shruthi)**; it detects held notes and reports
|
|
40
|
+
how their pitch compares with the swaras of your chosen raga.
|
|
41
|
+
|
|
42
|
+
Adapted from the practice-analysis tools developed for
|
|
43
|
+
[NaadamToRaagam](https://github.com/baijum/NaadamToRaagam). Pitch detection uses
|
|
44
|
+
[SwiftF0](https://github.com/lars76/swift-f0).
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
Requires **Python 3.11 or later**.
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
pip install carnatic-practice
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
For an isolated CLI installation, use `pipx install carnatic-practice` or
|
|
55
|
+
`uv tool install carnatic-practice` instead. Python dependencies and the SwiftF0
|
|
56
|
+
model are installed with the package dependencies. Analysis runs locally: no
|
|
57
|
+
recording is uploaded, and no account or API key is required.
|
|
58
|
+
|
|
59
|
+
## Quick start
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
# Default Sa: C3 (130.81 Hz); default raga: Mayamalavagowla.
|
|
63
|
+
carnatic-practice practice.wav
|
|
64
|
+
|
|
65
|
+
# Quote a tonic containing a sharp or a flat.
|
|
66
|
+
carnatic-practice practice.wav --sa 'A#'
|
|
67
|
+
carnatic-practice practice.wav --sa Bb3 --raga mohanam
|
|
68
|
+
|
|
69
|
+
# An explicit octave or a measured frequency in Hz.
|
|
70
|
+
carnatic-practice practice.wav --sa C4
|
|
71
|
+
carnatic-practice practice.wav --sa 130.81
|
|
72
|
+
|
|
73
|
+
# Save the report and a standalone SVG pitch plot.
|
|
74
|
+
carnatic-practice practice.wav --sa C --output report.md --svg pitch.svg
|
|
75
|
+
|
|
76
|
+
# Machine-readable report, or a list of supported ragas.
|
|
77
|
+
carnatic-practice practice.wav --format json > report.json
|
|
78
|
+
carnatic-practice --list-ragas
|
|
79
|
+
|
|
80
|
+
# Opt in to the original most-sung-pitch tonic estimator.
|
|
81
|
+
carnatic-practice practice.wav --sa auto
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`python -m carnatic_practice` is equivalent to `carnatic-practice`.
|
|
85
|
+
|
|
86
|
+
### Choosing Sa
|
|
87
|
+
|
|
88
|
+
A bare note such as `C`, `A#`, or `Bb` selects its frequency in the range
|
|
89
|
+
**100–200 Hz**, preserving the original analyzer's convention. In particular,
|
|
90
|
+
`C` means **C3**, not C4. Give an octave (`C4`, `A#2`, `Bb3`) or a positive
|
|
91
|
+
frequency (`130.81`) when you need a different register or a more precise tonic.
|
|
92
|
+
Unicode accidentals (`C♯3`, `B♭2`) are also accepted. Western note names use
|
|
93
|
+
A4 = 440 Hz; swara targets are relative to the supplied Sa.
|
|
94
|
+
|
|
95
|
+
`--sa auto` assumes that the most-sung pitch class, in its most-sung octave, is
|
|
96
|
+
Sa. This is a simple beginner-exercise heuristic, **not** a dedicated tonic
|
|
97
|
+
recognizer. Supplying your actual shruthi is more reliable.
|
|
98
|
+
|
|
99
|
+
### Supported ragas
|
|
100
|
+
|
|
101
|
+
| CLI name | Swaras above Sa |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `mayamalavagowla` (default) | Sa Ri1 Ga3 Ma1 Pa Da1 Ni3 |
|
|
104
|
+
| `shankarabharanam` | Sa Ri2 Ga3 Ma1 Pa Da2 Ni3 |
|
|
105
|
+
| `kalyani` | Sa Ri2 Ga3 Ma2 Pa Da2 Ni3 |
|
|
106
|
+
| `kharaharapriya` | Sa Ri2 Ga2 Ma1 Pa Da2 Ni2 |
|
|
107
|
+
| `harikambhoji` | Sa Ri2 Ga3 Ma1 Pa Da2 Ni2 |
|
|
108
|
+
| `mohanam` | Sa Ri2 Ga3 Pa Da2 |
|
|
109
|
+
| `hamsadhwani` | Sa Ri2 Ga3 Pa Ni3 |
|
|
110
|
+
| `chromatic` | All 12 reference swarasthanas |
|
|
111
|
+
|
|
112
|
+
The analyzer assigns each held note to the **nearest allowed swara**, across
|
|
113
|
+
octaves. It does not recognize the raga, know which note you intended to sing,
|
|
114
|
+
or align your recording to an exercise. Select the raga you practiced.
|
|
115
|
+
|
|
116
|
+
## Understanding the report
|
|
117
|
+
|
|
118
|
+
The default Markdown report includes each held note's time, swara, frequency,
|
|
119
|
+
pitch error in **cents**, and wobble, followed by per-swara and session summaries.
|
|
120
|
+
|
|
121
|
+
- **100 cents** is one semitone. Negative error is flat; positive error is sharp.
|
|
122
|
+
- **Wobble** is the standard deviation of pitch in cents during the held portion
|
|
123
|
+
of a note, after the initial slide-in is skipped. It is not a musical quality score.
|
|
124
|
+
- The summary counts notes within **±20 cents** of the reference. A warning marks
|
|
125
|
+
notes more than 50 cents away; also check your chosen raga and Sa in that case.
|
|
126
|
+
- A dot above a swara means an upper octave (`Ṡa`); a dot below means a lower
|
|
127
|
+
octave (`Ṇi`). The raga determines the variant, so display labels omit numbers.
|
|
128
|
+
|
|
129
|
+
`--format json` includes `source`, `sa_hz`, `sa_source`, `raga`, `reference`,
|
|
130
|
+
`notes`, `by_swara`, and `summary`. Note objects contain `start`, `end` (seconds),
|
|
131
|
+
`hz`, `swara`, `off` (cents), and `wobble` (cents). Raw frame-by-frame pitch arrays
|
|
132
|
+
are available through the Python API rather than included in every JSON report.
|
|
133
|
+
|
|
134
|
+
By default the report goes to standard output. `--output PATH` saves it instead.
|
|
135
|
+
`--svg PATH` additionally writes a self-contained pitch plot that can be opened
|
|
136
|
+
in a browser. Parent directories must already exist. Existing output files are
|
|
137
|
+
not replaced unless `--force` is supplied; the input recording, symlink outputs,
|
|
138
|
+
and conflicting report/plot paths are always protected.
|
|
139
|
+
|
|
140
|
+
### Recording tips and limitations
|
|
141
|
+
|
|
142
|
+
- Use a **WAV** file (`.wav` or `.wave`). Mono and multichannel WAVs are supported;
|
|
143
|
+
channels are averaged to mono. Export Audacity projects to WAV first.
|
|
144
|
+
- Use a clear, single melodic voice, with little background noise. A tanpura,
|
|
145
|
+
accompaniment, or another singer can confuse the pitch detector; it does not
|
|
146
|
+
separate sources.
|
|
147
|
+
- Hold practice swaras for at least about **0.3 seconds**, preferably longer.
|
|
148
|
+
Short blips are ignored and the beginning of each held note is skipped to
|
|
149
|
+
reduce the effect of sliding into it.
|
|
150
|
+
- The inherited detector range is **60–800 Hz**. Notes outside this range may be
|
|
151
|
+
missed; supplying a high Sa does not increase the detection range.
|
|
152
|
+
- Swara targets use rounded **just-intonation reference offsets**, not an
|
|
153
|
+
authoritative tuning system. Intonation varies by raga, phrase, and tradition.
|
|
154
|
+
Gamakas, expressive movement, and exercise correctness are not assessed.
|
|
155
|
+
- Use the results to choose one or two things to practice, not to grade musical
|
|
156
|
+
expression. Follow your teacher's guidance.
|
|
157
|
+
|
|
158
|
+
Invalid command arguments return exit status 2. Audio/analysis or output-writing
|
|
159
|
+
failures return 1; a successful report returns 0.
|
|
160
|
+
|
|
161
|
+
## Python API
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from pathlib import Path
|
|
165
|
+
from carnatic_practice.analysis import analyze
|
|
166
|
+
from carnatic_practice.reports import report
|
|
167
|
+
|
|
168
|
+
analysis = analyze(Path("practice.wav"), sa="C", raga="mayamalavagowla")
|
|
169
|
+
print(report(analysis))
|
|
170
|
+
# analysis.t and analysis.f0 contain frame timestamps and pitch (NaN if unvoiced).
|
|
171
|
+
# Use sa=None for explicit automatic tonic estimation.
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Development
|
|
175
|
+
|
|
176
|
+
```sh
|
|
177
|
+
uv sync --extra dev
|
|
178
|
+
uv run pytest
|
|
179
|
+
uv run ruff check .
|
|
180
|
+
uv build
|
|
181
|
+
uv run twine check --strict dist/*
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Tests synthesize their own audio; no practice recordings are included. Integration
|
|
185
|
+
tests run the real SwiftF0 detector. Use `uv run pytest -m 'not integration'` for
|
|
186
|
+
unit tests only.
|
|
187
|
+
|
|
188
|
+
### Releases
|
|
189
|
+
|
|
190
|
+
CI runs tests, lint, and distribution checks. Publication uses GitHub's OpenID
|
|
191
|
+
Connect identity through a PyPI trusted publisher; no upload token is stored in
|
|
192
|
+
the repository.
|
|
193
|
+
|
|
194
|
+
For the first release, the PyPI account owner must add a **pending publisher** at
|
|
195
|
+
<https://pypi.org/manage/account/publishing/> with these exact values:
|
|
196
|
+
|
|
197
|
+
- PyPI project name: `carnatic-practice`
|
|
198
|
+
- GitHub owner: `baijum`
|
|
199
|
+
- Repository: `carnatic-practice`
|
|
200
|
+
- Workflow filename: `publish.yml`
|
|
201
|
+
- GitHub environment: `pypi`
|
|
202
|
+
|
|
203
|
+
After configuring it, publish a GitHub release whose tag matches the package
|
|
204
|
+
version (for example, `v0.1.0`). The release workflow tests and builds the package,
|
|
205
|
+
then publishes the checked distributions from the `pypi` environment. PyPI
|
|
206
|
+
versions are immutable: increment `__version__` for every subsequent release.
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
[MIT](LICENSE). See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for attribution
|
|
211
|
+
and dependency notices.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# carnatic-practice
|
|
2
|
+
|
|
3
|
+
An offline command-line companion for Carnatic music learners. Give it a WAV
|
|
4
|
+
recording and your **Sa (Shadjam / shruthi)**; it detects held notes and reports
|
|
5
|
+
how their pitch compares with the swaras of your chosen raga.
|
|
6
|
+
|
|
7
|
+
Adapted from the practice-analysis tools developed for
|
|
8
|
+
[NaadamToRaagam](https://github.com/baijum/NaadamToRaagam). Pitch detection uses
|
|
9
|
+
[SwiftF0](https://github.com/lars76/swift-f0).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Requires **Python 3.11 or later**.
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
pip install carnatic-practice
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
For an isolated CLI installation, use `pipx install carnatic-practice` or
|
|
20
|
+
`uv tool install carnatic-practice` instead. Python dependencies and the SwiftF0
|
|
21
|
+
model are installed with the package dependencies. Analysis runs locally: no
|
|
22
|
+
recording is uploaded, and no account or API key is required.
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
# Default Sa: C3 (130.81 Hz); default raga: Mayamalavagowla.
|
|
28
|
+
carnatic-practice practice.wav
|
|
29
|
+
|
|
30
|
+
# Quote a tonic containing a sharp or a flat.
|
|
31
|
+
carnatic-practice practice.wav --sa 'A#'
|
|
32
|
+
carnatic-practice practice.wav --sa Bb3 --raga mohanam
|
|
33
|
+
|
|
34
|
+
# An explicit octave or a measured frequency in Hz.
|
|
35
|
+
carnatic-practice practice.wav --sa C4
|
|
36
|
+
carnatic-practice practice.wav --sa 130.81
|
|
37
|
+
|
|
38
|
+
# Save the report and a standalone SVG pitch plot.
|
|
39
|
+
carnatic-practice practice.wav --sa C --output report.md --svg pitch.svg
|
|
40
|
+
|
|
41
|
+
# Machine-readable report, or a list of supported ragas.
|
|
42
|
+
carnatic-practice practice.wav --format json > report.json
|
|
43
|
+
carnatic-practice --list-ragas
|
|
44
|
+
|
|
45
|
+
# Opt in to the original most-sung-pitch tonic estimator.
|
|
46
|
+
carnatic-practice practice.wav --sa auto
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`python -m carnatic_practice` is equivalent to `carnatic-practice`.
|
|
50
|
+
|
|
51
|
+
### Choosing Sa
|
|
52
|
+
|
|
53
|
+
A bare note such as `C`, `A#`, or `Bb` selects its frequency in the range
|
|
54
|
+
**100–200 Hz**, preserving the original analyzer's convention. In particular,
|
|
55
|
+
`C` means **C3**, not C4. Give an octave (`C4`, `A#2`, `Bb3`) or a positive
|
|
56
|
+
frequency (`130.81`) when you need a different register or a more precise tonic.
|
|
57
|
+
Unicode accidentals (`C♯3`, `B♭2`) are also accepted. Western note names use
|
|
58
|
+
A4 = 440 Hz; swara targets are relative to the supplied Sa.
|
|
59
|
+
|
|
60
|
+
`--sa auto` assumes that the most-sung pitch class, in its most-sung octave, is
|
|
61
|
+
Sa. This is a simple beginner-exercise heuristic, **not** a dedicated tonic
|
|
62
|
+
recognizer. Supplying your actual shruthi is more reliable.
|
|
63
|
+
|
|
64
|
+
### Supported ragas
|
|
65
|
+
|
|
66
|
+
| CLI name | Swaras above Sa |
|
|
67
|
+
|---|---|
|
|
68
|
+
| `mayamalavagowla` (default) | Sa Ri1 Ga3 Ma1 Pa Da1 Ni3 |
|
|
69
|
+
| `shankarabharanam` | Sa Ri2 Ga3 Ma1 Pa Da2 Ni3 |
|
|
70
|
+
| `kalyani` | Sa Ri2 Ga3 Ma2 Pa Da2 Ni3 |
|
|
71
|
+
| `kharaharapriya` | Sa Ri2 Ga2 Ma1 Pa Da2 Ni2 |
|
|
72
|
+
| `harikambhoji` | Sa Ri2 Ga3 Ma1 Pa Da2 Ni2 |
|
|
73
|
+
| `mohanam` | Sa Ri2 Ga3 Pa Da2 |
|
|
74
|
+
| `hamsadhwani` | Sa Ri2 Ga3 Pa Ni3 |
|
|
75
|
+
| `chromatic` | All 12 reference swarasthanas |
|
|
76
|
+
|
|
77
|
+
The analyzer assigns each held note to the **nearest allowed swara**, across
|
|
78
|
+
octaves. It does not recognize the raga, know which note you intended to sing,
|
|
79
|
+
or align your recording to an exercise. Select the raga you practiced.
|
|
80
|
+
|
|
81
|
+
## Understanding the report
|
|
82
|
+
|
|
83
|
+
The default Markdown report includes each held note's time, swara, frequency,
|
|
84
|
+
pitch error in **cents**, and wobble, followed by per-swara and session summaries.
|
|
85
|
+
|
|
86
|
+
- **100 cents** is one semitone. Negative error is flat; positive error is sharp.
|
|
87
|
+
- **Wobble** is the standard deviation of pitch in cents during the held portion
|
|
88
|
+
of a note, after the initial slide-in is skipped. It is not a musical quality score.
|
|
89
|
+
- The summary counts notes within **±20 cents** of the reference. A warning marks
|
|
90
|
+
notes more than 50 cents away; also check your chosen raga and Sa in that case.
|
|
91
|
+
- A dot above a swara means an upper octave (`Ṡa`); a dot below means a lower
|
|
92
|
+
octave (`Ṇi`). The raga determines the variant, so display labels omit numbers.
|
|
93
|
+
|
|
94
|
+
`--format json` includes `source`, `sa_hz`, `sa_source`, `raga`, `reference`,
|
|
95
|
+
`notes`, `by_swara`, and `summary`. Note objects contain `start`, `end` (seconds),
|
|
96
|
+
`hz`, `swara`, `off` (cents), and `wobble` (cents). Raw frame-by-frame pitch arrays
|
|
97
|
+
are available through the Python API rather than included in every JSON report.
|
|
98
|
+
|
|
99
|
+
By default the report goes to standard output. `--output PATH` saves it instead.
|
|
100
|
+
`--svg PATH` additionally writes a self-contained pitch plot that can be opened
|
|
101
|
+
in a browser. Parent directories must already exist. Existing output files are
|
|
102
|
+
not replaced unless `--force` is supplied; the input recording, symlink outputs,
|
|
103
|
+
and conflicting report/plot paths are always protected.
|
|
104
|
+
|
|
105
|
+
### Recording tips and limitations
|
|
106
|
+
|
|
107
|
+
- Use a **WAV** file (`.wav` or `.wave`). Mono and multichannel WAVs are supported;
|
|
108
|
+
channels are averaged to mono. Export Audacity projects to WAV first.
|
|
109
|
+
- Use a clear, single melodic voice, with little background noise. A tanpura,
|
|
110
|
+
accompaniment, or another singer can confuse the pitch detector; it does not
|
|
111
|
+
separate sources.
|
|
112
|
+
- Hold practice swaras for at least about **0.3 seconds**, preferably longer.
|
|
113
|
+
Short blips are ignored and the beginning of each held note is skipped to
|
|
114
|
+
reduce the effect of sliding into it.
|
|
115
|
+
- The inherited detector range is **60–800 Hz**. Notes outside this range may be
|
|
116
|
+
missed; supplying a high Sa does not increase the detection range.
|
|
117
|
+
- Swara targets use rounded **just-intonation reference offsets**, not an
|
|
118
|
+
authoritative tuning system. Intonation varies by raga, phrase, and tradition.
|
|
119
|
+
Gamakas, expressive movement, and exercise correctness are not assessed.
|
|
120
|
+
- Use the results to choose one or two things to practice, not to grade musical
|
|
121
|
+
expression. Follow your teacher's guidance.
|
|
122
|
+
|
|
123
|
+
Invalid command arguments return exit status 2. Audio/analysis or output-writing
|
|
124
|
+
failures return 1; a successful report returns 0.
|
|
125
|
+
|
|
126
|
+
## Python API
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from pathlib import Path
|
|
130
|
+
from carnatic_practice.analysis import analyze
|
|
131
|
+
from carnatic_practice.reports import report
|
|
132
|
+
|
|
133
|
+
analysis = analyze(Path("practice.wav"), sa="C", raga="mayamalavagowla")
|
|
134
|
+
print(report(analysis))
|
|
135
|
+
# analysis.t and analysis.f0 contain frame timestamps and pitch (NaN if unvoiced).
|
|
136
|
+
# Use sa=None for explicit automatic tonic estimation.
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Development
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
uv sync --extra dev
|
|
143
|
+
uv run pytest
|
|
144
|
+
uv run ruff check .
|
|
145
|
+
uv build
|
|
146
|
+
uv run twine check --strict dist/*
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Tests synthesize their own audio; no practice recordings are included. Integration
|
|
150
|
+
tests run the real SwiftF0 detector. Use `uv run pytest -m 'not integration'` for
|
|
151
|
+
unit tests only.
|
|
152
|
+
|
|
153
|
+
### Releases
|
|
154
|
+
|
|
155
|
+
CI runs tests, lint, and distribution checks. Publication uses GitHub's OpenID
|
|
156
|
+
Connect identity through a PyPI trusted publisher; no upload token is stored in
|
|
157
|
+
the repository.
|
|
158
|
+
|
|
159
|
+
For the first release, the PyPI account owner must add a **pending publisher** at
|
|
160
|
+
<https://pypi.org/manage/account/publishing/> with these exact values:
|
|
161
|
+
|
|
162
|
+
- PyPI project name: `carnatic-practice`
|
|
163
|
+
- GitHub owner: `baijum`
|
|
164
|
+
- Repository: `carnatic-practice`
|
|
165
|
+
- Workflow filename: `publish.yml`
|
|
166
|
+
- GitHub environment: `pypi`
|
|
167
|
+
|
|
168
|
+
After configuring it, publish a GitHub release whose tag matches the package
|
|
169
|
+
version (for example, `v0.1.0`). The release workflow tests and builds the package,
|
|
170
|
+
then publishes the checked distributions from the `pypi` environment. PyPI
|
|
171
|
+
versions are immutable: increment `__version__` for every subsequent release.
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
[MIT](LICENSE). See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for attribution
|
|
176
|
+
and dependency notices.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
The analysis and SVG rendering code was adapted from the author's
|
|
4
|
+
[NaadamToRaagam](https://github.com/baijum/NaadamToRaagam) practice-analysis
|
|
5
|
+
scripts. This standalone package does not include that project's recordings,
|
|
6
|
+
episode content, or production tools.
|
|
7
|
+
|
|
8
|
+
Pitch detection uses [SwiftF0](https://github.com/lars76/swift-f0), by Lars
|
|
9
|
+
Nieradzik. SwiftF0 is installed as a separate dependency; its implementation and
|
|
10
|
+
model are not bundled in the `carnatic-practice` wheel or source distribution.
|
|
11
|
+
SwiftF0 is MIT-licensed. Its notice is reproduced here for attribution:
|
|
12
|
+
|
|
13
|
+
> MIT License
|
|
14
|
+
>
|
|
15
|
+
> Copyright (c) 2025-2026 Lars Nieradzik
|
|
16
|
+
>
|
|
17
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
> of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
> in the Software without restriction, including without limitation the rights
|
|
20
|
+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
> copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
> furnished to do so, subject to the following conditions:
|
|
23
|
+
>
|
|
24
|
+
> The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
> copies or substantial portions of the Software.
|
|
26
|
+
>
|
|
27
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
> SOFTWARE.
|
|
34
|
+
|
|
35
|
+
NumPy, SoundFile, soxr, ONNX Runtime, and other transitive dependencies retain
|
|
36
|
+
their own licenses, distributed with those packages.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "carnatic-practice"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "An offline pitch-practice companion for Carnatic music learners"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE", "THIRD_PARTY_NOTICES.md"]
|
|
13
|
+
authors = [{ name = "Baiju Muthukadan" }]
|
|
14
|
+
keywords = ["carnatic", "music", "pitch", "swara", "practice", "audio"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"Intended Audience :: Education",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Programming Language :: Python :: 3.14",
|
|
25
|
+
"Topic :: Education",
|
|
26
|
+
"Topic :: Multimedia :: Sound/Audio :: Analysis",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"numpy>=2",
|
|
30
|
+
"soundfile>=0.12",
|
|
31
|
+
"soxr>=0.3",
|
|
32
|
+
"swift-f0>=0.3,<0.4",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
dev = ["pytest>=8", "ruff>=0.9", "build>=1.2", "twine>=6"]
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
carnatic-practice = "carnatic_practice.cli:main"
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/baijum/carnatic-practice"
|
|
43
|
+
Repository = "https://github.com/baijum/carnatic-practice"
|
|
44
|
+
Issues = "https://github.com/baijum/carnatic-practice/issues"
|
|
45
|
+
|
|
46
|
+
[tool.hatch.version]
|
|
47
|
+
path = "src/carnatic_practice/__init__.py"
|
|
48
|
+
|
|
49
|
+
[tool.hatch.build.targets.wheel]
|
|
50
|
+
packages = ["src/carnatic_practice"]
|
|
51
|
+
|
|
52
|
+
[tool.hatch.build.targets.sdist]
|
|
53
|
+
include = [
|
|
54
|
+
"/src",
|
|
55
|
+
"/tests",
|
|
56
|
+
"/pyproject.toml",
|
|
57
|
+
"/README.md",
|
|
58
|
+
"/LICENSE",
|
|
59
|
+
"/THIRD_PARTY_NOTICES.md",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
[tool.pytest.ini_options]
|
|
63
|
+
testpaths = ["tests"]
|
|
64
|
+
addopts = "-ra"
|
|
65
|
+
markers = ["integration: runs real SwiftF0 inference on synthetic WAV audio"]
|
|
66
|
+
|
|
67
|
+
[tool.ruff]
|
|
68
|
+
target-version = "py311"
|
|
69
|
+
line-length = 110
|
|
70
|
+
|
|
71
|
+
[tool.ruff.lint]
|
|
72
|
+
select = ["E4", "E7", "E9", "F"]
|