1

I am building a client-server application using python and javascript. In the frontend, i'm recording audio using recorder.js. After some fixed interval, i use exportWav() and send the audio file to the server. At the backend i now need to concatenate these files to make the bigger audiofile again.

I saw this question, but i don't have actual .wav files, just the blobs returned by exportWav.

I'm also using app engine, so i cannot write output to a wav file. I need to create another audioblob that i can store in the datastore.

Any ideas?

Community
  • 1
  • 1
vipluv
  • 607
  • 5
  • 8

1 Answers1

1

Is each segment the complete binary data for a wav file? You'll need to use some kind of format-aware library to concatenate the wavs. The implementation you choose is up to you, but of course it will need to be in python. On the other hand, you could use a Compute Engine instance to run a binary which concatenates the wavs, using the cloud storage client library to ultimately put those wav files in the bucket, cleaning up any temporary files afterward.

If they're just segments of a single wav's binary, you can simply transfer the data and use the cloud storage client library to open the relevant cloud storage blob for writing, writing the new portion to the end of the "file".

It really comes down to the fact that you yourself need to understand what's being returned by exportWav.

If you're set on using blob properties in datastore, you can do this of course, just look up the relevant documentation for storing blobs in datastore, and be aware that you can't "update" objects, or "concatenate" to their properties. If you put a wav today and want to concat to it in 3 months, you'll need to grab the full entity and blob, delete it, concat the new portion in-memory and then put it back.

Nick
  • 3,581
  • 1
  • 14
  • 36
  • Thanks for answering! I'm pretty sure that exportWav() creates a complete wav file. So could you help out with some names of format-aware python libraries that are compatible with app engine? Or is there a better way to record audio client-side and stream it to the server? – vipluv Jan 28 '15 at 06:24
  • Check out either [pydub](http://pydub.com/) or the python [wave](http://stackoverflow.com/questions/12649465/linux-and-python-combining-multiple-wave-files-to-one-wave-file) module. You'll have to determine if they'll run on app engine. Follow the link I sent in my original answer for "Compute Engine" to learn about the more VPS-like service where you can run any binary you like on a virtual linux (or other) box. You could use App Engine to serve your app and a Compute Engine instance to process the wavs if you can't find a way to do it in python on App Engine. – Nick Jan 28 '15 at 14:39
  • In fact I'd recommend that you don't use python to process the audio, especially since python on App Engine doesn't allow C files. Dealing with raw audio data in this way might be costly. I'd recommend using a program running on a GCE (Google Compute Engine) instance to process the wav files. You can use the [Compute Engine API](https://cloud.google.com/compute/docs/reference/latest/#Instances) to monitor your instance and start and stop it depending on the need to process files, so as to avoid keeping it up while idle. – Nick Jan 28 '15 at 17:13