I would like to use Node-RED (based on node.js) to upload my recorded audio files to the ingestion service.
On page https://docs.edgeimpulse.com/reference#data-acquisition-format I have found a Node.js example for 'Content-Type': 'application/json' but is it possible to use this content type for uploading audio files ? If so how should the wav audio file be put in the body ?
If not possible: is there some example describing the upload of an audio file (or binary data) for 'Content-Type': 'application/cbor' for Node.js ?
Currently I am using janvda/node-red-contrib-cbor (which is based on hildjj/node-cbor version v5.0.2) for converting json to cbor but once the json structure becomes a bit more complex this doesnât seem to work properly when I tested it as follows:
copy paste the hex string http://cbor.me/ in the right window and convert it back. In that case it reports error like: Out of bytes to decode (need at least 17 bytes more)
You can upload audio samples similarly as with other sensors by filling the values field with your audio samples as an array. Also you derive the interval_ms value from your audio sampling frequency and set the sensors value as follows:
sensors: [{ name: 'audio', units: 'wav' }]
Check also the code example of our cli uploader makeWav function, it uses the ingestion service to import wav files.
I have found the issue. The problem is located in step 2 where I am copy pasting the cbor data in string format. Most likely the cbor data in string format doesnât contain all binary data (all bits).
I fixed this issue by replacing step 2 and 3 by a step in node-red that converts the cbor buffer to a hex string using the command buffer.toString('hex'). This hex string when used in http://cbor.me/ (see step 4) properly converted back to the original json structure.