Listening to English audio with lyrics on Linux
To study English from movies is consistent with the methodology of praxis. GNU/Linux provides us a bunch of tools to extract audio and subtitle from videos as well as play the music file with scrolling lyrics. Using this study mode, we can focus on the English pronunciation, vocabulary and wording adopted in the script.
Generate lyrics from subtitle
-
Extract the audio from a video using
ffmpeg, for exampleffmpeg -i movie-file-name -vn -ar 44100 -ac 2 -b:a 192k -f mp3 movie-audio.mp3Here,
-ispecifies the input video file name,-vndisables the video,-arspecifies the audio sampling frequency in Hz,-acspecifies the number of audio channels,-b:asets the audio bitrate in kbit/s and-fspecifies the file format. -
Extract the embedded subtitle from
mkvInstall
mkvtoolnixandmkvtoolnix-guiusingapt-get. After opening amkvfile inmkvtoolnix-gui, select the English subtitle only and export it as amksfile. If the subtitle is an independent file, this step can be skipped.
-
Convert the subtitle file to lyrics using
ffmpegffmpeg -i subtitle-file-name subtitle.lrc
Compile and install the tool for displaying lyrics
-
Clone
osdlyricsfrom GitHubgit clone https://github.com/osdlyrics/osdlyrics.git - Install the following dependencies using
apt-getintltoollibdbus-glib-1-devandlibdbus-glib-1-dev-binpython3-futureandpython3-pycurl
-
Enter the cloned directory, compile and install
osdlyrics../autogen.sh ./configure PYTHON=/usr/bin/python3 make -j4 sudo make installHowever, after the installation,
osdlyricscannot be started reporting the following message, which indicates the error is caused byosdlyrics-daemon.Error: in function _start_daemon_cb: ol_main.c[769] Unable to start daemon: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.osdlyrics.Daemon exited with status 1
By manually running
osdlyrics-daemon, we can see that the Python moduleosdlyricscannot be found, even though it has been installed to/usr/local/lib/python3.7/site-packages. This is because the default path for searching packages by Python 3.7 should be/usr/local/lib/python3.7/dist-packagesinstead of...site-packages. Hence, creating a symbolic link under this path which points to/usr/local/lib/python3.7/site-packages/osdlyricssolves the problem.Traceback (most recent call last): File “/usr/local/lib/osdlyrics/daemon/main.py”, line 27, in
from osdlyrics import PACKAGE_VERSION ModuleNotFoundError: No module named 'osdlyrics' -
Run
osdlyricsfrom the command line and selectVLCas the associated music player. Even though my favorite music playerAudaciousis claimed to be supported, it actually does not work properly withosdlyricsat the moment. The command used byosdlyricsto startVLCis/usr/bin/vlc --started-from-file %U
Now the English movie audio can be played with a synchronously scrolling lyrics and a snapshot is given below. N.B. We can use VLC’s A-B mode to repeatedly listen to a fragment, which is very helpful for us to imitate the original pronunciation.

Scrolling lyrics