Giter Club home page Giter Club logo

mic's People

Contributors

artskydj avatar ashishbajaj99 avatar autonome avatar bpartridge83 avatar cmvee avatar ezekeal avatar leandrodvd avatar nfriedly avatar suchipi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mic's Issues

Error installing on Raspberry Pi Zero - ELOOP: too many symbolic links encountered

Hello, I got this error message while trying to install it in Raspi Zero and use it in Node_-Red:

npm ERR! path /home/pi/.node-red/node_modules/mic/package.json npm ERR! code ELOOP npm ERR! errno -40 npm ERR! syscall open npm ERR! ELOOP: too many symbolic links encountered, open '/home/pi/.node-red/node_modules/mic/package.json'

can anyone please help me?

How to get a valid wav file from micInputStream.on('data') ?

I'm using vosk-api for nodejs and in its sample, they use mic:

https://github.com/alphacep/vosk-api/blob/master/nodejs/demo/test_microphone.js#L27

micInputStream.on('data', data => {
    if (rec.acceptWaveform(data))
        console.log(rec.result());
    else
        console.log(rec.partialResult());
});

I'm trying to understand what kind of buffer is the data object and why is compatible with vosk

According to the vosk lib, buffer is

@param {Buffer} data audio data in PCM 16-bit mono format

But if I try to read the data object as wav file with the following libraries, I got this error: Not a supported format

Also if I try to get the standard wav sections (header, data, etc) of the data object I got this:

