gillesdemey / node-record-lpcm16

:microphone: Records a 16-bit signed-integer linear pulse modulation code encoded audio file.
ISC License
212 stars 59 forks source link

Can't record sound on Windows #40

Closed ArtyCake closed 5 years ago

ArtyCake commented 7 years ago

I've installed binaries and updated PATH variable I'm using node-record-lpcm16 with @google-cloud/speech for speech recognition. But when i run record i've received next to console:

Recording with sample rate 16000...  
Recording 4163 bytes  
Recording 1385 bytes  
End Recording: 76.632080078125ms

That's all. It doesn't depend on what stream i'm using speech.createRecognizeStream from google or simple fs.createWriteStream

My settings are

record
  .start({
    sampleRateHertz: 16000,
    threshold: 0.1,
    verbose: true,
    recordProgram: isWin ? 'sox' : 'rec',
    silence: '1.0',
  })

rec causes spawn rec ENOENT on windows sox on mac causes same behavior

Recording with sample rate 16000...
Recording 5344 bytes
End Recording: 12.887939453125ms

But with rec it work as expected. Recognition works fine

AkaiBF commented 6 years ago

I'm getting the same error, but everytime I use it, it records in total exactly 5548 bytes.

haijun-ucsd commented 6 years ago

I'm getting the same error. With sox, it records in total exactly 5548 bytes and then stop recording. With rec I got "spawn rec ENOENT" on windows.

atifsajjad commented 6 years ago

Also not working on windows 7 for me. Node version 8.11.2, npm version 5.6.0

gillesdemey commented 6 years ago

Can you verify if this bug still occurs with v0.3.1? :)

AkaiBF commented 6 years ago

I can't see the "Recording X bytes" message now, but still stops working at around 160ms.

qunliu commented 6 years ago

I tried the latest v0.3.1 on both macos and Windows, same issue. They all start then end very soon (eg: End Recording: 20 ms or so). I tried recordProgram using 'sox' on Windows, 'sox' and 'rec' on macos, no difference. Any clue?

bsluis commented 5 years ago

Use rec on Mac OSX and sox on Windows 10.

On Windows 10, the current sox config results in corrupt files/streams (this is a sox + Windows 10 bug I assume). The following settings circumvent this: sox -t waveaudio default -b 16 -c 1 -e signed-integer -r 16000 --endian little -t wav - > voice.wav More about this here.

I also found that when buidling Electron apps on Mac the $PATH settings are not properly passed anymore. The NPM fix-path module solves this problem.

bomzj commented 5 years ago

@bsluis the command you provided sox -t waveaudio default -b 16 -c 1 -e signed-integer -r 16000 --endian little -t wav - > voice.wav works fine. But I can't get node-record-lpcm16 to work. I receive the following console output and empty wav file:

Recording 1 channels with sample rate 16000...
End Recording: 105.277ms