Python SDK for Melogen AI - AI-powered music tools
Project description
melogenai — python sdk & cli for ai-powered music tools
python sdk and cli for melogen ai — convert sheet music to MIDI, transcribe audio to MIDI, and analyze music structure.
supports sync and async clients, streaming analysis, and a full-featured cli. convert PDFs, images, and audio files to MIDI with a single function call.
Installation
pip install melogenai
Quick Start
Python SDK
from melogenai import Melogen
client = Melogen(api_key="melo_xxx")
# Convert sheet music to MIDI
result = client.sheet2midi.convert(file_url="https://example.com/score.pdf")
final = client.sheet2midi.wait(result.task_id)
print(final.download_urls)
# Convert audio to MIDI
result = client.music2midi.convert(file_url="https://example.com/song.mp3")
final = client.music2midi.wait(result.task_id)
print(final.download_urls)
# Analyze music structure (streaming)
for chunk in client.analysis.analyze_stream(image_url="https://example.com/score.png"):
print(chunk, end="")
Async
from melogenai import AsyncMelogen
async with AsyncMelogen(api_key="melo_xxx") as client:
result = await client.sheet2midi.convert(file_url="https://example.com/score.pdf")
final = await client.sheet2midi.wait(result.task_id)
print(final.download_urls)
CLI
# Set your API key
export MELOGEN_API_KEY=melo_xxx
# Convert sheet music
melogen sheet2midi https://example.com/score.pdf
# Convert audio to MIDI
melogen music2midi https://example.com/song.mp3 --stems --quantize
# Analyze music
melogen analysis --image https://example.com/score.png --lang zh
# Verify API key
melogen auth verify
Services
| Service | Description | Input | Output |
|---|---|---|---|
sheet2midi |
Sheet music to MIDI | PDF, PNG, JPG | MIDI, MusicXML |
music2midi |
Audio to MIDI | MP3, WAV, FLAC, OGG, M4A | MIDI |
analysis |
Music structure analysis | MusicXML, image, PDF | Structured text |
Configuration
| Parameter | Env Var | Default |
|---|---|---|
api_key |
MELOGEN_API_KEY |
(required) |
base_url |
MELOGEN_BASE_URL |
https://api.melogen.ai |
timeout |
- | 30.0 |
poll_interval |
- | 2.0 |
poll_timeout |
- | 300.0 |
Error Handling
from melogenai import Melogen, AuthenticationError, TaskTimeoutError
client = Melogen(api_key="melo_xxx")
try:
result = client.sheet2midi.convert(file_url="https://example.com/score.pdf")
final = client.sheet2midi.wait(result.task_id)
except AuthenticationError:
print("Invalid API key")
except TaskTimeoutError:
print("Task took too long")
| Exception | HTTP Status | Cause |
|---|---|---|
AuthenticationError |
401 | Invalid or expired API key |
InsufficientCreditsError |
402 | Account out of credits |
ValidationError |
422 | Invalid parameters or unsupported format |
RateLimitError |
429 | Too many requests |
TaskTimeoutError |
— | Processing exceeded timeout |
TaskFailedError |
— | Server-side processing error |
Claude Code Skill
Install the melogen skill to use melogen directly in claude code:
npx @anthropic-ai/claude-code skills add melogenai/skills@melogen
Links
- Website: melogenai.com
- FAQ: melogenai.com/zh/faq
- Skills: github.com/melogenai/skills
- PyPI: pypi.org/project/melogenai
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file melogenai-0.1.0.tar.gz.
File metadata
- Download URL: melogenai-0.1.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8877d7eaf05d99da2c70622e59774a36936ab40f3f1776cf04c5c935834f6662
|
|
| MD5 |
eb5ab4b47d6712f7a4455942b6a32072
|
|
| BLAKE2b-256 |
1740622c7cd72379f3491b1939a75770234689c754c1e787d8490cacb21a12d9
|
File details
Details for the file melogenai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: melogenai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2af027b5d9b84d7f1cac1651b6021f9f02a9d49110899f91b60a7ab07bac8d4
|
|
| MD5 |
fb3e1430b3e76092db612a250eb54739
|
|
| BLAKE2b-256 |
6ccca5eae0f1d742c91d0a237dba6090b38b358a2dbf486bd38986c741aaaa34
|