Waveform Necklace as a Service

Sept. 6, 2015

Python Tools Hardware 

Originally posted at https://tech.labs.oliverwyman.com/blog/2015/09/06/waveform-necklace-as-a-service/

I’m generally quite fond of laser cutters and cute crafting things done with them, so when I saw a Waveform Necklace Instructable the other day, I had to give it a go. Basic idea is that you take a sound recording’s waveform and reduce it’s waveform down to a level where it can be reasonably represented by a much smaller sequence of samples, and making a series of discs corresponding to the size of those samples.

Problem is, I got as far as step 2, and then couldn’t figure out how to get Audacity to look like the example. Of course, being a developer I figured that some work with NumPy could generate the whole thing for me and avoid all the boring counting steps. This worked, and I got the lovely folks at the MakersCafe (conveniently located just around the corner from LShift) to cut the pieces and I was able to make a necklace.

Having done this once, and knowing that people tend to use web services more than things where they’ve got to install something, I figured I’d try and get it up and running on Heroku. This turns out to be a bit more complicated than I thought, because it has a bunch of dependencies: NumPy, SciPy and Audiolab. All of these are tricky dependencies that require compilation and various libraries, which means that just dumping them into your pip requirements as per most Python stuff on Heroku won’t work.

Main way to solve this is the fun of custom Heroku buildpacks. Rather than just using the built-in Heroku build, we have to customise it a bit. Now, if all I needed was NumPy and SciPy, there’s a perfectly good buildpack for those but it doesn’t cope with Audiolab. Instead, I ended up using Conda, which (mostly) lets me specify these weirder dependencies and actually make it work on Heroku. I say “mostly”, because the Conda dependency system doesn’t let me specify that I need a package from one of the non-core places, so I ended up having to fork the Conda buildpack to do things manually, but this turns out to be really quite easy, which was surprising!

So, some effort later I have a little Flask website up and running that’ll let you generate your necklaces with a lot less effort than it took me. Patches, as always, welcomed.

Previously: Spark Core-based proxy Next: Kitten videos: an engineering approach