import compmusic.essentia
import subprocess

class Mp3ToWav(compmusic.essentia.EssentiaModule):
    __version__ = "0.1"
    __sourcetype__ = "mp3"
    __slug__ = "wav"

    __output__ = {"wave": {"extension": "wav", "mimetype": "audio/wave"}}

    def run(self, fname):
        proclist = ["lame", "--decode", fname, "-"]
        p = subprocess.Popen(proclist, stdout=subprocess.PIPE)
        audiocontents = p.communicate()[0]

        return {"wave": audiocontents}

import compmusic.essentia
import subprocess

import tempfile
import os

class Mp3ToWav(compmusic.essentia.EssentiaModule):
    __version__ = "0.3"
    __sourcetype__ = "mp3"
    __slug__ = "wav"

    __output__ = {"wave": {"extension": "wav", "mimetype": "audio/wave"}}

    def run(self, fname):
        fp, tmpname = tempfile.mkstemp(".wav")
        os.close(fp)
        proclist = ["lame", "--decode", "-x", fname, tmpname]
        p = subprocess.Popen(proclist)
        p.communicate()

        contents = open(tmpname, "rb").read()
        os.unlink(tmpname)
        return {"wave": contents}

use tempfile because lame needs to write to the file