flowr-es / node-microphone Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I'm trying to get a continuous stream of input from my microphone using the node-microphone. However, after i get my first buffer, it stops reading. Does the info event pick up all the audio, or this buffer for something else?
const stream = require('stream');
const fs = require('fs');
const mkfifo = require('mkfifo').mkfifo;
const writestream = fs.createWriteStream('audiopipe');
let Mic = require('node-microphone');
let mic = new Mic();
let micStream = mic.startRecording();
micStream.pipe( writestream );
setTimeout(() => {
console.log('stopped recording');
mic.stopRecording();
}, 5000);
mic.on('info', (info) => {
console.log(info);
});
mic.on('error', (error) => {
console.log(error);
});
Any ideas?
Is it possible to provide a live streaming to the user through this?
I've tried the following code
var Mic = require('node-microphone');
var mic = new Mic();
app.get('/testmic',function(req,res) {
var micStream = mic.startRecording();
micStream.pipe(res);
});
when I directly pointed to this address (localhost:4000/testmic) the stream is getting downloaded as some file.
But I want it such that when I assign this url to a audio src attribute in HTML5 audio element, I should be able to listen to the stream.
Is it possible? If yes, where have I done the mistake?
Currently this module only allows for the default device to be used on Windows.
I am trying to detect the sound of multiple audio inputs ... Is this possible?
I am trying to run the node-microphone example on my Windows 10 machine.
It is crashing with the following error
SoX is installed and added to the Environment Path
`events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn sox ENOENT
at exports._errnoException (util.js:1026:11)
at Process.__dirname.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Timeout.Module.runMain as _onTimeout
at tryOnTimeout (timers.js:232:11)
at Timer.listOnTimeout (timers.js:202:5)
Press any key to continue...`
How can I fix this ?
On Raspberry PI I am having the following issue:
/node_modules/node-microphone/index.js:6
class Microphone {
^^^^^
SyntaxError: Unexpected reserved word
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/pi/git/myapp/app_client_socketio.js:99:11) //this is where I load
//var Mic = require('node-microphone');
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
Do you know what I am doing wrong ?
This is how the constructor options documentation appears:
Create a new Class of the microphone module. You can give an options Object with the class. options - JSON containing sound options.Following are valid options: endian: big OR little, default: little bitwidth: 8 OR 16 OR 24 OR anything valid supported by arecord OR sox, default: 16 encoding: signed - integer OR unsinged- integer(none of the other encoding formats are supported), default:signed - integer rate: 8000 OR 16000 OR 44100 OR anything valid supported by arecord OR sox, default: 16000 channels: 1 OR 2 OR anything valid supported by arecord OR sox, default: 1(mono) device: hw: 0, 0 OR plughw: 1, 0 OR anything valid supported by arecord. For sox it is taken as waveaudio drive.
How can I test my MIC ? nothing happens with
pi@Rose:~/node/node_modules/node-microphone $ node index.js
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.