Recording audio in raspberry pi 3 using nodejs

Posted By : Chandan Kumar Singh | 28-Dec-2016

In my previous blog I have mentioned how to configure the usb microphone in raspberry pi 3,

Now we will record 30 sec audio.
 var spawn = require('child_process').spawn;
var musicFileName = new Date().getTime() + '.wav'; // generating the music file name
var proces = spawn('arecord', ['-D', 'plughw:0,0', '-f', 'dat'].concat(musicFileName), {
                    cwd: /home/pi/Music
                }); // invoking the arecord command
proces.on('exit', function(code, sig) { // if arecord process success
                    if (code !== null && sig === null) {
                        // here /home/pi/Music/1482926811918.wav 
		//	now you can process this wav file as your requirement
proces.stderr.on('data', function(data) {
                    console.log("music record stderr :" + data);
                proces.stdout.on('data', function(data) {
                   console.log(' music record stdout data: ' + data);
                setTimeout(function() {
                }, 30000);

By running this you will get audio file in Music folder. Now you can further process this wav file as your requirement. In next blog we will see how to configure ffmpeg on raspberry pi 3.


About Author

Author Image
Chandan Kumar Singh

Chandan is a bright Web Developer with expertise in Java and Spring framework and ORM tools Hibernate. He loves technologies like Blockchain and IoT.

Request for Proposal

Name is required

Comment is required

Sending message..