micInputStream.on('data', async (data) => {    
  if (rec.acceptWaveform(data)){

      console.log("0  >  4 : "+data.slice(0,4).toString())
      console.log("8  > 12 : "+data.slice(8,12).toString())
      console.log("12 > 14 : "+data.slice(12,14).toString())
      console.log("36 > 40 : "+data.slice(36,40).toString())
      console.log("45 > end:", data.slice(45))
     
      console.log("data:"+JSON.stringify(rec.result()));

Output

image

The received buffer from microphone (https://www.npmjs.com/package/mic) is not a valid wav file but works for vosk


Question

  • How to get a valid wav file from micInputStream.on('data') ?
  • Is the data object a kind of wav format?
  • Why I can't read it as valid wav file

Related issues

alphacep/vosk-api#1504


If anyone here can point me in the right direction of documentation, I will appreciate.

Thanks!

Version Update

Since there are some changes above v2.1.2 and version hasn't updated for months, is it the right time to make a new version and publish it on npm?

Mic on windows ignores bitwidth setting

Hi, when using this module on Windows, the audio stream seems to ignore the settings given, and instead pipes out 32 bit PCM audio no matter what. To test I streamed audio from the mic module into a file, and played the resulting file in VLC, where the codec information states it's 32bit Signed LE PCM audio.

Reading the documentation appears to show this is intentional: -p is an alias for -t sox -, which sets the file format to .sox, which is 32bit PCM audio. Viewing the resultant file in a hex editor confirms it's a .sox file as it has a default comment of "Processed by sox" (or wtte)
http://sox.sourceforge.net/sox.html#FILENAMES (see: -p and -t)
http://sox.sourceforge.net/soxformat.html (see .sox)

Problem

Hi, i have an error when i try to launch your example ...

$ node serveur.js
Got SIGNAL startComplete
Received Info: Capture WAVE 'stdin' : Signed 16 bit Little Endian, Fréquence 16000 Hz, Mono
arecord: set_params:1239: Nombre de canaux non disponible => Number of channels not available (translation) 
recording audioProcess has exited with code = 1
Got SIGNAL pauseComplete
Microphone paused
Got SIGNAL resumeComplete
Microphone resumed
Got SIGNAL stopComplete
Microhphone stopped

Can you help me please ?

Thanks you in advance !

Error: write after end

Hi,

When I edit your test code like below and run I get the error : Error: write after end

micInputStream.on('stopComplete', function() {
    console.log("Got SIGNAL stopComplete");
    setTimeout(function() {
            micInstance.start();
    }, 5000);
}); 

Any idea how to fix/handle it ?

Linux signals not supported on windows

I try to use mic.pause() and mic.resume() on windows but i encounter the following errors:
TypeError [ERR_UNKNOWN_SIGNAL]: Unknown signal: SIGSTOP when trying mic.pause()
TypeError [ERR_UNKNOWN_SIGNAL]: Unknown signal: SIGCONT when trying mic.resume()

Maybe linux signals are not supported on windows?

Detect sounds

Would it be possible to detect sounds and emit a 'sound' event accordingly?

My use case is that, after receiving 'slience', I need to know the time that elapsed before a new sound occured. I don't see how to do that with the current API.

This is great work otherwise!

Stream .on('data') always passes Uint8Array to callback

Regardless of the specified encoding passed in the settings when creating the mic instance, the on 'data' listener always passes an Uint8Array to the callback.

I would expect this data to be, for example, of type Int16Array if I specify a 'signed-integer' encoding.

Looking at the source code, here the encoding argument of the transform stream's _transform method seems to be unused. I'm not sure if that's where the change would have to be made to get the right TypedArray according to the specified encoding.

If anyone here can point me in the right direction (right place in source code), I don't mind working out a potential solution and opening a PR.

Thanks!

WAV format generates slowed down audio files?

Hi there!

I created a program that generates an audio file everytime there is a silence. Using standard configuration (raw) the files are creating correctly but if I try to generate .wav using the fileType, the first one is created correctly but the other files the speech sounds like the time is slowed down.

I know I can convert them using ffmpeg, but would be great to do it directly. There is a chance the script generating the files (fs.WriteStream) is wrong, but that would also mean raw files should be also broken

Any Idea?

audio open error

Hello, so i download the package and added your example, but i get the following error. Any idea on how to reslove this. I'm unable to figure the arecord command that is getting launched in this package.

Got SIGNAL startComplete
Received Info: ALSA lib pcm_hw.c:1700:(_snd_pcm_hw_open) Invalid value for card
arecord: main:722: audio open error: No such file or directory
recording audioProcess has exited with code = 1

use this to capture mic audio to client browser

Hi, I am trying to create a tool that capture mic audio input - for this your node is doing a great job. however, the output is a .wav file, instead I would like to make that available via localhost for remote client to access. Please let me know if I can use your code your code for this or I will face some known limitation ? - I am new to this so please bear with me.
Thanks for your help.

Issue on macOS

I get Error: spawn rec ENOENT

The issue is located at lib/mic.js line 54.

The main issue here is that the crash is hard to catch and detect from the user application. The library should catch the error and communicate about what is going on and how to fix it. For instance:

* Install sox for audio recording :
  https://github.com/JoFrhwld/FAVE/wiki/SoX-on-OS-X

Invalid value for card error

hello,
I'm running the test code and just didn't work, I'm with ubuntu Ubuntu 21.10...

Received Info: ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
arecord: main:852:
Received Info: audio open error: No such file or directory

How to process input

Hi there, thanks for the module. I had a question and forgive my naivety on how this whole thing works and not overly familiar with streams. How can I get access to the data so I can process it as a series of amplitudes?

AUDIO INPUT NOT PAUSING ON PAUSECOMPLETE

on pauseComplete signal,I dont see find speech block statement but afterwards when i play the audio it includes the voice input given when the mic was actually paused.What can be the reason behind this?

Mic and Azure Speech to Text

I am trying to recognize the user voice continuously, but I am always getting wrong results. Have anybody done something like this?

I will add some parts of my code so you can understand.

Here is how I create an instance of pushStream (MS Speech SDK)

this.pushStream = AudioInputStream.createPushStream(AudioStreamFormat.getWaveFormatPCM(16, 16000, 1));

Here is the method I call to recognize the user voice

    recognizeAsync() {
        this.audioConfig = AudioConfig.fromStreamInput(this.pushStream);
        this.recognizer = new SpeechRecognizer(this.speechConfig, this.audioConfig);
        this.subject = new Observable(subs => {
            this.subscription = subs;
            this.recognizer.startContinuousRecognitionAsync();
            this.recognizer.recognizing = (rec, {result}) => {
                subs.next(result);
            };
            this.recognizer.recognized = (rec, {result}) => {
                subs.next(result);
            };
        });
        return this.subject;
    }

And here is where I use the mic package to get the user voice data

speech = new Speech(language, subscriptionKey, region);
speech.recognizeAsync().subscribe(result => {
        console.log('result', result);
});
var micInstance = mic({
        rate: '16000',
        channels: '1',
        debug: false,
        exitOnSilence: 6,
        fileType: 'wav' //have also tried with raw type
});
const micInputStream = micInstance.getAudioStream();

micInputStream.on('data', function(data) {
    speech.pushStream.write(data);
    //console.log("Recieved Input Stream: ", data);
});

'plughw:1,0' is a bad default for the 'device' option

The chosen default device is platform-specific. I for example do not have a 'plughw:1,0' device on my laptop, my default mic is at 'plughw:0,0' instead.

This caused errors when I tried running the example code.

The underlying commands have some smarts to select a default device for you. I think the library should, by default, not specify a device on the command line, allowing the underlying tools to do their magic.

WAV header not required

i want to remove arecord 44 byte WAV header or there sholud be option for which tool to use like sox is also installed in my pc and alsa is also installed. i want pcm raw format output for pocketsphinx stt. need help or suggest me any realtime npm module for converting WAV to pcm.

Doesn't work for windows

Itried to use this on windows and it doesn't work. It seems that 'rec' command doesn't exist in Sox for windows anymore. It seems that the following command must be used instead
sox -t waveaudio −d new-file.wav

Write .wav file format with header.

I need make mathematical calculation with sound stream from microphone. For now it can be fft transforming. I made this before with .wav file by decoding via wav-decoder.

But when i try decode buffer from microphone as below, a have exeption Invalid WAV file.

micInputStream.on('data', function(data) {
   WavDecoder.decode(buffer);
});

Even, when i tried write wav file format then decode it. I also had exeption.

var micInputStream = micInstance.getAudioStream(); 
var outputFileStream = fs.WriteStream('output.wav'); 
micInputStream.pipe(outputFileStream);
micInstance.start();

I suppose, this because raw format have no header.

So can i some way decode micInputStream data directly or write wav file format via mic?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.