Skip to main content

beets-romanize

License PyPI Python Version

This beets plugin lets you give your music Latin-script paths and/or tags, while your beets library keeps the metadata in its original scripts.

What is romanization?

Romanization is the process of writing a language in the Roman (Latin) script, via either transliteration (symbol by symbol) or transcription (by sound). The text stays in its original language. Japanese, for instance, is romanized as romaji, which spells out how its kanji and kana are read: 硝子の夢 becomes Garasu no Yume (硝子 → garasu, の → no, 夢 → yume), or Glass no Yume, spelling the loanword garasu as in English.

Translation, by contrast, carries the meaning over into another language: 硝子の夢 translates into English as Dream of Glass.

Either one offers Latin-script text to people who read it more easily than the original script, and beets-romanize supports both. Following MusicBrainz, its settings call romanized text a transliteration.

What beets does

There are three different places that beets writes things down:

  1. in the beets database (an SQLite file named library.db);
  2. in metadata tags embedded in the music files; and
  3. in the file paths of the music files.

Beets provides commands for keeping them in sync:

Sync Command
database → paths beet move
database → tags beet write
tags → database beet update

Metadata tags and the beets database both allow a wide range of Unicode characters including both Latin and non-Latin glyphs. But file paths on disk typically have stricter rules, with certain characters disallowed or considered problematic depending on the file system and individual user taste. For this reason, beets has an option called asciify_paths to purge or replace such characters when deciding the file path of each music track. This ASCIIfication feature is powered by the unidecode library, which is quite limited: it converts one character at a time and reads every kanji with its Mandarin reading, so e.g. the Japanese sequence この誰もいない部屋で becomes konoShui moinaiBu Wu de when it should be closer to Kono daremoinai heya de.

What beets-romanize does

