Friday, March 5, 2010

Patch to enable stardict to play mp3 audio

It goes without saying the most popular and free extensible multilingual dictionary on Linux is stardict so far. However, failing to play back mp3 or other compressed audio recordings is a serious drawback which leads up to falling behind Lingoes on Windows. After looking inside the source code, it's a piece of cake to achieve such a requirement.

Why stardict doesn't support mp3 or other compressed audio playback? Two key restraints are hard-coded:
  1. filename suffixes such as mp3 and ogg are filtered out.
  2. gnome_sound_play() accepting only wav formats is called to play audio recordings.
A web post had exposed valid modifications to remove the above restrictions. After performing some verifications on the ubuntu Linux platform, the modifications are rewritten into a distributable form. To apply the changes step by step, all you need to do are:
  1. download the source code stardict-3.0.1.tar.bz2
  2. download stardict-3.0.1-mp3.patch and configure.ubuntu
  3. tar jxf stardict-3.0.1.tar.bz2
  4. cd stardict-3.0.1
  5. patch -p1 < ../stardict-3.0.1-mp3.patch
  6. chmod +x ../configure.ubuntu
  7. ln -s ../configure.ubuntu
  8. ./configure.ubuntu
  9. make
  10. sudo make install
That's all. But be careful:
  • espeak should be installed before configuring stardict.
  • stardict has been configured to play audio by an external command, e.g. mplayer which has to be installed beforehand.
  • custom audio recordings need to be installed in the same form and location(i.e. /usr/share) specified by stardict.

No comments:

Post a Comment