Skip to main content

Desktop OMR tool for turning sheet music into annotations, audio, MIDI, and synchronized video.

Project description

PyClef logo

PyClef

Desktop Optical Music Recognition for annotations, MIDI, MP3, and synchronized video.

PyPI Python Platform Status Downloads

Website | PyPI | Repository


PyClef is a desktop Optical Music Recognition (OMR) tool for converting sheet music into annotated score pages, MIDI, MP3 audio, and synchronized video.

It combines neural symbol detection with staff-aware post-processing to make score recognition easier to inspect, hear, and review.

Features

  • PDF, PNG, JPG, and JPEG score input
  • Annotated score image output
  • MIDI export
  • MP3 audio rendering
  • Optional SoundFont piano rendering through FluidSynth
  • Synchronized MP4 video preview
  • Desktop interface with English and Portuguese support
  • Automatic model download on first use

Installation

Install PyClef from PyPI:

pip install pyclef

Then launch the desktop app:

pyclef

Or start it from Python:

from pyclef import Pyclef

Pyclef()

External Requirements

PyClef depends on a few external tools for full functionality.

Poppler

PDF input is handled through pdf2image, which requires Poppler.

On Windows, install Poppler and make sure the Poppler bin directory is available. The default path used by PyClef is:

C:\poppler\Library\bin

You can adjust this path in pyclef_app/config.py if needed.

FFmpeg

MP3 and video generation use audio/video processing libraries that may require FFmpeg.

Make sure FFmpeg is installed and available in your system PATH.

FluidSynth

PyClef includes an internal audio synthesizer by default. For a more realistic piano sound, the desktop app also provides a SoundFont piano option.

That option requires FluidSynth. Install FluidSynth and make sure the executable is available in your system PATH, or set:

PYCLEF_FLUIDSYNTH_PATH=/path/to/fluidsynth

On Windows PowerShell:

$env:PYCLEF_FLUIDSYNTH_PATH="C:\tools\fluidsynth\bin\fluidsynth.exe"
pyclef

Model File

The YOLO model is not bundled inside the PyPI package because the file is large.

When PyClef starts processing a score, it looks for the model in this order:

  1. PYCLEF_MODEL_PATH, if set.
  2. The user cache folder at ~/.pyclef/models/best.pt.
  3. Automatic download from PYCLEF_MODEL_URL.

By default, PYCLEF_MODEL_URL points to:

https://github.com/viniciusfs14/PyClef/releases/download/model-v1.0.0/best.pt.zip

If automatic download is available, PyClef will download and extract the model on first use.

For manual setup, place the model here:

~/.pyclef/models/best.pt

Or set the environment variable:

PYCLEF_MODEL_PATH=/path/to/best.pt

On Windows PowerShell:

$env:PYCLEF_MODEL_PATH="C:\path\to\best.pt"
pyclef

SoundFont Audio

The SoundFont file is not bundled inside the PyPI package. When SoundFont piano is selected, PyClef looks for the SoundFont in this order:

  1. PYCLEF_SOUNDFONT_PATH, if set.
  2. The user cache folder at ~/.pyclef/soundfonts/GeneralUser-GS.sf2.
  3. Automatic download from PYCLEF_SOUNDFONT_URL.

By default, PYCLEF_SOUNDFONT_URL points to the GeneralUser GS SoundFont:

https://raw.githubusercontent.com/mrbumpy409/GeneralUser-GS/main/GeneralUser-GS.sf2

For manual setup, place a .sf2 file anywhere and set:

PYCLEF_SOUNDFONT_PATH=/path/to/piano.sf2

On Windows PowerShell:

$env:PYCLEF_SOUNDFONT_PATH="C:\path\to\piano.sf2"
pyclef

Basic Workflow

  1. Open PyClef.
  2. Select a PDF or image score.
  3. Choose the outputs you want to generate.
  4. Set the BPM.
  5. Run processing.
  6. Open the generated result folder.

Each run creates a result folder named after the input file:

results_score-name/
  score-name_annotated_p1.jpg
  score-name.mp3
  score-name.mid
  score-name.mp4

The generated files depend on the output options selected in the interface.

Programmatic Usage

PyClef can also be called from Python:

from pyclef import process_score_files

result = process_score_files(
    file_list=["score.pdf"],
    bpm=90,
    output_options={
        "annotations": True,
        "audio": True,
        "midi": True,
        "video": False,
        "timbre": "soundfont_piano",
        "language": "en",
    },
)

print(result)

Example return value:

{
    "annotations": ["results_score/score_annotated_p1.jpg"],
    "audio": "results_score/score.mp3",
    "midi": "results_score/score.mid"
}

Research Context

PyClef is part of an Optical Music Recognition research workflow focused on turning object detection results into usable musical output.

The project uses MIRP, a staff-referenced musical inference method, to reconstruct pitch from detected symbols using staff geometry and clef context.

Project website:

https://viniciusfs14.github.io/PyClef/

Current Status

PyClef is under active development.

The current version is suitable for experimentation, demonstrations, and research-oriented score processing. Recognition quality can vary depending on scan quality, notation density, and symbol detection performance.

License

See the repository license for usage terms.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyclef-1.0.8.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyclef-1.0.8-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file pyclef-1.0.8.tar.gz.

File metadata

  • Download URL: pyclef-1.0.8.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for pyclef-1.0.8.tar.gz
Algorithm Hash digest
SHA256 8ddf20a9d5218fc6eca3a77db0c3657cd0911b4ad9a97dff342a325883a42d9c
MD5 352c31182fe687192bf8439122d7f87e
BLAKE2b-256 7d9a020c32c6254e5f80174c1eded84b2290130a2024987c3021c2f62c62b040

See more details on using hashes here.

File details

Details for the file pyclef-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: pyclef-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for pyclef-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5a879f0fa005f162a8490ab592ece4c5b73af9937fc73b021b3a42f85a7ce960
MD5 6419cd2c136d716c34d06f1e93eea941
BLAKE2b-256 96c01d0708d7a876eb1b525351a0f63e654bc7091a79432c0824ead1fb9f3eb5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page