Saturday, November 03, 2012

Android Audiobook Speed Up

I like to listen to audiobooks. But the narration is way too slow on most books. I usually get CD audiobooks and rip them to my computer to listen to on a mobile device. I also listen to a lot of podcasts.

At first, I used an ipod nano. I would use itunes to rip audiobooks (or add podcasts). Then I'd create a playlist. I'd then be able to listen to the playlist at 1.5 speed without much trouble.

Then I won an iPod touch, and it all worked well.

Then I upgraded to the newer version of iOS and everything broke. The playlists were still there, but they seemed to play in random order. Nothing seemed to fix that. D'oh. What to do?

Luckily, I found that if I selected audiobook instead of playlist, I was able to listen to the books in proper order. Ok, Things were good.

Then I a won an iPad. (Talk about a string of luck!) Things sort of worked there also.

Then I upgraded the iPan to IOS5. This broke everything. The playlists were in random order. The Audiobooks were in random order. Some MP3 files didn't play. There was no option to play the audiobooks at a higher speed.

I wanted to downgrade. But, alas, there was no official Apple way to do it. Perhaps they would release an upgrade? Well, they finally did. But it didn't help. Uggh.

Time to swear off Apple. So I bought an Android phone. It could play all the files I had on iTunes. And it was open, so I could even write something to play audiobooks if I didn't like the existing players.

Unfortunately, Android Gingerbread does not support variable speed on playback. There are some apps that do. (And you could create an app using libraries and codecs). However, since I didn't need to use iTunes anymore, I wanted to see if there was a better approach.

The approach I chose was to speed up the original ripped audiobook files. This also has the advantage of reducing the filesize. I decided to use Ogg Vorbis file format because it was more readily supported by the tools. I was able to script the speedup process. The rip is still somewhat manual. I also use an mp3 tag editor to make sure the files are properly numbered. I find it easiest to rip each CD into one track, and then number each CD sequentially. This seems to get the order working properly in winamp and android media player. I also give all CDs the same album name. (The CDDB or FreeDB entries are notoriously bad for audiobooks.)

Perhaps this could be automated with a simple tool. Insert all the discs to have them ripped. Then enter the album name and author, and have everything sped up, tagged by rip date, and ready to go.

This was all done on windows, but most of the tools are cross-platform and could be easily run on mac or linux also.

Ripping: (I prefer to rip as .ogg with the entire CD as one file)
FreeAC:
http://www.freac.org/

Speeding up: Sox:
http://sourceforge.net/projects/sox/files/sox/

Example of speeding up:
http://www.ghodmode.com/blog/2009/01/speeding-up-netcasts-on-linux-with-sox/

A simple batch file to speed up everything in a directory

mkdir out
for %%p in (%1) do (
"C:\Program Files (x86)\sox-14-4-0\sox.exe" --show-progress --volume 1.2 "%%p" "out/%%p" tempo 1.5
)



Or from wave (loader)

"c:\Program Files (x86)\sox-14-4-0\sox.exe" --show-progress --volume 1.1 "Philip K Dick - Radio Free Albemuth.wav" -
C -1 out/pkd1.ogg tempo 1.5


Sox, alas, does not support all formats natively. If you have something in another format (like AAC aka M4A), you can use ffmpeg to convert:

http://ffmpeg.org/download.html

For windows, I use the latest statically linked version. (Either 32 or 64 bit depending on my system.) Since it comes in 7z format, you may also need to get the 7zip tool to decompress.


To convert to ogg, it is important to specify the codec (libvorbis) and the quality (-2 = very low quality). Otherwise, it will convert to super high quality ogg. (Which does't make sense for audiobooks - especially ones ripped at low quality.)

ffmpeg.exe -i "10-01 roughing it.m4a" -acodec libvorbis -aq -2 "10-01 roughing it.ogg"


Here is a simple batch file I use to convert itunes files. It assumes that both sox and ffmpeg are in your PATH. (If not, you can specify the complete path.) It can take directories or file names on the command line. It will convert all m4a files to ogg, and speed than up..


echo off

echo Converting all .m4a files passed or in directories in to 1.5X .ogg files

rem echo DIR:%1
for %%p in (%*) do (
rem echo WALKING:%%p
rem echo "EXT:"%%~xp
rem recursively walk directories
if exist %%p\ call :WALKDIR %%p
rem manually convert any m4as that were passed
if "%%~xp" EQU ".m4a" call :OGGIT %%p
)
goto :EOF

:OGGIT
echo OGGING:%1
if not exist "%~p1\out" mkdir "%~p1\out"
ffmpeg.exe -y -i %1 -acodec libvorbis -aq -2 "%~p1\%~n1.ogg"
sox.exe --show-progress --volume 1.1 "%~p1/%~n1.ogg" "%~p1/out/%~n1.ogg" tempo 1.5
goto :EOF

:WALKDIR
echo WALKDIR:%1
for /r %1 %%G IN (*.m4a) do call :OGGIT "%%G"
goto :EOF


MP3tag:
http://www.mp3tag.de/en/

I'll use the track numbering wizard to number all sequentially or extract from filename if we have good numbers there.

If the files are not in a sox format, then you can convert them using ffmpeg

mkdir out
for %%p in (%1) do (
C:\ffmpeg-20120426-git-a4b58fd-win64-static\bin\ffmpeg.exe -y -i "%%p"
-acodec libvorbis "%%~np.ogg"
"C:\Program Files (x86)\sox-14-4-0\sox.exe" --show-progress --volume 1.1 "%%~np.ogg" "out/%%~np.ogg" tempo 1.5
)


Other taggers (open source):
http://sourceforge.net/projects/easytag/
http://sourceforge.net/projects/kid3


[a few updates - feb 7, 2013]
I've found myself using itunes for the ripping. It uses the "paid" CDDB and it doesn't throttle rip speed like winamp. The quality also seems a little better, even with the extra conversion step.

I tried doing a flac -> ogg, but since flac doesn't have metadata m4a worked better.

I've also tried "whole disc" rip and "give every track the same name" rip. Neither worked well. Best was to rip each track as is. If names didn't come from gracenote, I'd generate a name from track number (after track ordering.) this allows for easy last.fm lookup if something odd happens.

I've also pondered putting everything on google music, but my upload speeds are awful.

No comments:

Post a Comment