Metadata-Version: 2.5
Name: vocal-range-test
Version: 0.1.0
Summary: Estimate vocal range and voice type from pitch, notes, or audio takes.
Project-URL: Homepage, https://github.com/sherotree/vocal-range-test-py
Project-URL: Repository, https://github.com/sherotree/vocal-range-test-py
Project-URL: Issues, https://github.com/sherotree/vocal-range-test-py/issues
Project-URL: Documentation, https://github.com/sherotree/vocal-range-test-py#readme
Author-email: Sherotree <sherotree@users.noreply.github.com>
License-Expression: MIT
License-File: LICENSE
Keywords: audio,music,pitch,singing,vocal-range,voice-type,yin
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
Classifier: Topic :: Scientific/Engineering
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: numpy>=1.22
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# vocal-range-test

[Vocal Range Test](https://www.uwarp.design/vocal-range-test)

Headless Python library that turns pitch data into a vocal range and a voice-type estimate. Given lowest and highest pitches (as Hz, note names, a pitch contour, or audio takes), it reports note names, frequencies, semitone/octave span, and an estimated voice type among bass, baritone, tenor, alto, mezzo-soprano, and soprano.

This package **analyzes** range. It does not open a microphone, draw a UI, or perform network I/O.

## Install

```bash
pip install vocal-range-test
```

From a local checkout:

```bash
pip install -e ".[dev]"
```

**Formats:** WAV is decoded with the Python standard library. **MP3, M4A, and AAC require [`ffmpeg`](https://ffmpeg.org/) on your `PATH`.**

## Quick start

```python
from vocal_range_test import estimate_range

# Already-known low / high pitches (notes or Hz)
result = estimate_range(low="E2", high="E4")
print(result.low_note, result.high_note)          # E2 E4
print(result.semitone_span, result.octave_span)   # 24.0  2.0
print(result.voice_type)                          # bass

result = estimate_range(low=110.0, high=440.0)    # A2 – A4 → baritone
```

From a pitch contour (Hz sequence; unvoiced frames may be `None`):

```python
from vocal_range_test import estimate_from_contour

result = estimate_from_contour([98.0, 100.0, 110.0, 220.0, 330.0, 349.0])
print(result.voice_type)
```

From two sustained audio takes (low, then high):

```python
from vocal_range_test import estimate_from_audio

result = estimate_from_audio("low.wav", "high.wav")
print(result.to_dict())
```

## CLI

```bash
vocal-range-test --pitches E2 E4
vocal-range-test --pitches 82.41 329.63 --json
vocal-range-test --files low.wav high.wav
vocal-range-test --file take.wav
vocal-range-test --list-bands
```

## Voice-type classification bands

Classification compares your measured low–high MIDI span against typical published solo-voice ranges (see [Wikipedia — Voice type](https://en.wikipedia.org/wiki/Voice_type)):

| Voice type    | Typical range | MIDI (C4 = 60) |
| ------------- | ------------- | -------------- |
| bass          | E2 – E4       | 40 – 64        |
| baritone      | A2 – A4       | 45 – 69        |
| tenor         | C3 – C5       | 48 – 72        |
| alto          | F3 – F5       | 53 – 77        |
| mezzo-soprano | A3 – A5       | 57 – 81        |
| soprano       | C4 – C6       | 60 – 84        |

**Bands overlap.** The estimator scores each band by how many semitones of your span fall inside it and picks the best overlap. If nothing overlaps, the result is `mixed`. This is a **range-based estimate**, not a diagnosis — tessitura, timbre, and training also define voice type.

## Public API

| Symbol | Role |
| --- | --- |
| `estimate_range(...)` | Unified entry: pitches, contour, two takes, or one file |
| `estimate_from_pitches(low, high)` | Notes or Hz → range result |
| `estimate_from_contour(contour)` | Pitch contour → range result |
| `estimate_from_audio(low, high)` | Two audio takes / buffers → range result |
| `estimate_from_file(path)` | Single file contour percentiles → range result |
| `build_range(low_hz, high_hz)` | Pure math from two frequencies |
| `estimate_voice_type(low_midi, high_midi)` | Overlap classifier only |
| `voice_type_bands()` | Documented band table |
| `VocalRangeResult` | Notes, Hz, spans, and `voice_type` |

Pitch tracking for audio uses **YIN** (time-domain), after De Cheveigné & Kawahara (2002). Contour / take summaries use robust percentiles (20th for low, 80th for high) so brief pitch glitches weigh less than a sustained note.

## Development

```bash
pip install -e ".[dev]"
pytest
```

## License

MIT — see [LICENSE](LICENSE).
