Working audio on bot
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user