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,
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() { proces.kill('SIGTERM'); }, 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.
Thanks
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
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.