Working audio on bot

This commit is contained in:
Logan Cusano
2022-12-11 18:24:24 -05:00
parent 4e1b82c557
commit 9ce846f1d9
3 changed files with 48 additions and 15 deletions

View File

@@ -12,7 +12,14 @@ export function getAudioDevice({deviceName = undefined, deviceId = undefined}){
}
export function getAudioDevices(){
const deviceList = portAudio.getDevices();
const deviceList = portAudio.getDevices().map((device) => {
if (device.defaultSampleRate === 48000 || device.maxInputChannels > 0) {
return device;
}
else {
return null;
}
}).filter(Boolean);
console.log("Devices:", deviceList);
return deviceList;
}
@@ -26,11 +33,12 @@ export function createAudioInstance() {
inOptions: {
channelCount: 2,
sampleFormat: portAudio.SampleFormat16Bit,
sampleRate: 44100,
sampleRate: 48000,
deviceId: selectedDevice.id, // Use -1 or omit the deviceId to select the default device
closeOnError: false, // Close the stream if an audio error is detected, if set false then just log the error
framesPerBuffer: 0 // 44100 / 1000 * 120 / 2 // Get 120ms of audio
}
closeOnError: true, // Close the stream if an audio error is detected, if set false then just log the error
framesPerBuffer: 100, //(48000 / 1000) * 20, //(48000 * 16 * 2) / 1000 * 20 // (48000 * (16 / 8) * 2) / 60 / 1000 * 20 //0.025 * 48000 / 2
highwaterMark: 3840
},
});
//audioInstance.start();
return audioInstance;