[Announce] node-red-contrib-sox-utils : first beta (testers wanted)

I just finished the first usable beta version of my very first node.
The node is a wrapper around the record functionality of the sox commandline tool on linux and you can find it here:

I’m happy for any testers who could give it a spin and tell me about any errors they find or usage feedback.
This node will record audio from the specified audio source on the machine node-red runs on.
It has several features which distinguish it from the microphone/record nodes already present.
It has options for record duration and a fine tune able silence detection which can be both used together or separate. It can be configured to either return a stream of raw audio buffers or a single buffer when recording is done. It separates the audio data and info/debug to two different outputs and the debug amount can be specified.
You can easily combine it with nodes like https://github.com/bartbutenaers/node-red-contrib-wav or use it in speech projects involving watson, voice2json or similar to record voice commands.
There is some detailed usage instructions in the readme which you can find in the repository.
Here are some pictures:

Thanks for your time and i look forward to your feedback,



Version Bump to 0.1.2
Added gain, highpass and lowpass parameters.
Streamlined record argument building.
Reshuffled some Ui parameters.

Hey Jonathan,
Unfortunately I cannot test this node, since I don't have a microphone for my raspberry ...
But is there any reason why you have added all this functionality into a single node? Because I can image it would be nice to have a separate highpass-node and a lowpass-node (in a separate repository). Then it would be possible to reuse that functionality e.g. when I want to process audio arriving from my node-red-contrib-ui-microphone node.

Or is this perhaps functionality that is completely stuffed into the sox library?

Its all typically things you do within a single sox command. As sox can do amazing things the commands tend to get quite long which is why i made this node in the first place. It just offers that little bit more in tunability compared to any of the other microphone nodes. As this is something you do to a live audio stream it also makes sense to have as much as possible in one workstep as by splitting it into several nodes you would introduce extra latency in each step which is not what you want especially if you use it for something like speech commands.
I tried to get around some of the menu bulkiness by hidding some of the more detailed options till you actually use them but i agree it is quite a long menu. Hopefully its structure is logical enough that it still is usable.


Ok i might change it to this:

where some of the more advanced settings that are optional are hidden by default and make the config more manageable but you can expand it all the way up to a monster like this if you want to have full control:

This is now in the repo as 0.1.3

1 Like

Thank you for your great work!
I ve no microphone connected to my raspi. I guess its not possible to use the mircophone from the laptop/mobile phone I use to view the dashboard with?

Not with my node but you can use Nicks great node-red-node-ui-microphone for that. You just need to set up https first as it wont work otherwise,

Version 0.1.4.

  • A play node has been added that can play audio from a file path send to it for now. Buffer support will be added soon. The new play node also includes a dropdown that shows all available playback devices. I will add this feature to the record node too to make input selection easier.

Version 0.1.5

  • Play node now also accepts data as a single buffer in addition to file paths
  • Play node now has a output gain option
  • You can now choose how the play node behaves if a new input arrives while a playback is already in progress
  • Moved Nodes to their own category

Version 0.1.6

  • Record Node now also includes a dropdown showing all available devices
  • Added option to output a single wav buffer to the record node
  • updated documentation

Version 0.1.7

  • added queue mode to the play node
  • added better help text to the nodes
  • updated the readme to reflect all current options

Version 0.2.0

  • added sox-convert node:
    • can convert from all available sox formats to wav, flac, mp3 and ogg (i will add more target formats in the future, if you have a request for one tell me :slight_smile: )
    • it accepts both buffers and file paths
  • fixed a whole lot in the play node when it comes to playing buffer input
  • breaking change: If you want to play a buffer you now have to attach a msg.format to the msg.object that contains the buffer that contains the file extension of the buffer (eg. wav, mp3, flac, ogg...)
    • the record and convert node now automatically include this msg.format property in their output so that the nodes can still be connected straight to each other.

If the buffer arrives without a .format could you guess by using "magic numbers" ? https://en.wikipedia.org/wiki/List_of_file_signatures
and then fail if not recognised ?

Just tested this and it looks like i should be able to simply use buffer.includes(Buffer.from(formatAsHex)) and just keep an array of the formats hex identifiers to compare against.
Thanks for this great input @dceejay

maybe need compare rather than includes to save searching the whole file...

Don’t think that would work as the file signatures are not always in the same place. For example for mp3s without an id3 Tag i have to look for frame headers to identify it.

uugh.. well I did say it could be a best effort... searching complete buffer may kill performance.

I think big audio files will probably be passed in as urls or file paths and i don’t need to do the searching and guessing for them. You wouldn’t want to pass around a buffer of 3 hours of flac audio in memory anyway. I might integrate it as a checkbox with a disclaimer of possible performance problems. So check this box if you want the node to guess the input format. I might add a note that this option should only be used with smaller files.

I would not have the option (one more thing to confuse users) - just search the first few bytes - if successful then hooray - good win - if not then error/warn that msg.format was not supplied.


To catch the ones that are not at the start i would have to search at least the first 20000 buffer elements. Does that count as a few :see_no_evil: I will only check the first few and if you pass in mp3s that don’t include modern tags its your own fault and you have to supply a msg.format