sung
Music data access: search and process chord sheets and lyrics from the chords&lyrics dataset, and search tracks and build playlists on Spotify.
Install
pip install sung
Agent skill
sung ships a sung-playlist agent skill (build a Spotify playlist from a list of songs) inside the package, in sung/data/skills/. Install it with gh skill install thorwhalen/sung sung-playlist, or link it from your pip installed copy: ln -s "$(python -c 'import sung, pathlib; print(pathlib.Path(sung.__file__).parent / "data/skills/sung-playlist")')" .claude/skills/sung-playlist.
Chords and Lyrics Processing
The sung package provides powerful tools for processing chord sheets and lyrics, including parsing, filtering, formatting, and rendering to various formats.
Basic Usage
from sung import render_chords_and_lyrics, search_songs
# Search for songs in the dataset
songs = search_songs(title="wonderwall", artist="oasis")
print(f"Found {len(songs)} songs")
# Get the raw chord sheet text
raw_text = songs.iloc[0]["chords&lyrics"]
# Render to text (reconstruct the original format)
formatted_text = render_chords_and_lyrics(raw_text, to="text")
print(formatted_text)
# Render to PDF
render_chords_and_lyrics(raw_text, to="pdf", output_path="song.pdf")
Advanced Features
Filter Non-Lyrics Content
Remove extraneous text that isn't part of the actual song. The keyword is apply_filter_non_lyrics -- filter_non_lyrics is the standalone function it delegates to, and passing that name as a keyword is silently ignored:
from sung import remove_non_lyrics
# Remove non-lyrics content (section headers, metadata, etc.)
clean_lyrics = render_chords_and_lyrics(
raw_text, to="text", apply_filter_non_lyrics=True
)
# Keep metadata lines like [Verse], [Chorus]
clean_with_metadata = render_chords_and_lyrics(
raw_text, to="text", apply_filter_non_lyrics=True, keep_metadata_lines=True
)
# Standalone function
clean_text = remove_non_lyrics(raw_text)
Pack Lines for Better Space Usage
Combine short lines to make better use of horizontal space:
from sung import pack_song_text
# Pack lines up to 80 characters
packed_text = render_chords_and_lyrics(
raw_text, to="text", pack_lines=True, max_line_length=80
)
# Standalone function
packed = pack_song_text(raw_text, max_length=80)
Combine Features
Use both filtering and packing together:
# Clean and optimized output
optimized = render_chords_and_lyrics(
raw_text,
to="text",
apply_filter_non_lyrics=True,
pack_lines=True,
max_line_length=80,
)
PDF Rendering with Custom Styling
# Custom fonts and spacing
render_chords_and_lyrics(
raw_text,
to="pdf",
output_path="styled_song.pdf",
page_size="LETTER", # Can use strings like 'A4', 'LETTER', 'LEGAL'
lyrics_font={"name": "Times-Roman", "size": 14, "color": "black"},
chords_font={"name": "Helvetica-Bold", "size": 12, "color": "blue"},
title_font={"name": "Helvetica-Bold", "size": 18, "color": "darkred"},
margin=50,
spacing_chord_lyrics=15,
spacing_group=20,
)
Dataset Access
The package provides access to a large dataset of songs with chords and lyrics:
from sung import get_lyrics_and_chords_dataset
# Load the full dataset (cached after first load)
df = get_lyrics_and_chords_dataset()
print(f"Dataset contains {len(df)} songs")
# A local copy of the zip is read directly, with no Kaggle credentials:
# pass zip_path=, or set SUNG_CHORDS_AND_LYRICS_ZIP, or keep it where haggle
# downloads it ($HAGGLE_ROOTDIR/zips/eitanbentora/chords-and-lyrics-dataset.zip).
# usecols= loads only the columns you need (the CSV is ~650 MB).
df = get_lyrics_and_chords_dataset(
usecols=["artist_name", "song_name", "chords&lyrics"]
)
# Search by multiple criteria
results = search_songs(
title="hotel california", artist="eagles", lyrics="welcome to the hotel"
)
Core Functions
render_chords_and_lyrics(): Main function for rendering chord sheetssearch_songs(): Search the song databaseparse_chord_lyrics(): Parse raw chord/lyrics text into structured datafilter_non_lyrics(): Remove non-lyrics contentpack_song_lines(): Combine short lines for better formattingextract_title(): Extract song title from chord sheetget_lyrics_and_chords_dataset(): Access the full dataset
Spotify
For spotify tools, you'll also need spotify API access info:
export SPOTIFY_API_CLIENT_ID="your_api_client_id"
export SPOTIFY_API_CLIENT_SECRET="your_api_client_secrete"
export SPOTIPY_REDIRECT_URI="http://127.0.0.1:8000/callback"
export SPOTIPY_CLIENT_ID="$SPOTIFY_API_CLIENT_ID"
export SPOTIPY_CLIENT_SECRET="$SPOTIFY_API_CLIENT_SECRET"
Spotify API credentials?
To obtain Spotify API credentials, follow these steps:
1. Create a Spotify Developer Account:
• Visit the [Spotify Developer Dashboard](https://developer.spotify.com/dashboard/).
• Log in with your Spotify account or create a new one.
2. Register a New Application:
• Click on “Create an App.”
• Provide an App Name and App Description.
• Agree to the Developer Terms of Service.
• Click “Create.”
3. Retrieve Client ID and Client Secret:
• After creating the app, you’ll be directed to the app’s dashboard.
• Here, you’ll find your Client ID and Client Secret.
• Keep these credentials secure; they are essential for API authentication.
4. Set Redirect URIs (if applicable):
• In your app settings, click “Edit Settings.”
• Under “Redirect URIs,” add the URIs where Spotify should redirect after authentication.
• This is crucial for certain authorization flows.
For detailed information on authorization flows and using your credentials, refer to Spotify’s Authorization Guide.
Ensure you handle your Client Secret securely and adhere to Spotify’s Developer Terms of Service.
Note on redirect URIs. Spotify rejects
http://localhostas "Insecure" since April 2025. Usehttp://127.0.0.1:PORT/callbackand add that exact value (no trailing slash, exact case) in your app dashboard's Redirect URIs.
Note on audio features. Spotify removed
/audio-featuresaccess for apps registered after Nov 2024.sungdegrades gracefully:Tracks.audio_featuresreturns{}with a one-time warning, andTracks.data/Playlist.datafall back to metadata-only.
Building a Spotify Playlist from a List of Song Names
Got a list of song names (from a setlist, a chat, a markdown doc) and want a playlist? Use playlist_from_songs — it searches Spotify for each song, picks the best match (preferring exact title + artist matches and filtering out covers/karaoke), and creates the playlist in one call.
from sung import playlist_from_songs
songs = [
("Clocks", "Coldplay"),
"Fix You — Coldplay", # also: "Title - Artist", "Title by Artist"
{"name": "Believer", "artist": "Imagine Dragons"},
"Radioactive", # title only is fine, but match quality drops
]
playlist, matches = playlist_from_songs(
songs,
playlist_name="My Mix",
# public=True, # default
# market="US", # optional ISO market code
# search_limit=10, # candidates to consider per song
# skip_missing=True, # drop unresolved instead of raising
)
print(playlist.playlist_url)
for m in matches:
print(m.summary())
if m.ambiguous:
for c in m.candidates[:3]:
print(
" alt:",
c["name"],
"—",
", ".join(c["artists"]),
"pop=",
c["popularity"],
)
matches is a list[SongMatch]. Each match exposes track_id, track_name, artist_names, album_name, popularity, plus ambiguous: bool (top two candidates are different songs/artists scoring within 10 points — worth showing alternatives) and not_found: bool.
CLI
For one-shot use from a file (or stdin), the same logic is wrapped as python -m sung.playlists:
# songs.txt — one song per line; "Title - Artist" or just "Title".
# Comment lines (#), markdown bullets (-, *, 1.), and **bold** are tolerated.
python -m sung.playlists songs.txt --name "My Mix"
# Inspect matches without creating the playlist:
python -m sung.playlists songs.txt --dry-run
# JSON report (for chaining):
python -m sung.playlists songs.txt --name "My Mix" --json
# stdin works too:
cat songs.txt | python -m sung.playlists - --name "My Mix"
Other flags: --private (default is public), --market US.
Lower-level building blocks
If you want to inspect matches before creating anything (or hand-tune ranking), the helper is a thin layer over:
parse_song_descriptor(...)— turn a descriptor into(name, artist)resolve_song(...)/resolve_songs(...)— search + rank, returnSongMatch(es)Playlist.create_from_track_list(...)— actually creates the playlistdelete_playlist(playlist_id, ask_confirmation=False)— clean up
A longer worked session (search results as a DataFrame, audio features, audio analysis) is in misc/docs/spotify_notebook.md.
Metadata
Release files for sung 0.0.36
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 | Actions |
|---|---|---|---|---|
| sung-0.0.36.tar.gz | 76.3 kB | Without provenance | Details for sung-0.0.36.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sung-0.0.36-py3-none-any.whl | Python 3 | none | any | Details for sung-0.0.36-py3-none-any.whl |
Total release size: 133.5 kB
Release files / sung-0.0.36.tar.gz
| Download URL | sung-0.0.36.tar.gz |
|---|---|
| Size | 76.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c985be9bba904adf4a3c9450401dfe6711cda6522b23ce5cf6d894221ddf37b9
|
|
BLAKE2b-256 checksum How to use checksums |
6440a3ec63d442cd3ef46d5f5f381aa5079363bfb354d7c9a309190d16f0046f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sung-0.0.36-py3-none-any.whl
| Download URL | sung-0.0.36-py3-none-any.whl |
|---|---|
| Size | 57.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c13a54ff03caf24c83b762483b20511c7209071366bb3910301f421686253c36
|
|
BLAKE2b-256 checksum How to use checksums |
0108975b8eb92984249437b1df7ff5c484cd889a23edd7e3702c2de0647412b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for sung 0.0.36
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.