Harmonica
An independent reproduction of Harmonica: Accurate and Lightweight Instrument-Agnostic Music Transcription (Ou, Martel, Hennessy-Priest, Cho; arXiv:2609.04640). Audio of one pitched instrument goes in and its notes come out as MIDI, with no instrument label anywhere.
This is not the authors' code. Everything here was rebuilt from the paper. Where the paper leaves a detail unspecified, we filled it in with our own assumptions, so this implementation is not guaranteed to match the authors' exactly.
Transcribe a recording
uvx harmonica-amt song.wav # writes song.mid
uvx harmonica-amt song.flac -o out.mid # choose where the MIDI goes
uvx harmonica-amt song.wav --model x-large # the most accurate size; medium by default
Input can be WAV, FLAC, MP3, or OGG. Inference runs on a GPU if there is one, otherwise on the CPU.
Models
--model takes one of the sizes below or the path of a checkpoint. Each size
ships with the decoding thresholds its development-set sweep chose. Scores are
the mean OnP / OnPOff / Frm over the paper's eight test sets:
| Variant | Params | Ours | Paper |
|---|---|---|---|
| nano | 25K | .791 / .524 / .763 | .808 / .547 / .773 |
| small | 131K | .835 / .603 / .804 | .854 / .638 / .815 |
| medium (default) | 654K | .862 / .660 / .827 | .879 / .687 / .838 |
| large | 3.1M | .877 / .688 / .843 | .891 / .713 / .848 |
| x-large | 14.7M | .882 / .694 / .843 | .895 / .721 / .852 |
docs/results.md breaks the scores down by test set.
Python
from harmonica import Harmonica
model = Harmonica() # the bundled medium, on the GPU if there is one
notes = model.transcribe("song.wav")
notes.save_midi("song.mid")
for onset, offset, pitch in zip(notes.onsets, notes.offsets, notes.pitches):
print(f"{onset:.2f}-{offset:.2f}s MIDI {pitch}")
The model loads once, so reuse a Harmonica for many recordings. It also
takes a NumPy array with its sample rate, model.transcribe(audio, 44100),
and Harmonica(model, device=..., onset_threshold=..., frame_threshold=...)
picks another model, device, or thresholds.
Reproduce the paper
uv sync # Python 3.12+, a CUDA GPU
source .venv/bin/activate # puts harmonica on PATH
harmonica prepare --workers 16 # index the eight corpora
harmonica train --size medium # one row of the table above
harmonica eval --size medium \
--checkpoint outputs/harmonica-medium/checkpoints/checkpoint_latest.ckpt
- docs/data.md: where each corpus goes, the cache, and the splits.
- docs/training.md: configuration, ablations, resuming, and exporting weights.
- docs/evaluation.md: the threshold sweep, the metrics, and evaluating on many GPUs.
Citation
This repository reproduces the following paper; please cite it:
@article{ou2026harmonica,
title = {Harmonica: Accurate and Lightweight Instrument-Agnostic Music Transcription},
author = {Longshen Ou and H{\'e}ctor Martel and Joe Hennessy-Priest and Taemin Cho},
journal = {arXiv preprint arXiv:2609.04640},
year = {2026}
}
Metadata
Release files for harmonica-amt 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| harmonica_amt-0.2.0.tar.gz | 69.5 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| harmonica_amt-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 139.0 MB
Release files / harmonica_amt-0.2.0.tar.gz
| Download URL | harmonica_amt-0.2.0.tar.gz |
|---|---|
| Size | 69.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3bfdbe047faa6912be950ebf4f80c973199c078179b7fd5154df3c4d9b55256c
|
|
BLAKE2b-256 checksum How to use checksums |
c75e18055134608f9966c4797522435c996b1bce1533bcc67312e3fc987962e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / harmonica_amt-0.2.0-py3-none-any.whl
| Download URL | harmonica_amt-0.2.0-py3-none-any.whl |
|---|---|
| Size | 69.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6e54921729393e08e230179aaa528da79c5e2a43adfe7d53db1c9e83f40402ae
|
|
BLAKE2b-256 checksum How to use checksums |
f6dc7c824b6a2df5a8221f1aba3ce52dbc4033ddf0bf8d8485085980bef27033
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for harmonica-amt 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.