Created
October 24, 2020 02:53
-
-
Save shizuka-na-kazushi/eec719076afcef3bed2e9abd6dc911ec to your computer and use it in GitHub Desktop.
naudiodonで録音する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var portAudio = require('naudiodon'); | |
// デバイスのオープン | |
var ai = new portAudio.AudioIO({ | |
inOptions: { | |
channelCount: 1, | |
sampleFormat: portAudio.SampleFormat16Bit, | |
sampleRate: 44100, | |
deviceId: 6, // ここは環境によって書き換える必要あり | |
closeOnError: false // バッファがいっぱいになってもアプリが閉じないようにfalseに | |
} | |
}); | |
// 録音するファイル準備 | |
var out = fs.createWriteStream('rec.raw'); | |
// データが来たら呼ばれる | |
ai.on('data', (chunk) => { | |
out.write(chunk); | |
}); | |
ai.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment