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.mp3
Here,
-i
specifies the input video file name,-vn
disables the video,-ar
specifies the audio sampling frequency in Hz,-ac
specifies the number of audio channels,-b:a
sets the audio bitrate in kbit/s and-f
specifies the file format. -
Extract the embedded subtitle from
mkv
Install
mkvtoolnix
andmkvtoolnix-gui
usingapt-get
. After opening amkv
file inmkvtoolnix-gui
, select the English subtitle only and export it as amks
file. If the subtitle is an independent file, this step can be skipped. -
Convert the subtitle file to lyrics using
ffmpeg
ffmpeg -i subtitle-file-name subtitle.lrc
Compile and install the tool for displaying lyrics
-
Clone
osdlyrics
from GitHubgit clone https://github.com/osdlyrics/osdlyrics.git
- Install the following dependencies using
apt-get
intltool
libdbus-glib-1-dev
andlibdbus-glib-1-dev-bin
python3-future
andpython3-pycurl
-
Enter the cloned directory, compile and install
osdlyrics
../autogen.sh ./configure PYTHON=/usr/bin/python3 make -j4 sudo make install
However, after the installation,
osdlyrics
cannot 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 moduleosdlyrics
cannot 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-packages
instead of...site-packages
. Hence, creating a symbolic link under this path which points to/usr/local/lib/python3.7/site-packages/osdlyrics
solves 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
osdlyrics
from the command line and selectVLC
as the associated music player. Even though my favorite music playerAudacious
is claimed to be supported, it actually does not work properly withosdlyrics
at the moment. The command used byosdlyrics
to startVLC
is/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