Romanizing reliably is not possible in general: for example, 一日 reads as ichinichi or tsuitachi depending on meaning. Names in particular have irregular readings, with artists often inventing their own (see beets#1916).

To overcome such ambiguity and inconsistency, the beets-romanize plugin uses a series of steps when deciding how to romanize each character sequence:

Step Action Example
1 Consult your local overrides table 満-MITSURU- → MITSURU
2 For people, check MusicBrainz artist aliases and sort names 矢井田瞳 → Hitomi Yaida
3 For titles, check MusicBrainz pseudo-releases 硝子の夢 → Dream of Glass or Glass no Yume
4 For symbols unidecode drops or mangles, use readable ASCII LOVE☆ → LOVE(star), ♥♥ → (hearts)
5 For Japanese romanization in context, use cutlet この誰もいない部屋で → Kono dare mo inai heya de
6 Anything else non-ASCII (e.g. Korean, Cyrillic, Chinese) is left for asciify_paths

Steps 4 and 6 are for paths only: in tag mode, symbols and non-Japanese text stay as they are.

In other words: beets-romanize looks up what's already written down externally before falling back to heuristics and guessing.

Real-world examples

Here are some comparisons of unidecode, cutlet, and beets-romanize:

Transliteration from a pseudo-release. These are readings that only a person can know, because a word has several valid readings or is stylized:

Original unidecode cutlet beets-romanize
明日は今日と同じ未来 Ming Ri haJin Ri toTong ziWei Lai Asu wa kyou to onaji mirai Ashita wa Kyou to Onaji Mirai
漸-ZEN Jian -ZEN Susumu-ZEN ZEN

Translation from a pseudo-release. These are made-up names and English titles written in katakana:

Original unidecode cutlet beets-romanize
灰羽連盟 サウンドトラック ハネノネ Hui Yu Lian Meng saundotoratsuku hanenone Haiwa renmei Saundo torakku Hane no ne Haibane-Renmei Soundtrack HANENONE
LOVE☆トロピカ〜ナ デラックス LOVEtoropika~ na deratsukusu LOVE(star)Toro pika~Na Derakkusu Love Tropicana Deluxe
桜蘭高校ホスト部 サントラ & キャラソン集 前編 Ying Lan Gao Xiao hosutoBu santora & kiyarasonJi Qian Bian Sakura Ran koukou hosuto bu Santora & Kyarasonshuu Zenpen Ouran High School Host Club Soundtrack & Character Song Collection <First Part>

Romanization with cutlet. With no pseudo-release, cutlet reads kanji as Japanese rather than Mandarin, and splits words:

Original unidecode beets-romanize
この誰もいない部屋で konoShui moinaiBu Wu de Kono dare mo inai heya de
さよならを聴かせて sayonarawoTing kasete Sayonara wo kikasete
愛のカケラ Ai nokakera Ai no kakera

Cutlet is not perfect; the following examples are better than unidecode, but would still benefit from an override or a pseudo-release:

Original unidecode beets-romanize Ideal
ナイト・オブ・ナイツ naito*obu*naitsu Naito.obu.naitsu Night of Knights
カナコのサーフィンJPN kanakonosa-huinJPN Kana ko no saafin JPN Kanako no Surfin' JPN
ジェットにんぢん zietsutonindin Jetto ni n ji n Jet Ninjin

As shown above, English written in katakana is spelled as pronounced (unless foreign_spelling is set; see Configuration below), names can be split (カナコ, Kanako), and unfamiliar spellings (にんぢん, an old spelling of にんじん, ninjin) are read kana by kana.

Setup

  1. Install the plugin into the same environment as beets. To enable Japanese romanization, include the japanese extra, which installs cutlet and a dictionary of about 50 MB:

    pip install "beets-romanize[japanese]"
    
  2. Add romanize to the plugins: section of your beets config.

  3. Use the plugin's fields in your path formats, for example:

    asciify_paths: yes
    paths:
      default: $albumartist_latin/$album_latin%aunique{}/$track $title_latin
      singleton: Non-Album/$artist_latin/$title_latin
      comp: Compilations/$album_latin%aunique{}/$track $artist_latin - $title_latin
    
  4. Look up Latin names and titles for music you already have, then move the files to their new paths (check with beet move -p first):

    beet romanize
    beet move
    

    New imports are looked up automatically, before files move into place.

Path fields and functions

Every field below has a Latin form as a _latin field: $title_latin, $artist_latin, $composers_latin and so on.

Kind Fields Latin form from
Titles title, album, disctitle pseudo-release, else romanization
Other titles work, grouping, release_group_title romanization
Artists artist, albumartist, plus their _sort and _credit forms and the lists artists, albumartists, etc. MusicBrainz artist names, else romanization
Other people composers, lyricists, arrangers, remixers MusicBrainz artist names, else romanization
Labels label romanization

All of them apply the overrides and symbols first. Names capitalize every romanized word (Amano Tsuki); titles capitalize only the first (Kono dare mo...). Album fields (album, albumartist..., label, release_group_title) have _latin fields for albums too. Lists come out as beets shows them, e.g. Yuki Kajiura; Nobuo Uematsu.

The template functions %romanize{text} and %romanize_name{text} romanize any other value, as a title or a name. They apply the overrides, symbols and romanization, and %romanize_name also known artist names; but not pseudo-release titles, which belong to a particular item or album. Since they have no item to go by, they always read kanji as Japanese.

Kanji are read as Japanese unless the item's script or language is Chinese or Korean. To fix a misread release, set those fields, e.g. beet modify -a album:… script=Hant language=zho.

The romanize command

beet romanize [QUERY] looks up, for the matching items:

  • Artist names: Latin names for every non-Latin artist and album artist credit, from the MusicBrainz aliases of the credited artists. Aliases in the locales of beets' import.languages are preferred (English if that is empty), then any -Latn locale, then any other Latin alias. Among those, primary aliases win, then stage names over legal names, then names that agree with the sort name. With no Latin alias, the artist's Latin sort name is used (Yaida, Hitomi → Hitomi Yaida).
  • Other people: Latin names for non-Latin composers, lyricists, arrangers and remixers, the same way. Their artist IDs come from the items' composers_ids (and so on) where beets has them, or else from the release's relationships. Names are matched with spaces ignored, so 植松 伸夫 (as some sources write it) matches MusicBrainz's 植松伸夫.
  • Titles: for releases with non-Latin album, disc or track titles, Latin titles from their pseudo-releases.

beet romanize then writes the files whose tags are out of date: in tag mode, those whose Latin forms changed; otherwise, those still holding Latin forms from tag mode. beet romanize -p only lists them, and looks nothing up. Unlike beet write, it writes only the romanized fields' tags, and leaves the files' other tags alone.

Names and releases already looked up are skipped. beet romanize -f looks up everything again, which can rename folders if MusicBrainz changed (see Where the data is kept).

Only music matched to MusicBrainz (with an mb_albumid or mb_trackid) can be looked up; everything else gets only the overrides, symbols and romanization.

Differences from mbpseudo

beets' built-in mbpseudo plugin also uses MusicBrainz pseudo-releases, but for a different purpose: it replaces your metadata with the pseudo-release's, while beets-romanize keeps your metadata and adds Latin forms alongside it.

With beets-romanize, the database still holds the original titles, so you can still search for them, and the Latin forms are available as fields:

$ beet ls -a -f '$album | $album_latin' 硝子
硝子の夢 | Dream of Glass

With mbpseudo, if you pick the pseudo-release when importing, the album is stored as Dream of Glass (or Glass no Yume, whichever Latin-script pseudo-release MusicBrainz lists first), and beet ls -a 硝子 finds nothing: the original titles are not kept. Its custom_tags_only option instead keeps the originals and adds album_transl, title_transl and artist_transl fields to the database and the files' tags, but they are not used in paths unless you write path formats around them, and they are empty for anything without a pseudo-release.

Either way, mbpseudo takes only the album and track titles from the pseudo-release (and, with import.languages, artist aliases). Labels, composers and other people stay as on the original release, often in the original script, and are left to asciify_paths.

mbpseudo beets-romanize
Original metadata in the database Replaced (kept with custom_tags_only) Always kept
Latin forms in the files' tags Always (as the main tags, or as *_transl tags) Only with tags: yes, which keeps the originals in *_ORIGINAL tags; undone by beet romanize
When Only while importing While importing, or any time with beet romanize
Which pseudo-release The first in a wanted script By language: translation or transliteration, per languages and prefer
Without a pseudo-release Nothing Overrides, artist aliases, symbols, Japanese romanization (cutlet)
Fields Album and track titles, artists Also disc titles, composers, lyricists, arrangers, remixers, labels...

So mbpseudo suits you if you would rather your library were the pseudo-release: if you want the English or romanized release as your metadata, and are importing music that has one. beets-romanize suits you if the original-script metadata is what you want to keep, and you want readable paths (and, optionally, readable tags) for all of it, including music already in your library and music with no pseudo-release.

If you use mbpseudo to replace your metadata, beets-romanize can still fill in what it leaves alone: labels, composers and other people, and music with no pseudo-release. If you use its custom_tags_only mode, beets-romanize reads the title_transl and album_transl fields it writes, so switching keeps them, though beets-romanize replaces them where it finds a Latin title itself.

Configuration

Defaults shown:

romanize:
  auto: yes              # look up newly imported music
  titles: yes            # look up pseudo-release titles
  people: yes            # look up composers', lyricists'... names
  languages: [eng]       # translation languages, most preferred first
  prefer: translation    # or: transliteration
  foreign_spelling: no   # cutlet: モノクロレター -> "Monochrome letter"
  overrides: {}          # original text -> Latin form
  tags: no               # write Latin forms to the files' tags too

Translation or transliteration?

A release can have several Latin-script pseudo-releases: say, an English translation (Dream of Glass) and a romaji transliteration (Glass no Yume). A pseudo-release counts as a translation if its language is in languages (ISO 639-3 codes, as MusicBrainz uses: eng, deu, fra...), and as a transliteration if its language is that of the original release. Pseudo-releases in other languages are ignored. prefer picks which kind wins. Each title comes from the most preferred pseudo-release with a Latin form, so an incomplete translation is filled in from the transliteration.

Overrides

Overrides map original text to its Latin form, anywhere in a name or title, and take precedence over everything else. Longer keys win over shorter ones they contain. Use them to fix anything that comes out wrong:

romanize:
  overrides:
    早乙女乱馬: Ranma Saotome
    シャープネル: Sharpnel

Foreign spelling

With foreign_spelling, cutlet restores the original spelling of katakana loanwords (モノクロレター → Monochrome letter rather than Monokuro retaa). That is often nicer, but sometimes wrong: シャープネル (DJ Sharpnel) becomes sharp flannel.

Tag mode

The plugin always offers romanized values via dedicated *_latin fields (see path fields and functions above), while leaving the original/non-Latin values in place. For example:

Metadata Original value Romanized value DB field (original) Path field (romanized)
Title 硝子の夢 Glass no Yume title title_latin
Composers 梶浦由記; Nobuo Uematsu Yuki Kajiura; Nobuo Uematsu composers composers_latin

The tags setting controls whether, in a file's tags, each value gets filled from the original field (tags: no) or the romanized/_latin one (tags: yes):

Tag in file Source when tags: yes Source when tags: no
TITLE title_latin title
COMPOSER composers_latin composers
TITLE_ORIGINAL title not populated
COMPOSERS_ORIGINAL composers not populated

Every romanized field that beets writes to files is covered (all those under Path fields and functions except work and release_group_title). A *_ORIGINAL tag is added only where the Latin form differs. Unlike paths, tags need not be ASCII, so symbols stay as they are: LOVE☆ and Ænima are left alone, and only the Japanese in LOVE☆トロピカ〜ナ is romanized. These *_ORIGINAL tags are ordinary custom tags in each format (ID3 TXXX frames, Vorbis comments, MP4 freeform atoms, APEv2 and ASF attributes); players ignore them.

Since the database keeps the originals, commands like beet mbsync, beet modify, and re-imports work as usual, and the Latin forms are recomputed whenever a file is written. When reading files, beets reads a field's *_ORIGINAL tag where there is one, so beet update and imports do not mistake the Latin forms for new values, and beet write does not count them as changes. That also means beet write cannot tell when the Latin forms in a file are out of date, so use beet romanize for that:

  • Turning tag mode on: run beet romanize to write the Latin forms to your files. beet romanize -p lists which files would change first.

  • After changing overrides (or anything else that changes Latin forms): beet romanize again. It writes only files whose tags would change.

  • Turning tag mode off: beet romanize again (or -p first), which restores the original values and removes the *_ORIGINAL tags.

beet romanize writes only the tags of fields it romanizes (and their *_ORIGINAL tags), so tags that the files have but the database lacks (say, ISRCs from another tagger) survive, and so do Latin values that differ from the database's (leave those to beet write). Where a romanized field is empty in the database but not in a file (e.g. an ARTISTS tag from before beets had that field), the file's value is romanized. beet write, by contrast, writes every field from the database, and may remove tags that only the files have.

If another program changes a file's tags, beets still reads the *_ORIGINAL values; so to change a value, change it in beets.

Where the data is kept

Lookups are kept, so that paths stay the same until you ask otherwise:

  • Artist names (and other people's) go in romanize-names.json in the beets config directory, keyed by the name or credit as beets stores it. beet romanize only adds names not yet known; beet romanize -f looks them up again. Treat it like a lockfile rather than a cache: if MusicBrainz changes in the meantime, regenerating it can rename folders.
  • Titles go in the beets database as flexible attributes: title_transl and disctitle_transl (items) and album_transl (albums) hold the Latin titles; transl_release holds the MBID of the pseudo-release used, or none if there is none. title_transl and album_transl have the same names as in beets' mbpseudo plugin. They are not written to the files' tags (in tag mode, the Latin forms are, as TITLE and so on). Existing values (e.g. from mbpseudo) are kept unless a Latin title is found to replace them.
  • Releases whose people were looked up are recorded in transl_people (albums, or singleton items), as the MBID of the release, so that they are not looked up again.

Development

make test   # run the tests
make lint   # format and lint
make dist   # build release archives

These need uv.

Metadata

Release files for beets-romanize 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for beets-romanize 0.1.0
File Size Uploaded Provenance Actions
beets_romanize-0.1.0.tar.gz 50.9 kB Without provenance Details for beets_romanize-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for beets-romanize 0.1.0
File Interpreter ABI Platform Actions
beets_romanize-0.1.0-py3-none-any.whl Python 3 none any Details for beets_romanize-0.1.0-py3-none-any.whl

Total release size: 87.0 kB

Release files / beets_romanize-0.1.0.tar.gz

Download URL beets_romanize-0.1.0.tar.gz
Size 50.9 kB
Tags Source
SHA-256 checksum
How to use checksums
379923792f8456283f0906f2aadb3bafa5f0c1931b3516a8d03eae753dd938e2
BLAKE2b-256 checksum
How to use checksums
0a2424ffa0954c90207bd9b74e1bb99849490a7992c1b66c51e37279c638902a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / beets_romanize-0.1.0-py3-none-any.whl

Download URL beets_romanize-0.1.0-py3-none-any.whl
Size 36.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e23fc7aff7de96a48da7c29d94068d52d88106ee1074dcf48e4a06b6ed9f51a
BLAKE2b-256 checksum
How to use checksums
a6e4b22060d9fc9092030d1e072e7ce612b44b599988003e1f6de53064961854
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for beets-romanize 0.1.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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page