.metajson lyrics extract missing syllables
The lyrics extract in the .metajson
files generated by MuseScore 3 is missing syllables (usually when they fall on the second note of a tie, or possibly (not tested) on a rest).
I wrote this small XSLT transform (plus tiny sed cleanup script for some special characters) as shell oneliner for better lyrics extract (e.g. for uploading to free-scores.com
):
fn='/path/to/filename.mscx' # must be mscx, not mscz xmlstarlet <"$fn" sel -T -t \ -m '//*/Score' \ -i name \ -o '‣ Lyrics for part: ' -v name \ --else \ -o '‣ Lyrics:' \ -b \ -n \ -m Staff \ --var staffId=@id \ -o 'Staff ' -v '$staffId' \ -o ' (' -v '../Part[./Staff/@id=$staffId]/trackName' -o '):' \ -m './/Lyrics' -s A:N:- 'concat("0", no)' \ -i 'not(syllabic="middle" or syllabic="end")' \ -o ' ' \ -b \ -c text \ -b \ -n \ -b \ -b | sed \ -e $'s/\u00A0/ /g' \ -e $'s/\uE550/ /g' \ -e 's/ \{2,\}/ /g'
Hope this helps anyone!
PS: This does not handle repeats!
Comments
And here’s an XSLT 1.0 file (latest version on http://www.mirbsd.org/music/resources/xlyrics.xsl always) that extracts the lyrics in an orderly fashion into XML (per part, stave and verse): lyric-xslt.zip (PKZIP archive)
Use it as follows:
Note: both versions do not handle repeats!
In reply to And here’s an XSLT 1.0 file … by mirabilos
Apparently, some old MuseScore 2 files can miss the «syllabic»end«/syllabic» if a «syllabic»middle«/syllabic» is present; the lyrics text with the missing
syllabic
tag is then automatically an “end” syllabic.The XSLT shown here does not, cannot properly, handle that. I’m fixing up those files with a different script instead.
In reply to Apparently, some old… by mirabilos
… during which I discover that this also doesn’t handle lyrics in voices 2,3,4 well ☹
In reply to … during which I discover… by mirabilos
xlyrics.zip
A version that handles voices well (repeats still not, but these are pretty much out of scope). XSLT only though due to the complexity of handling MuseScore 2.x files.
(Only 2.x and 3.x are supported, who knows what format 4.x will use…)
In reply to Apparently, some old… by mirabilos
According to http://www.mirbsd.org/music/resources/syllabicfix some MuseScore 3 files are also affected. Gah!
At least I can fix that locally now.
In reply to According to http://www… by mirabilos
Erk… begin→begin and end→end also occur…
In reply to And here’s an XSLT 1.0 file … by mirabilos
Here’s xlyrics.zip an updated version with a wrapper script for the XSLT, the XSLT itself, and my script to fix up syllabics. The XSLT is optimised and commented better now.