client-sdk-js
client-sdk-js copied to clipboard
sampleRate not being used for the Audio Track
Describe the bug
What is happening
I am using useTrackToggle with custom sampleRate as below on the browser side, but the audio sample received on the node.js server side is not changing, and always 48Khz:
(props) => {
const { buttonProps, enabled } = useTrackToggle({
source: Track.Source.Microphone,
captureOptions: {
autoGainControl: false,
channelCount: 1,
echoCancellation: true,
noiseSuppression: true,
voiceIsolation: true,
sampleRate: 16000, // Gemini Audio input needs 16Khz, LE, raw PCM
},
onDeviceError: (error) => props.onDeviceError?.({ source: Track.Source.Microphone, error }),
});
return (
<Button
{...buttonProps}
Icon={enabled ? Mic : MicOff}
title={enabled ? "Mic is ON" : "Mic is Off"}
className={enabled ? styles.on : styles.off}
/>
);
},
What is expected
When the sampleRate is set on the browser side react component, the server side should receive audio samples at the set sampleRate
Reproduction
Use the above code in the react for creating a custom MIC button and monitor the audio frame sample Rate received on the server side.
Logs
System Info
System:
OS: Windows 10 10.0.19045
CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
Memory: 19.12 GB / 31.81 GB
Binaries:
Node: 22.11.0 - C:\Program Files\nodejs\node.EXE
npm: 11.3.0 - C:\Program Files\nodejs\npm.CMD
bun: 1.2.10 - ~\.bun\bin\bun.EXE
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (127.0.2651.105)
Internet Explorer: 11.0.19041.1566
npmPackages:
@livekit/components-react: ^2.9.4 => 2.9.4
@livekit/components-styles: ^1.1.5 => 1.1.5
livekit-client: ^2.13.0 => 2.13.0
@livekit/rtc-node: ^0.13.13 => 0.13.13
livekit-server-sdk: ^2.13.0 => 2.13.0
Severity
blocking an upgrade
Additional Information
No response