There's some file metadata available via mw.title: https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#File_metadata
I was thinking this functionality could be used to enhance https://en.wikipedia.org/wiki/Template:Listen which suggests users to manually include length information.