Archive

Archive for the ‘Code’ Category

Too Many Podcasts, Too Little Time…

September 28th, 2009 Xoke 3 comments

No I don’t want to stop listening to some of my podcasts, but seriously TLLTs takes forever to catch up on!

So I’ve been reading up on / talking to people about speeding up the playback of podcasts.  You can play them through mplayer (CLI version) and press ] to increase the speed, but the people end up sounding like chipmunks.  Whilst this may be an improvement for Dann, other people sound terrible this way.

SoX is a cool command that will sort this out for you.  You can increase the ‘tempo’ without adjusting the pitch.  I want to have a script to amend this that can be called after bashpodder so it’s a one-stop-shop to fix everything.

To install SoX (and let it handle MP3 files):

sudo apt-get install sox libsox-fmt-mp3

So far I have:

#!/bin/bash
##################################################
#
#                       LICENSE
#
##################################################
#
# Xoke's Speed Increase script for Podcasts
# Copyright (C) 2009 Xoke
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details <http://www.gnu.org/licenses/>.

# I added a bit of a version control section here to mark any changes to the code
##################################################
#
#                       Versions
#
##################################################
#
# Ver    Date            Author        Description
# ------------------------------------------------------------------------------------
# 0.1        Sep 2009    Xoke        Initial Version

# Increase tempo of podcasts for today
#    Issues:
#        Assumes bashpodder is running
#        Probably has issues being run twice in one day
#        Doesn't tidy up after itself
#        mp3s become *.mp3.ogg

# Make script crontab friendly:
cd $(dirname $0)

# Speed Increase - change this to change
# the speed.
incspeedby=1.5

# datadir is the directory you want podcasts saved to:
datadir=$(date +%Y-%m-%d)

# Move into directory
cd $datadir

# Find all the MP3s
list=`ls *.mp3`
for currfile in $list
do
 echo $currfile
 # Process them
 sox $currfile z$currfile.ogg tempo $incspeedby
done

# Find all the OGGs
list=`ls *.ogg`
for currfile in $list
do
 echo $currfile
 # Process them
 sox $currfile z$currfile tempo $incspeedby
done

This will go into the current date directory, as per bashpodder.  This means if you run it twice in one day it will have problems as it will try to increase the tempo of the files already increased… which will be a problem.  It will convert mp3 files to ogg as the Jaunty version of SoX does not come with MP3 export capabilities.  This means HPR069.mp3 becomes zHPR069.mp3.ogg which is a little annoying, but not a huge problem.  The files all get a ‘z’ appended to the front, as I didn’t want to delete the old files without testing this on a lot of different files!  The next version (after lots of testing) will remove the old files and tidy things up!  Also this takes a while to run to convert files.

If you think 1.5x speed is too fast (or too slow if you’re Kajarii!) then you can change the incspeedby variable to change both mp3 and ogg.

Apart from that, I posted it here and not under ‘tips’ so everyone on the planet can look and let me know if I’m missing something, or if there is a better way of doing it.  I did google however most people are converting the MP3s to WAV files to increase the tempo and then recompress them!

Categories: Code, Creative Commons, Podcasts Tags: