Skip to main content

Python bindings for WaoN - Wave-to-Notes transcriber

Reason this release was yanked:

non functional for transcription

Project description

WaoN Python Bindings

Python bindings for WaoN - Wave-to-Notes transcriber.

Installation

Building from Source

The Python bindings require the WaoN shared library to be built first. From the project root:

mkdir build
cd build
cmake .. -DBUILD_SHARED_LIB=ON -DBUILD_PYTHON_BINDINGS=ON
make

Installing with pip

Once built, you can install the Python package:

cd python
pip install .

For development installation:

pip install -e .

Requirements

  • Python >= 3.6
  • NumPy >= 1.16.0
  • pybind11 >= 2.6.0 (for building)
  • CMake >= 3.12 (for building)

Usage

Basic Usage

import waon

# Simple transcription with default settings
waon.transcribe_file("input.wav", "output.mid")

Advanced Usage

import waon

# Create transcriber and options
transcriber = waon.Transcriber()
options = waon.Options()

# Configure options
options.set_fft_size(4096)  # Larger FFT for better frequency resolution
options.set_hop_size(1024)  # Custom hop size
options.set_window(waon.WindowType.HANNING)
options.set_cutoff(-4.0)  # More sensitive cutoff
options.set_note_range(36, 84)  # C2 to C6
options.set_phase_vocoder(True)  # Enable phase vocoder

# Optional: set progress callback
def progress_callback(progress):
    print(f"Progress: {progress * 100:.1f}%")

transcriber.set_progress_callback(progress_callback)

# Perform transcription
transcriber.transcribe("input.wav", "output.mid", options)

Using NumPy Arrays

import waon
import numpy as np

# Generate or load audio data
sample_rate = 44100
audio_data = np.random.randn(sample_rate * 2)  # 2 seconds of noise

# Transcribe
waon.transcribe(
    audio_data,
    sample_rate,
    "output.mid",
    fft_size=2048,
    cutoff=-5.0,
    note_bottom=48,
    note_top=84
)

API Reference

Classes

Transcriber

Main transcription class.

  • transcribe(input_file, output_file, options=None): Transcribe audio file to MIDI
  • transcribe_data(audio_data, sample_rate, output_file, options=None): Transcribe NumPy array to MIDI
  • set_progress_callback(callback): Set progress callback function

Options

Configuration options for transcription.

  • set_fft_size(size): Set FFT size (must be power of 2)
  • set_hop_size(size): Set hop size (0 = auto, default is fft_size/4)
  • set_window(window): Set window type (WindowType enum)
  • set_cutoff(cutoff): Set cutoff ratio (log10)
  • set_note_range(bottom, top): Set MIDI note range to analyze
  • set_phase_vocoder(enable): Enable/disable phase vocoder
  • set_drum_removal(bins, factor): Set drum removal parameters
  • set_octave_removal(factor): Set octave removal factor

Enums

WindowType

  • NONE: No windowing
  • PARZEN: Parzen window
  • WELCH: Welch window
  • HANNING: Hanning window (default)
  • HAMMING: Hamming window
  • BLACKMAN: Blackman window
  • STEEPER: Steeper 30-dB/octave rolloff window

ErrorCode

  • SUCCESS: Operation successful
  • MEMORY: Memory allocation failed
  • FILE_NOT_FOUND: File not found
  • FILE_FORMAT: Invalid file format
  • INVALID_PARAM: Invalid parameter
  • IO: I/O error
  • INTERNAL: Internal error

Functions

  • version_string(): Get library version string
  • version(): Get library version as tuple (major, minor, patch)
  • transcribe_file(input_file, output_file, **kwargs): Convenience function for file transcription
  • transcribe(audio_data, sample_rate, output_file, **kwargs): Convenience function for array transcription

Exceptions

  • WaonError: Exception raised for WaoN-specific errors

Examples

See the examples/ directory for more detailed examples:

  • basic_transcription.py: Simple file transcription
  • advanced_transcription.py: Advanced options and progress callback
  • numpy_transcription.py: Using NumPy arrays

License

The Python bindings are released under the same license as WaoN (GPL v2 or later).

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

waon-0.10.tar.gz (128.0 kB view details)

Uploaded Source

Built Distribution

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

waon-0.10-py3-none-any.whl (123.4 kB view details)

Uploaded Python 3

File details

Details for the file waon-0.10.tar.gz.

File metadata

  • Download URL: waon-0.10.tar.gz
  • Upload date:
  • Size: 128.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for waon-0.10.tar.gz
Algorithm Hash digest
SHA256 697559d800e1205eca3bf202a7d8860ee15fefdc8b9a1ea90bbf9ebcbfcd4960
MD5 4c45cba99e580cdc949052dc1bb9e02d
BLAKE2b-256 1f1d47c334eea5108ca26fb9b1a51a26a80068ce3e2db99de5bdfbb84b3f5c9a

See more details on using hashes here.

File details

Details for the file waon-0.10-py3-none-any.whl.

File metadata

  • Download URL: waon-0.10-py3-none-any.whl
  • Upload date:
  • Size: 123.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for waon-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 21bd54379bb47c6c4e440a6815c78ebae150a1cc1b59619fcc09b28f5756adf6
MD5 46b0c4e1c9ed000941d1bb2f4f4af1c3
BLAKE2b-256 42ea11f52ec9fd229cb5aa468e7de28346ddf0c8154e1aa09fd0db6770dab5fb

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