Help

Converting audios

Revision as of 20:41, 28 December 2023 by Yug (talk | contribs)

Converting audio files is a frequently needed task when serving audio files to target services and users.

How to convert large batch of audios ?

Dependencies

Warning : avconv have been removed from Ubuntu packages since 18.04. Use ffmpeg instead.
sudo apt-get install lame avconv
man lame                           # then search for parameters via "/{param}". ex: /-m

Technolect

  • cbr: constant bit rate.
  • abr: average bit rate.
  • vbr: variable bit rate.

For more, see man lame.

Helpers

mkdir -p ./new/                     # create folder, if not existing (-p)
file="./dir/audio-0a6f36g.flac"     # path to .flac file into varible "$file"
avconv -i "$file" 2>1               # print out metadata of $file, for some formats only

Simple batch format conversion

for file in ./flac/*.flac
do
  key=$(basename "$file" .flac).mp3                                 # name of the file minus .flac, plus .mp3 
  lame --abr 24    -m m -h --resample 22.05 "$file" "./new/$key";
done

Metadata-based format conversion

This example works on SWAC recorder audio files having the SWAC_TEXT metadata field. In this example, we assume a folder with file audio-0a6f36g.flac and metadata SWAC_TEXT : 很.

for file in ./flac/*.flac
do
  key=$(avconv -i "$file" 2>&1 | sed -ne 's/.*SWAC_TEXT *: //p')                 # print metadata, assign SWAC_TEXT's value to variable.
  lame --abr 24    -m m -h --resample 22.05 "$file" "./new-24k/cmn-$key.mp3";    # ex: cmn-很.mp3 (24k abr)
  lame --cbr -b 96 -m m -h --resample 22.05 "$file" "./new-96k/cmn-$key.mp3";    # ex: cmn-很.mp3 (96k cbr)
done

See also

Lingua Libre technical helps
Template {{Speakers category}} • {{Recommended lists}} • {{To iso 639-2}} • {{To iso 639-3}} • {{Userbox-records}} • {{Bot steps}}
Audio files How to create a frequency list?Convert files formatsDenoise files with SoXRename and mass rename
Bots Help:BotsLinguaLibre:BotHelp:Log in to Lingua Libre with PywikibotLingua Libre Bot (gh) • OlafbotPamputtBotDragons Bot (gh)
MediaWiki MediaWiki: Help:Documentation opérationelle MediawikiHelp:Database structureHelp:CSSHelp:RenameHelp:OAuthLinguaLibre:User rights (rate limit) • Module:Lingua Libre record & {{Lingua Libre record}}JS scripts: MediaWiki:Common.jsLastAudios.jsSoundLibrary.jsItemsSugar.jsLexemeQueriesGenerator.js (pad) • Sparql2data.js (pad) • LanguagesGallery.js (pad) • Gadgets: Gadget-LinguaImporter.jsGadget-Demo.jsGadget-RecentNonAudio.jsLiLiZip.js
Queries Help:APIsHelp:SPARQLSPARQL (intermediate) (stub) • SPARQL for lexemes (stub) • SPARQL for maintenanceLingualibre:Wikidata (stub) • Help:SPARQL (HAL)
Reuses Help:Download datasetsHelp:Embed audio in HTML
Unstable & tests Help:SPARQL/test
Categories Category:Technical reports