Setup offline dictionary on Ubuntu with audio pronunciation

I use dict. dict is a CLI client dictd server (offline usage).

First allow the universe repo:


sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"

Install:

sudo apt-get install dict
sudo apt-get install dictd

Installing English dictionary databeses (gcide, wn, devil):

sudo apt-get install dict-gcide
sudo apt-get install dict-wn
sudo apt-get install dict-devil

Installing English Thesaurus database (moby-thesaurus):

sudo apt-get install dict-moby-thesaurus

It also supports various translation/bilingual disctionaries subpackages.

Usage:

  1. Using a particular database (eg. WordNet – wn):
    dict -d wn "buzz"
    
  2. Not specifying a dict-database will output definitions/translations/thesaurus from all available databases. eg.
    dict "buzz"
    

Audio pronunciation and phoneme mneumonics:

Let’s define a function that will use espeak for phoneme mnemonics and dict for definitions, thesauri, and others.

  • First install espeak (if it’s not already):
    sudo apt-get install espeak
    
  • Open the .bashrc file in your user-home directory with text editor of your choice:
    nano ~/.bashrc
    

    or

    gedit ~/.bashrc &
    

    (even better if you place your custom aliases and functions in ~/.bash_aliases rather than in ~/.bashrc)

  • Append the following function and save the file:
    function define {
    # espeak for the pronunciation audible output and phonetic alphabet string
    echo "Phoneme mnemonics: $(espeak -ven-uk-rp -x -s 120 "$1" 2> /dev/null)"       
    # dict - the client for the dictionary server
    dict "$1"       
    }
    

    [here I’ve used the switches -ven-uk-rp for British English Received Pronunciation (espeak --voices for more), -x to display mnemonics, -s for speech output speed. You can modify the switches for espeak or dict as per your needs.]

  • Open a new instance of terminal and use define to look for definitions. You should hear the pronunciation now. e.g.:
    define buzz
    

    or

    define buzz | less
  • Since I named the function as “define” you need to run define <wordname>. You can name your function differently and use the same for your query with the phoneme pronunciation. But if you don’t want to hear the pronunciation audio then you can just use the dict command as shown earlier.
    dict buzz | less

    (with less you can use arrow keys to scroll through the definitions; pressing h will show you some more controls that you can use; to quit press q)

Screenshot 2016-04-17 04:03:34

Advertisements

Here's your chance to type xoxo

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s