Posts Tagged ‘linux’

Bash one-liner using sox to batch convert the sampling frequency of audio files

July 12, 2011

A bash one-liner to batch convert the sampling rate of WAV files using the SoX tool.  The example will resample *.wav files in the current directory to 8000Hz and place the output in an existing subdirectory called 8000Hz.

The one-liner below is overkill for this task, but the extra arguments provide a starting point for modification for related tasks.  The use of find/xargs should help the one-liner deal with very large numbers of audio files and filenames that contain whitespace.


find . -maxdepth 1 -name '*.wav' -type f -print0 | xargs -0 -t -r -I {} sox {} -r 8000 8000Hz/{}


Gnome “Show Desktop” applet that only minimizes all windows

June 28, 2011

The “show desktop” applet in Gnome is more like a toggle button that switches between minimizing all windows and restoring all windows. I’ve never found the restore all windows behavior useful, it requires an extra mouse click, and I’m always jolted by the temporary flash of restoring windows.

For those few souls who share this peeve there is a simple way to replace the applet with a version that always and only shows the desktop.  Reproducing ruizscar’s instructions here:

  1. Install "wmctrl" (i.e., sudo apt-get install wmctrl)
  2. Add a “Custom App Launcher” to the desktop panel bar with the command "wmctrl -k on"

If you want to completely reproduce the “show desktop” applet, you’ll need to also set the icon.  For the default Ubuntu/Gnome theme (as of 11.04), the icon is located at: "/usr/share/icons/Humanity/places/24/gnome-ccdesktop.svg".  Hopefully that’ll get you in the right neighborhood depending on the theme/panel size you run.

How to compile SRILM on Ubuntu

November 3, 2010

EDIT: This is my original post, but the comments have newer and better instructions.

I always encounter problems when compiling SRILM on Ubuntu.  Assuming the basic SRILM dependencies are installed on your system (see the Prerequisites), this works for SRILM 1.5.11 on Ubuntu 9.04 (Jaunty) and 10.04 (Lucid):

  1. Install tcsh if not already installed
  2. Install all the TCL developer libraries: tcl8.4-dev, tcl-dev, tcl-lib, tclx8.4, tclx8.4-dev.  This step may not be necessary, let me know what works for you.
  3. Uncomment the “SRILM =” line in the top level Makefile and replace the existing path with the absolute path of the SRILM top-level directory on your system (where the Makefile resides)
  4. Start the tcsh shell
  5. Type “make NO_TCL=X MACHINE_TYPE=i686-gcc4 World > & make.log.txt” to begin the build and capture stderr and stdout in a file
  6. If you can run “./bin/i686-gcc4/ngram-count -help“, the build was probably a success

Please add simplifications to this recipe or extensions to other versions of Ubuntu in the comments.

Mute annoying commercials

March 15, 2010

I love Pandora and I think they do a great job of monetizing their service.  The $1 surcharge on heavy use is pretty minimal and their audio ads are short and fairly infrequent.  However, I keep getting one audio ad that I absolutely hate but cannot ignore.  It pulls my attention away from what I’m doing and I am compelled to either take my headphones off or mute the sound to avoid accumulating aggravation.

The duct-tape solution for my Ubuntu box is a script that simply mutes the sound for 30 seconds.  I link to the script with an icon on Gnome’s toolbar and also map it to “CTRL-M” to allow for quick activation.  The script is below; the only thing you might need to do is change the soundcard index (the “0” in “-c 0 …”) on your system.

amixer -c 0 sset Master,0 mute
sleep 30
amixer -c 0 sset Master,0 unmute

Using Xournal to Annotate PDFs

September 13, 2009

Just came across an open source tool that allows easy annotation of PDF files: Xournal. One can add text, sketches, and highlighting and then export the result to a PDF.

Penumbra – First Person Horror Game on Linux

August 29, 2009

I just finished the first three installments of the Penumbra series.  Verdict: this game is great for the price!  It has a neat physics engine that allows manipulation of objects in the environment, so you do need to get comfortable with stacking boxes :)  It has good gameplay (running in terror from zombies while looking for an exit in the beam of your flashlight– no uzi’s in this game), and a decent plot.


Creative Zen on Hardy Heron Ubuntu Linux

September 27, 2008

An upcoming trip to DC motivated me to search for ways to upload videos on my Creative Zen mp3 player.  While Gnomad2 is good for managing audio, it doesn’t yet handle video uploads.  All the applications referred to are available through the Synaptic package manager.