Lame Programming with Echonest

Finally realized how simple it is to use a Queue to trade speed for memory. In other words handle the data a bit at a time.

All this code does is add the filenames from a specified directory into a queue, then one at a time make echonest.remix.LocalAudioFiles out of them and save them to the same directory.


"""
Experiment with echonest.remix and Queue
"""
# System modules
from Queue import Queue
from threading import Thread
import time
import glob
import echonest.remix.audio as audio
import pickle

q = Queue()

files = glob.glob('audio/*.mp3')

for f in files:
    q.put(f)
    
print(q.unfinished_tasks)

while not q.empty():
    file = q.get()
    audiofile = audio.LocalAudioFile(file)
    audiofile.save()
    q.task_done()

print("left are")    
print(q.unfinished_tasks)

with open('audio/Track01.mp3.analysis.en') as f:
    audiofile = pickle.load(f)

I think this module created by Peter Sobot will be useful, but not sure how to use it yet.

It interfaces with LAME, which is an MP# encoder that either is or includes a command-line interface.

Some instructions for how to install and test it with examples.

Note – echonest uses en-ffmpeg, which can be tested on your server via python interface:

In [1]: import os

In [2]: os.system("en-ffmpeg")

or simply from the command line with

macbookpro1:glitcher mikekilmer$ en-ffmpeg -version
FFmpeg version git-400098a, Copyright (c) 2000-2010 the FFmpeg developers
  built on Jan 15 2011 12:10:01 with gcc 4.0.0 (Apple Computer, Inc. build 5370)
  configuration: --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libmp3lame --enable-libx264 --enable-libfaac --target-os=darwin --disable-shared --enable-gpl --enable-pthreads --enable-nonfree
  libavutil     50.34. 0 / 50.34. 0
  libavcore      0.16. 0 /  0.16. 0
  libavcodec    52.99. 1 / 52.99. 1
  libavformat   52.88. 0 / 52.88. 0
  libavdevice   52. 2. 2 / 52. 2. 2
  libavfilter    1.69. 0 /  1.69. 0
  libswscale     0.12. 0 /  0.12. 0
FFmpeg git-400098a
libavutil     50.34. 0 / 50.34. 0
libavcore      0.16. 0 /  0.16. 0
libavcodec    52.99. 1 / 52.99. 1
libavformat   52.88. 0 / 52.88. 0
libavdevice   52. 2. 2 / 52. 2. 2
libavfilter    1.69. 0 /  1.69. 0
libswscale     0.12. 0 /  0.12. 0

 
Somehow missed that Sobot’s entire Forever.FM library is on GitHub!

Now need to get a better understanding of Socket programming both in overview and specifics.

… and some “advanced” logging.

… and Tornado