Skip to content

Commit 8611812

Browse files
Update getAudioStream with an object for configuration (#338)
1 parent 5533e44 commit 8611812

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/wrapper/getAudioStream.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
export type AudioStreamOptions = {
2+
echoCancellation?: boolean;
3+
noiseSuppression?: boolean;
4+
autoGainControl?: boolean;
5+
};
6+
17
/**
28
* Requests an audio stream from the user's device using the `getUserMedia` API.
39
* The stream will have echo cancellation, noise suppression, and auto gain control enabled.
410
*
511
* @returns {Promise<MediaStream>} A promise that resolves to a `MediaStream` containing audio data only.
612
* @throws {DOMException} If the user denies access or no audio input devices are found.
713
*/
8-
export const getAudioStream = async (
9-
echoCancellation: boolean = true,
10-
noiseSuppression: boolean = true,
11-
autoGainControl: boolean = true,
12-
): Promise<MediaStream> => {
14+
export const getAudioStream = async (audioStreamOptions: AudioStreamOptions = {}): Promise<MediaStream> => {
15+
const { echoCancellation = true, noiseSuppression = true, autoGainControl = true } = audioStreamOptions;
1316
return navigator.mediaDevices.getUserMedia({
1417
audio: {
1518
echoCancellation,

0 commit comments

Comments
 (0)