@tensamin/audio 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-AQ5RVY33.mjs → chunk-645QO2TA.mjs} +11 -7
- package/dist/chunk-ANM5JP7I.mjs +38 -0
- package/dist/{chunk-7IKKNKM7.mjs → chunk-IT365EBN.mjs} +11 -11
- package/dist/{chunk-BAUJY4Q2.mjs → chunk-MVWRBGIR.mjs} +23 -26
- package/dist/{chunk-YQPL2O7D.mjs → chunk-XEGLAV6A.mjs} +2 -2
- package/dist/defaults.d.mts +10 -0
- package/dist/defaults.d.ts +10 -0
- package/dist/defaults.js +66 -0
- package/dist/defaults.mjs +14 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +64 -36
- package/dist/index.mjs +17 -5
- package/dist/livekit/integration.d.mts +1 -1
- package/dist/livekit/integration.d.ts +1 -1
- package/dist/livekit/integration.js +54 -36
- package/dist/livekit/integration.mjs +6 -5
- package/dist/pipeline/audio-pipeline.js +48 -29
- package/dist/pipeline/audio-pipeline.mjs +4 -3
- package/dist/pipeline/remote-audio-monitor.js +24 -14
- package/dist/pipeline/remote-audio-monitor.mjs +4 -3
- package/dist/vad/vad-state.js +20 -7
- package/dist/vad/vad-state.mjs +2 -1
- package/package.json +1 -1
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_SPEAKING_DETECTION_CONFIG
|
|
3
|
+
} from "./chunk-ANM5JP7I.mjs";
|
|
4
|
+
|
|
1
5
|
// src/vad/vad-state.ts
|
|
2
6
|
var LevelBasedVAD = class {
|
|
3
7
|
config;
|
|
@@ -6,13 +10,13 @@ var LevelBasedVAD = class {
|
|
|
6
10
|
pendingSilenceSince = null;
|
|
7
11
|
constructor(config) {
|
|
8
12
|
this.config = {
|
|
9
|
-
minDb: config.minDb,
|
|
10
|
-
maxDb: config.maxDb,
|
|
11
|
-
speakOnRatio: config.speakOnRatio ??
|
|
12
|
-
speakOffRatio: config.speakOffRatio ??
|
|
13
|
-
hangoverMs: config.hangoverMs ??
|
|
14
|
-
attackMs: config.attackMs ??
|
|
15
|
-
releaseMs: config.releaseMs ??
|
|
13
|
+
minDb: config.minDb ?? DEFAULT_SPEAKING_DETECTION_CONFIG.minDb,
|
|
14
|
+
maxDb: config.maxDb ?? DEFAULT_SPEAKING_DETECTION_CONFIG.maxDb,
|
|
15
|
+
speakOnRatio: config.speakOnRatio ?? DEFAULT_SPEAKING_DETECTION_CONFIG.speakOnRatio,
|
|
16
|
+
speakOffRatio: config.speakOffRatio ?? DEFAULT_SPEAKING_DETECTION_CONFIG.speakOffRatio,
|
|
17
|
+
hangoverMs: config.hangoverMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.hangoverMs,
|
|
18
|
+
attackMs: config.attackMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.attackMs,
|
|
19
|
+
releaseMs: config.releaseMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.releaseMs
|
|
16
20
|
};
|
|
17
21
|
}
|
|
18
22
|
updateConfig(config) {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/defaults.ts
|
|
2
|
+
var DEFAULT_SPEAKING_DETECTION_CONFIG = {
|
|
3
|
+
minDb: -65,
|
|
4
|
+
maxDb: -20,
|
|
5
|
+
speakOnRatio: 0.5,
|
|
6
|
+
speakOffRatio: 0.3,
|
|
7
|
+
hangoverMs: 500,
|
|
8
|
+
attackMs: 100,
|
|
9
|
+
releaseMs: 120
|
|
10
|
+
};
|
|
11
|
+
var DEFAULT_NOISE_SUPPRESSION_CONFIG = {
|
|
12
|
+
enabled: true,
|
|
13
|
+
noiseReductionLevel: 50
|
|
14
|
+
};
|
|
15
|
+
var DEFAULT_OUTPUT_GAIN_CONFIG = {
|
|
16
|
+
speechGain: 1,
|
|
17
|
+
silenceGain: 0,
|
|
18
|
+
gainRampTime: 0.015,
|
|
19
|
+
maxGainDb: 6,
|
|
20
|
+
smoothTransitions: true
|
|
21
|
+
};
|
|
22
|
+
var DEFAULT_LIVEKIT_SPEAKING_OPTIONS = {
|
|
23
|
+
noiseSuppression: DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
24
|
+
speaking: DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
25
|
+
output: DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
26
|
+
muteWhenSilent: true
|
|
27
|
+
};
|
|
28
|
+
var DEFAULT_REMOTE_SPEAKING_OPTIONS = {
|
|
29
|
+
speaking: DEFAULT_SPEAKING_DETECTION_CONFIG
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
34
|
+
DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
35
|
+
DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
36
|
+
DEFAULT_LIVEKIT_SPEAKING_OPTIONS,
|
|
37
|
+
DEFAULT_REMOTE_SPEAKING_OPTIONS
|
|
38
|
+
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createLevelDetectorNode
|
|
3
|
+
} from "./chunk-QNQK6QFB.mjs";
|
|
1
4
|
import {
|
|
2
5
|
LevelBasedVAD
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-645QO2TA.mjs";
|
|
7
|
+
import {
|
|
8
|
+
DEFAULT_REMOTE_SPEAKING_OPTIONS,
|
|
9
|
+
DEFAULT_SPEAKING_DETECTION_CONFIG
|
|
10
|
+
} from "./chunk-ANM5JP7I.mjs";
|
|
4
11
|
import {
|
|
5
12
|
getAudioContext,
|
|
6
13
|
registerPipeline,
|
|
7
14
|
unregisterPipeline
|
|
8
15
|
} from "./chunk-OZ7KMC4S.mjs";
|
|
9
|
-
import {
|
|
10
|
-
createLevelDetectorNode
|
|
11
|
-
} from "./chunk-QNQK6QFB.mjs";
|
|
12
16
|
|
|
13
17
|
// src/pipeline/remote-audio-monitor.ts
|
|
14
18
|
import mitt from "mitt";
|
|
@@ -17,13 +21,9 @@ async function createRemoteAudioMonitor(sourceTrack, config = {}) {
|
|
|
17
21
|
registerPipeline();
|
|
18
22
|
const fullConfig = {
|
|
19
23
|
speaking: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
speakOffRatio: config.speaking?.speakOffRatio ?? 0.3,
|
|
24
|
-
hangoverMs: config.speaking?.hangoverMs ?? 500,
|
|
25
|
-
attackMs: config.speaking?.attackMs ?? 100,
|
|
26
|
-
releaseMs: config.speaking?.releaseMs ?? 120
|
|
24
|
+
...DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
25
|
+
...DEFAULT_REMOTE_SPEAKING_OPTIONS.speaking,
|
|
26
|
+
...config.speaking
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
if (!sourceTrack || sourceTrack.kind !== "audio") {
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createDeepFilterNet3Node
|
|
3
3
|
} from "./chunk-IS37FHDN.mjs";
|
|
4
|
+
import {
|
|
5
|
+
createLevelDetectorNode
|
|
6
|
+
} from "./chunk-QNQK6QFB.mjs";
|
|
4
7
|
import {
|
|
5
8
|
LevelBasedVAD
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-645QO2TA.mjs";
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_LIVEKIT_SPEAKING_OPTIONS,
|
|
12
|
+
DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
13
|
+
DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
14
|
+
DEFAULT_SPEAKING_DETECTION_CONFIG
|
|
15
|
+
} from "./chunk-ANM5JP7I.mjs";
|
|
7
16
|
import {
|
|
8
17
|
getAudioContext,
|
|
9
18
|
registerPipeline,
|
|
10
19
|
unregisterPipeline
|
|
11
20
|
} from "./chunk-OZ7KMC4S.mjs";
|
|
12
|
-
import {
|
|
13
|
-
createLevelDetectorNode
|
|
14
|
-
} from "./chunk-QNQK6QFB.mjs";
|
|
15
21
|
|
|
16
22
|
// src/pipeline/audio-pipeline.ts
|
|
17
23
|
import mitt from "mitt";
|
|
@@ -19,31 +25,22 @@ async function createAudioPipeline(sourceTrack, config = {}) {
|
|
|
19
25
|
const context = getAudioContext();
|
|
20
26
|
registerPipeline();
|
|
21
27
|
const nsConfig = {
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
...DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
29
|
+
...config.noiseSuppression
|
|
30
|
+
};
|
|
31
|
+
const speakingConfig = {
|
|
32
|
+
...DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
33
|
+
...config.speaking
|
|
34
|
+
};
|
|
35
|
+
const outputConfig = {
|
|
36
|
+
...DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
37
|
+
...config.output
|
|
24
38
|
};
|
|
25
|
-
if (config.noiseSuppression?.assetConfig) {
|
|
26
|
-
nsConfig.assetConfig = config.noiseSuppression.assetConfig;
|
|
27
|
-
}
|
|
28
39
|
const fullConfig = {
|
|
29
40
|
noiseSuppression: nsConfig,
|
|
30
|
-
speaking:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
speakOnRatio: config.speaking?.speakOnRatio ?? 0.5,
|
|
34
|
-
speakOffRatio: config.speaking?.speakOffRatio ?? 0.3,
|
|
35
|
-
hangoverMs: config.speaking?.hangoverMs ?? 500,
|
|
36
|
-
attackMs: config.speaking?.attackMs ?? 100,
|
|
37
|
-
releaseMs: config.speaking?.releaseMs ?? 120
|
|
38
|
-
},
|
|
39
|
-
output: {
|
|
40
|
-
speechGain: config.output?.speechGain ?? 1,
|
|
41
|
-
silenceGain: config.output?.silenceGain ?? 0,
|
|
42
|
-
gainRampTime: config.output?.gainRampTime ?? 0.015,
|
|
43
|
-
maxGainDb: config.output?.maxGainDb ?? 6,
|
|
44
|
-
smoothTransitions: config.output?.smoothTransitions ?? true
|
|
45
|
-
},
|
|
46
|
-
muteWhenSilent: config.muteWhenSilent ?? false
|
|
41
|
+
speaking: speakingConfig,
|
|
42
|
+
output: outputConfig,
|
|
43
|
+
muteWhenSilent: config.muteWhenSilent ?? DEFAULT_LIVEKIT_SPEAKING_OPTIONS.muteWhenSilent ?? false
|
|
47
44
|
};
|
|
48
45
|
if (!sourceTrack || sourceTrack.kind !== "audio") {
|
|
49
46
|
throw new Error(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAudioPipeline
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MVWRBGIR.mjs";
|
|
4
4
|
import {
|
|
5
5
|
createRemoteAudioMonitor
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IT365EBN.mjs";
|
|
7
7
|
|
|
8
8
|
// src/livekit/integration.ts
|
|
9
9
|
async function attachSpeakingDetectionToTrack(track, options = {}) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SpeakingDetectionConfig, NoiseSuppressionConfig, OutputGainConfig, LivekitSpeakingOptions, RemoteSpeakingOptions } from './types.mjs';
|
|
2
|
+
import 'mitt';
|
|
3
|
+
|
|
4
|
+
declare const DEFAULT_SPEAKING_DETECTION_CONFIG: Readonly<Required<SpeakingDetectionConfig>>;
|
|
5
|
+
declare const DEFAULT_NOISE_SUPPRESSION_CONFIG: Readonly<NoiseSuppressionConfig>;
|
|
6
|
+
declare const DEFAULT_OUTPUT_GAIN_CONFIG: Readonly<Required<OutputGainConfig>>;
|
|
7
|
+
declare const DEFAULT_LIVEKIT_SPEAKING_OPTIONS: Readonly<LivekitSpeakingOptions>;
|
|
8
|
+
declare const DEFAULT_REMOTE_SPEAKING_OPTIONS: Readonly<RemoteSpeakingOptions>;
|
|
9
|
+
|
|
10
|
+
export { DEFAULT_LIVEKIT_SPEAKING_OPTIONS, DEFAULT_NOISE_SUPPRESSION_CONFIG, DEFAULT_OUTPUT_GAIN_CONFIG, DEFAULT_REMOTE_SPEAKING_OPTIONS, DEFAULT_SPEAKING_DETECTION_CONFIG };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SpeakingDetectionConfig, NoiseSuppressionConfig, OutputGainConfig, LivekitSpeakingOptions, RemoteSpeakingOptions } from './types.js';
|
|
2
|
+
import 'mitt';
|
|
3
|
+
|
|
4
|
+
declare const DEFAULT_SPEAKING_DETECTION_CONFIG: Readonly<Required<SpeakingDetectionConfig>>;
|
|
5
|
+
declare const DEFAULT_NOISE_SUPPRESSION_CONFIG: Readonly<NoiseSuppressionConfig>;
|
|
6
|
+
declare const DEFAULT_OUTPUT_GAIN_CONFIG: Readonly<Required<OutputGainConfig>>;
|
|
7
|
+
declare const DEFAULT_LIVEKIT_SPEAKING_OPTIONS: Readonly<LivekitSpeakingOptions>;
|
|
8
|
+
declare const DEFAULT_REMOTE_SPEAKING_OPTIONS: Readonly<RemoteSpeakingOptions>;
|
|
9
|
+
|
|
10
|
+
export { DEFAULT_LIVEKIT_SPEAKING_OPTIONS, DEFAULT_NOISE_SUPPRESSION_CONFIG, DEFAULT_OUTPUT_GAIN_CONFIG, DEFAULT_REMOTE_SPEAKING_OPTIONS, DEFAULT_SPEAKING_DETECTION_CONFIG };
|
package/dist/defaults.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/defaults.ts
|
|
21
|
+
var defaults_exports = {};
|
|
22
|
+
__export(defaults_exports, {
|
|
23
|
+
DEFAULT_LIVEKIT_SPEAKING_OPTIONS: () => DEFAULT_LIVEKIT_SPEAKING_OPTIONS,
|
|
24
|
+
DEFAULT_NOISE_SUPPRESSION_CONFIG: () => DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
25
|
+
DEFAULT_OUTPUT_GAIN_CONFIG: () => DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
26
|
+
DEFAULT_REMOTE_SPEAKING_OPTIONS: () => DEFAULT_REMOTE_SPEAKING_OPTIONS,
|
|
27
|
+
DEFAULT_SPEAKING_DETECTION_CONFIG: () => DEFAULT_SPEAKING_DETECTION_CONFIG
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(defaults_exports);
|
|
30
|
+
var DEFAULT_SPEAKING_DETECTION_CONFIG = {
|
|
31
|
+
minDb: -65,
|
|
32
|
+
maxDb: -20,
|
|
33
|
+
speakOnRatio: 0.5,
|
|
34
|
+
speakOffRatio: 0.3,
|
|
35
|
+
hangoverMs: 500,
|
|
36
|
+
attackMs: 100,
|
|
37
|
+
releaseMs: 120
|
|
38
|
+
};
|
|
39
|
+
var DEFAULT_NOISE_SUPPRESSION_CONFIG = {
|
|
40
|
+
enabled: true,
|
|
41
|
+
noiseReductionLevel: 50
|
|
42
|
+
};
|
|
43
|
+
var DEFAULT_OUTPUT_GAIN_CONFIG = {
|
|
44
|
+
speechGain: 1,
|
|
45
|
+
silenceGain: 0,
|
|
46
|
+
gainRampTime: 0.015,
|
|
47
|
+
maxGainDb: 6,
|
|
48
|
+
smoothTransitions: true
|
|
49
|
+
};
|
|
50
|
+
var DEFAULT_LIVEKIT_SPEAKING_OPTIONS = {
|
|
51
|
+
noiseSuppression: DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
52
|
+
speaking: DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
53
|
+
output: DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
54
|
+
muteWhenSilent: true
|
|
55
|
+
};
|
|
56
|
+
var DEFAULT_REMOTE_SPEAKING_OPTIONS = {
|
|
57
|
+
speaking: DEFAULT_SPEAKING_DETECTION_CONFIG
|
|
58
|
+
};
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
DEFAULT_LIVEKIT_SPEAKING_OPTIONS,
|
|
62
|
+
DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
63
|
+
DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
64
|
+
DEFAULT_REMOTE_SPEAKING_OPTIONS,
|
|
65
|
+
DEFAULT_SPEAKING_DETECTION_CONFIG
|
|
66
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_LIVEKIT_SPEAKING_OPTIONS,
|
|
3
|
+
DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
4
|
+
DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
5
|
+
DEFAULT_REMOTE_SPEAKING_OPTIONS,
|
|
6
|
+
DEFAULT_SPEAKING_DETECTION_CONFIG
|
|
7
|
+
} from "./chunk-ANM5JP7I.mjs";
|
|
8
|
+
export {
|
|
9
|
+
DEFAULT_LIVEKIT_SPEAKING_OPTIONS,
|
|
10
|
+
DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
11
|
+
DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
12
|
+
DEFAULT_REMOTE_SPEAKING_OPTIONS,
|
|
13
|
+
DEFAULT_SPEAKING_DETECTION_CONFIG
|
|
14
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AudioPipelineHandle, LivekitSpeakingOptions, NoiseSuppressionConfig, OutputGainConfig, RemoteSpeakingOptions, SpeakingController, SpeakingDetectionConfig, SpeakingEvents, SpeakingState } from './types.mjs';
|
|
2
|
+
export { DEFAULT_LIVEKIT_SPEAKING_OPTIONS, DEFAULT_NOISE_SUPPRESSION_CONFIG, DEFAULT_OUTPUT_GAIN_CONFIG, DEFAULT_REMOTE_SPEAKING_OPTIONS, DEFAULT_SPEAKING_DETECTION_CONFIG } from './defaults.mjs';
|
|
2
3
|
export { attachSpeakingDetectionToRemoteTrack, attachSpeakingDetectionToTrack } from './livekit/integration.mjs';
|
|
3
4
|
import 'mitt';
|
|
4
5
|
import 'livekit-client';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AudioPipelineHandle, LivekitSpeakingOptions, NoiseSuppressionConfig, OutputGainConfig, RemoteSpeakingOptions, SpeakingController, SpeakingDetectionConfig, SpeakingEvents, SpeakingState } from './types.js';
|
|
2
|
+
export { DEFAULT_LIVEKIT_SPEAKING_OPTIONS, DEFAULT_NOISE_SUPPRESSION_CONFIG, DEFAULT_OUTPUT_GAIN_CONFIG, DEFAULT_REMOTE_SPEAKING_OPTIONS, DEFAULT_SPEAKING_DETECTION_CONFIG } from './defaults.js';
|
|
2
3
|
export { attachSpeakingDetectionToRemoteTrack, attachSpeakingDetectionToTrack } from './livekit/integration.js';
|
|
3
4
|
import 'mitt';
|
|
4
5
|
import 'livekit-client';
|
package/dist/index.js
CHANGED
|
@@ -30,11 +30,47 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
DEFAULT_LIVEKIT_SPEAKING_OPTIONS: () => DEFAULT_LIVEKIT_SPEAKING_OPTIONS,
|
|
34
|
+
DEFAULT_NOISE_SUPPRESSION_CONFIG: () => DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
35
|
+
DEFAULT_OUTPUT_GAIN_CONFIG: () => DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
36
|
+
DEFAULT_REMOTE_SPEAKING_OPTIONS: () => DEFAULT_REMOTE_SPEAKING_OPTIONS,
|
|
37
|
+
DEFAULT_SPEAKING_DETECTION_CONFIG: () => DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
33
38
|
attachSpeakingDetectionToRemoteTrack: () => attachSpeakingDetectionToRemoteTrack,
|
|
34
39
|
attachSpeakingDetectionToTrack: () => attachSpeakingDetectionToTrack
|
|
35
40
|
});
|
|
36
41
|
module.exports = __toCommonJS(index_exports);
|
|
37
42
|
|
|
43
|
+
// src/defaults.ts
|
|
44
|
+
var DEFAULT_SPEAKING_DETECTION_CONFIG = {
|
|
45
|
+
minDb: -65,
|
|
46
|
+
maxDb: -20,
|
|
47
|
+
speakOnRatio: 0.5,
|
|
48
|
+
speakOffRatio: 0.3,
|
|
49
|
+
hangoverMs: 500,
|
|
50
|
+
attackMs: 100,
|
|
51
|
+
releaseMs: 120
|
|
52
|
+
};
|
|
53
|
+
var DEFAULT_NOISE_SUPPRESSION_CONFIG = {
|
|
54
|
+
enabled: true,
|
|
55
|
+
noiseReductionLevel: 50
|
|
56
|
+
};
|
|
57
|
+
var DEFAULT_OUTPUT_GAIN_CONFIG = {
|
|
58
|
+
speechGain: 1,
|
|
59
|
+
silenceGain: 0,
|
|
60
|
+
gainRampTime: 0.015,
|
|
61
|
+
maxGainDb: 6,
|
|
62
|
+
smoothTransitions: true
|
|
63
|
+
};
|
|
64
|
+
var DEFAULT_LIVEKIT_SPEAKING_OPTIONS = {
|
|
65
|
+
noiseSuppression: DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
66
|
+
speaking: DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
67
|
+
output: DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
68
|
+
muteWhenSilent: true
|
|
69
|
+
};
|
|
70
|
+
var DEFAULT_REMOTE_SPEAKING_OPTIONS = {
|
|
71
|
+
speaking: DEFAULT_SPEAKING_DETECTION_CONFIG
|
|
72
|
+
};
|
|
73
|
+
|
|
38
74
|
// src/pipeline/audio-pipeline.ts
|
|
39
75
|
var import_mitt = __toESM(require("mitt"));
|
|
40
76
|
|
|
@@ -165,13 +201,13 @@ var LevelBasedVAD = class {
|
|
|
165
201
|
pendingSilenceSince = null;
|
|
166
202
|
constructor(config) {
|
|
167
203
|
this.config = {
|
|
168
|
-
minDb: config.minDb,
|
|
169
|
-
maxDb: config.maxDb,
|
|
170
|
-
speakOnRatio: config.speakOnRatio ??
|
|
171
|
-
speakOffRatio: config.speakOffRatio ??
|
|
172
|
-
hangoverMs: config.hangoverMs ??
|
|
173
|
-
attackMs: config.attackMs ??
|
|
174
|
-
releaseMs: config.releaseMs ??
|
|
204
|
+
minDb: config.minDb ?? DEFAULT_SPEAKING_DETECTION_CONFIG.minDb,
|
|
205
|
+
maxDb: config.maxDb ?? DEFAULT_SPEAKING_DETECTION_CONFIG.maxDb,
|
|
206
|
+
speakOnRatio: config.speakOnRatio ?? DEFAULT_SPEAKING_DETECTION_CONFIG.speakOnRatio,
|
|
207
|
+
speakOffRatio: config.speakOffRatio ?? DEFAULT_SPEAKING_DETECTION_CONFIG.speakOffRatio,
|
|
208
|
+
hangoverMs: config.hangoverMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.hangoverMs,
|
|
209
|
+
attackMs: config.attackMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.attackMs,
|
|
210
|
+
releaseMs: config.releaseMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.releaseMs
|
|
175
211
|
};
|
|
176
212
|
}
|
|
177
213
|
updateConfig(config) {
|
|
@@ -233,31 +269,22 @@ async function createAudioPipeline(sourceTrack, config = {}) {
|
|
|
233
269
|
const context = getAudioContext();
|
|
234
270
|
registerPipeline();
|
|
235
271
|
const nsConfig = {
|
|
236
|
-
|
|
237
|
-
|
|
272
|
+
...DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
273
|
+
...config.noiseSuppression
|
|
274
|
+
};
|
|
275
|
+
const speakingConfig = {
|
|
276
|
+
...DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
277
|
+
...config.speaking
|
|
278
|
+
};
|
|
279
|
+
const outputConfig = {
|
|
280
|
+
...DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
281
|
+
...config.output
|
|
238
282
|
};
|
|
239
|
-
if (config.noiseSuppression?.assetConfig) {
|
|
240
|
-
nsConfig.assetConfig = config.noiseSuppression.assetConfig;
|
|
241
|
-
}
|
|
242
283
|
const fullConfig = {
|
|
243
284
|
noiseSuppression: nsConfig,
|
|
244
|
-
speaking:
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
speakOnRatio: config.speaking?.speakOnRatio ?? 0.5,
|
|
248
|
-
speakOffRatio: config.speaking?.speakOffRatio ?? 0.3,
|
|
249
|
-
hangoverMs: config.speaking?.hangoverMs ?? 500,
|
|
250
|
-
attackMs: config.speaking?.attackMs ?? 100,
|
|
251
|
-
releaseMs: config.speaking?.releaseMs ?? 120
|
|
252
|
-
},
|
|
253
|
-
output: {
|
|
254
|
-
speechGain: config.output?.speechGain ?? 1,
|
|
255
|
-
silenceGain: config.output?.silenceGain ?? 0,
|
|
256
|
-
gainRampTime: config.output?.gainRampTime ?? 0.015,
|
|
257
|
-
maxGainDb: config.output?.maxGainDb ?? 6,
|
|
258
|
-
smoothTransitions: config.output?.smoothTransitions ?? true
|
|
259
|
-
},
|
|
260
|
-
muteWhenSilent: config.muteWhenSilent ?? false
|
|
285
|
+
speaking: speakingConfig,
|
|
286
|
+
output: outputConfig,
|
|
287
|
+
muteWhenSilent: config.muteWhenSilent ?? DEFAULT_LIVEKIT_SPEAKING_OPTIONS.muteWhenSilent ?? false
|
|
261
288
|
};
|
|
262
289
|
if (!sourceTrack || sourceTrack.kind !== "audio") {
|
|
263
290
|
throw new Error(
|
|
@@ -394,13 +421,9 @@ async function createRemoteAudioMonitor(sourceTrack, config = {}) {
|
|
|
394
421
|
registerPipeline();
|
|
395
422
|
const fullConfig = {
|
|
396
423
|
speaking: {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
speakOffRatio: config.speaking?.speakOffRatio ?? 0.3,
|
|
401
|
-
hangoverMs: config.speaking?.hangoverMs ?? 500,
|
|
402
|
-
attackMs: config.speaking?.attackMs ?? 100,
|
|
403
|
-
releaseMs: config.speaking?.releaseMs ?? 120
|
|
424
|
+
...DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
425
|
+
...DEFAULT_REMOTE_SPEAKING_OPTIONS.speaking,
|
|
426
|
+
...config.speaking
|
|
404
427
|
}
|
|
405
428
|
};
|
|
406
429
|
if (!sourceTrack || sourceTrack.kind !== "audio") {
|
|
@@ -583,6 +606,11 @@ async function attachSpeakingDetectionToRemoteTrack(track, options = {}) {
|
|
|
583
606
|
}
|
|
584
607
|
// Annotate the CommonJS export names for ESM import in node:
|
|
585
608
|
0 && (module.exports = {
|
|
609
|
+
DEFAULT_LIVEKIT_SPEAKING_OPTIONS,
|
|
610
|
+
DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
611
|
+
DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
612
|
+
DEFAULT_REMOTE_SPEAKING_OPTIONS,
|
|
613
|
+
DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
586
614
|
attachSpeakingDetectionToRemoteTrack,
|
|
587
615
|
attachSpeakingDetectionToTrack
|
|
588
616
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -2,14 +2,26 @@ import "./chunk-WBQAMGXK.mjs";
|
|
|
2
2
|
import {
|
|
3
3
|
attachSpeakingDetectionToRemoteTrack,
|
|
4
4
|
attachSpeakingDetectionToTrack
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-XEGLAV6A.mjs";
|
|
6
|
+
import "./chunk-MVWRBGIR.mjs";
|
|
7
7
|
import "./chunk-IS37FHDN.mjs";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-AQ5RVY33.mjs";
|
|
10
|
-
import "./chunk-OZ7KMC4S.mjs";
|
|
8
|
+
import "./chunk-IT365EBN.mjs";
|
|
11
9
|
import "./chunk-QNQK6QFB.mjs";
|
|
10
|
+
import "./chunk-645QO2TA.mjs";
|
|
11
|
+
import {
|
|
12
|
+
DEFAULT_LIVEKIT_SPEAKING_OPTIONS,
|
|
13
|
+
DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
14
|
+
DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
15
|
+
DEFAULT_REMOTE_SPEAKING_OPTIONS,
|
|
16
|
+
DEFAULT_SPEAKING_DETECTION_CONFIG
|
|
17
|
+
} from "./chunk-ANM5JP7I.mjs";
|
|
18
|
+
import "./chunk-OZ7KMC4S.mjs";
|
|
12
19
|
export {
|
|
20
|
+
DEFAULT_LIVEKIT_SPEAKING_OPTIONS,
|
|
21
|
+
DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
22
|
+
DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
23
|
+
DEFAULT_REMOTE_SPEAKING_OPTIONS,
|
|
24
|
+
DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
13
25
|
attachSpeakingDetectionToRemoteTrack,
|
|
14
26
|
attachSpeakingDetectionToTrack
|
|
15
27
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LivekitSpeakingOptions, SpeakingController, RemoteSpeakingOptions } from '../types.mjs';
|
|
2
1
|
import { LocalAudioTrack, RemoteAudioTrack } from 'livekit-client';
|
|
2
|
+
import { LivekitSpeakingOptions, SpeakingController, RemoteSpeakingOptions } from '../types.mjs';
|
|
3
3
|
import 'mitt';
|
|
4
4
|
|
|
5
5
|
declare function attachSpeakingDetectionToTrack(track: LocalAudioTrack, options?: LivekitSpeakingOptions): Promise<SpeakingController>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LivekitSpeakingOptions, SpeakingController, RemoteSpeakingOptions } from '../types.js';
|
|
2
1
|
import { LocalAudioTrack, RemoteAudioTrack } from 'livekit-client';
|
|
2
|
+
import { LivekitSpeakingOptions, SpeakingController, RemoteSpeakingOptions } from '../types.js';
|
|
3
3
|
import 'mitt';
|
|
4
4
|
|
|
5
5
|
declare function attachSpeakingDetectionToTrack(track: LocalAudioTrack, options?: LivekitSpeakingOptions): Promise<SpeakingController>;
|
|
@@ -157,6 +157,37 @@ async function createLevelDetectorNode(context, onLevel, options) {
|
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
// src/defaults.ts
|
|
161
|
+
var DEFAULT_SPEAKING_DETECTION_CONFIG = {
|
|
162
|
+
minDb: -65,
|
|
163
|
+
maxDb: -20,
|
|
164
|
+
speakOnRatio: 0.5,
|
|
165
|
+
speakOffRatio: 0.3,
|
|
166
|
+
hangoverMs: 500,
|
|
167
|
+
attackMs: 100,
|
|
168
|
+
releaseMs: 120
|
|
169
|
+
};
|
|
170
|
+
var DEFAULT_NOISE_SUPPRESSION_CONFIG = {
|
|
171
|
+
enabled: true,
|
|
172
|
+
noiseReductionLevel: 50
|
|
173
|
+
};
|
|
174
|
+
var DEFAULT_OUTPUT_GAIN_CONFIG = {
|
|
175
|
+
speechGain: 1,
|
|
176
|
+
silenceGain: 0,
|
|
177
|
+
gainRampTime: 0.015,
|
|
178
|
+
maxGainDb: 6,
|
|
179
|
+
smoothTransitions: true
|
|
180
|
+
};
|
|
181
|
+
var DEFAULT_LIVEKIT_SPEAKING_OPTIONS = {
|
|
182
|
+
noiseSuppression: DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
183
|
+
speaking: DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
184
|
+
output: DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
185
|
+
muteWhenSilent: true
|
|
186
|
+
};
|
|
187
|
+
var DEFAULT_REMOTE_SPEAKING_OPTIONS = {
|
|
188
|
+
speaking: DEFAULT_SPEAKING_DETECTION_CONFIG
|
|
189
|
+
};
|
|
190
|
+
|
|
160
191
|
// src/vad/vad-state.ts
|
|
161
192
|
var LevelBasedVAD = class {
|
|
162
193
|
config;
|
|
@@ -165,13 +196,13 @@ var LevelBasedVAD = class {
|
|
|
165
196
|
pendingSilenceSince = null;
|
|
166
197
|
constructor(config) {
|
|
167
198
|
this.config = {
|
|
168
|
-
minDb: config.minDb,
|
|
169
|
-
maxDb: config.maxDb,
|
|
170
|
-
speakOnRatio: config.speakOnRatio ??
|
|
171
|
-
speakOffRatio: config.speakOffRatio ??
|
|
172
|
-
hangoverMs: config.hangoverMs ??
|
|
173
|
-
attackMs: config.attackMs ??
|
|
174
|
-
releaseMs: config.releaseMs ??
|
|
199
|
+
minDb: config.minDb ?? DEFAULT_SPEAKING_DETECTION_CONFIG.minDb,
|
|
200
|
+
maxDb: config.maxDb ?? DEFAULT_SPEAKING_DETECTION_CONFIG.maxDb,
|
|
201
|
+
speakOnRatio: config.speakOnRatio ?? DEFAULT_SPEAKING_DETECTION_CONFIG.speakOnRatio,
|
|
202
|
+
speakOffRatio: config.speakOffRatio ?? DEFAULT_SPEAKING_DETECTION_CONFIG.speakOffRatio,
|
|
203
|
+
hangoverMs: config.hangoverMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.hangoverMs,
|
|
204
|
+
attackMs: config.attackMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.attackMs,
|
|
205
|
+
releaseMs: config.releaseMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.releaseMs
|
|
175
206
|
};
|
|
176
207
|
}
|
|
177
208
|
updateConfig(config) {
|
|
@@ -233,31 +264,22 @@ async function createAudioPipeline(sourceTrack, config = {}) {
|
|
|
233
264
|
const context = getAudioContext();
|
|
234
265
|
registerPipeline();
|
|
235
266
|
const nsConfig = {
|
|
236
|
-
|
|
237
|
-
|
|
267
|
+
...DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
268
|
+
...config.noiseSuppression
|
|
269
|
+
};
|
|
270
|
+
const speakingConfig = {
|
|
271
|
+
...DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
272
|
+
...config.speaking
|
|
273
|
+
};
|
|
274
|
+
const outputConfig = {
|
|
275
|
+
...DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
276
|
+
...config.output
|
|
238
277
|
};
|
|
239
|
-
if (config.noiseSuppression?.assetConfig) {
|
|
240
|
-
nsConfig.assetConfig = config.noiseSuppression.assetConfig;
|
|
241
|
-
}
|
|
242
278
|
const fullConfig = {
|
|
243
279
|
noiseSuppression: nsConfig,
|
|
244
|
-
speaking:
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
speakOnRatio: config.speaking?.speakOnRatio ?? 0.5,
|
|
248
|
-
speakOffRatio: config.speaking?.speakOffRatio ?? 0.3,
|
|
249
|
-
hangoverMs: config.speaking?.hangoverMs ?? 500,
|
|
250
|
-
attackMs: config.speaking?.attackMs ?? 100,
|
|
251
|
-
releaseMs: config.speaking?.releaseMs ?? 120
|
|
252
|
-
},
|
|
253
|
-
output: {
|
|
254
|
-
speechGain: config.output?.speechGain ?? 1,
|
|
255
|
-
silenceGain: config.output?.silenceGain ?? 0,
|
|
256
|
-
gainRampTime: config.output?.gainRampTime ?? 0.015,
|
|
257
|
-
maxGainDb: config.output?.maxGainDb ?? 6,
|
|
258
|
-
smoothTransitions: config.output?.smoothTransitions ?? true
|
|
259
|
-
},
|
|
260
|
-
muteWhenSilent: config.muteWhenSilent ?? false
|
|
280
|
+
speaking: speakingConfig,
|
|
281
|
+
output: outputConfig,
|
|
282
|
+
muteWhenSilent: config.muteWhenSilent ?? DEFAULT_LIVEKIT_SPEAKING_OPTIONS.muteWhenSilent ?? false
|
|
261
283
|
};
|
|
262
284
|
if (!sourceTrack || sourceTrack.kind !== "audio") {
|
|
263
285
|
throw new Error(
|
|
@@ -394,13 +416,9 @@ async function createRemoteAudioMonitor(sourceTrack, config = {}) {
|
|
|
394
416
|
registerPipeline();
|
|
395
417
|
const fullConfig = {
|
|
396
418
|
speaking: {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
speakOffRatio: config.speaking?.speakOffRatio ?? 0.3,
|
|
401
|
-
hangoverMs: config.speaking?.hangoverMs ?? 500,
|
|
402
|
-
attackMs: config.speaking?.attackMs ?? 100,
|
|
403
|
-
releaseMs: config.speaking?.releaseMs ?? 120
|
|
419
|
+
...DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
420
|
+
...DEFAULT_REMOTE_SPEAKING_OPTIONS.speaking,
|
|
421
|
+
...config.speaking
|
|
404
422
|
}
|
|
405
423
|
};
|
|
406
424
|
if (!sourceTrack || sourceTrack.kind !== "audio") {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
attachSpeakingDetectionToRemoteTrack,
|
|
3
3
|
attachSpeakingDetectionToTrack
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-XEGLAV6A.mjs";
|
|
5
|
+
import "../chunk-MVWRBGIR.mjs";
|
|
6
6
|
import "../chunk-IS37FHDN.mjs";
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-AQ5RVY33.mjs";
|
|
9
|
-
import "../chunk-OZ7KMC4S.mjs";
|
|
7
|
+
import "../chunk-IT365EBN.mjs";
|
|
10
8
|
import "../chunk-QNQK6QFB.mjs";
|
|
9
|
+
import "../chunk-645QO2TA.mjs";
|
|
10
|
+
import "../chunk-ANM5JP7I.mjs";
|
|
11
|
+
import "../chunk-OZ7KMC4S.mjs";
|
|
11
12
|
export {
|
|
12
13
|
attachSpeakingDetectionToRemoteTrack,
|
|
13
14
|
attachSpeakingDetectionToTrack
|
|
@@ -154,6 +154,34 @@ async function createLevelDetectorNode(context, onLevel, options) {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
// src/defaults.ts
|
|
158
|
+
var DEFAULT_SPEAKING_DETECTION_CONFIG = {
|
|
159
|
+
minDb: -65,
|
|
160
|
+
maxDb: -20,
|
|
161
|
+
speakOnRatio: 0.5,
|
|
162
|
+
speakOffRatio: 0.3,
|
|
163
|
+
hangoverMs: 500,
|
|
164
|
+
attackMs: 100,
|
|
165
|
+
releaseMs: 120
|
|
166
|
+
};
|
|
167
|
+
var DEFAULT_NOISE_SUPPRESSION_CONFIG = {
|
|
168
|
+
enabled: true,
|
|
169
|
+
noiseReductionLevel: 50
|
|
170
|
+
};
|
|
171
|
+
var DEFAULT_OUTPUT_GAIN_CONFIG = {
|
|
172
|
+
speechGain: 1,
|
|
173
|
+
silenceGain: 0,
|
|
174
|
+
gainRampTime: 0.015,
|
|
175
|
+
maxGainDb: 6,
|
|
176
|
+
smoothTransitions: true
|
|
177
|
+
};
|
|
178
|
+
var DEFAULT_LIVEKIT_SPEAKING_OPTIONS = {
|
|
179
|
+
noiseSuppression: DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
180
|
+
speaking: DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
181
|
+
output: DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
182
|
+
muteWhenSilent: true
|
|
183
|
+
};
|
|
184
|
+
|
|
157
185
|
// src/vad/vad-state.ts
|
|
158
186
|
var LevelBasedVAD = class {
|
|
159
187
|
config;
|
|
@@ -162,13 +190,13 @@ var LevelBasedVAD = class {
|
|
|
162
190
|
pendingSilenceSince = null;
|
|
163
191
|
constructor(config) {
|
|
164
192
|
this.config = {
|
|
165
|
-
minDb: config.minDb,
|
|
166
|
-
maxDb: config.maxDb,
|
|
167
|
-
speakOnRatio: config.speakOnRatio ??
|
|
168
|
-
speakOffRatio: config.speakOffRatio ??
|
|
169
|
-
hangoverMs: config.hangoverMs ??
|
|
170
|
-
attackMs: config.attackMs ??
|
|
171
|
-
releaseMs: config.releaseMs ??
|
|
193
|
+
minDb: config.minDb ?? DEFAULT_SPEAKING_DETECTION_CONFIG.minDb,
|
|
194
|
+
maxDb: config.maxDb ?? DEFAULT_SPEAKING_DETECTION_CONFIG.maxDb,
|
|
195
|
+
speakOnRatio: config.speakOnRatio ?? DEFAULT_SPEAKING_DETECTION_CONFIG.speakOnRatio,
|
|
196
|
+
speakOffRatio: config.speakOffRatio ?? DEFAULT_SPEAKING_DETECTION_CONFIG.speakOffRatio,
|
|
197
|
+
hangoverMs: config.hangoverMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.hangoverMs,
|
|
198
|
+
attackMs: config.attackMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.attackMs,
|
|
199
|
+
releaseMs: config.releaseMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.releaseMs
|
|
172
200
|
};
|
|
173
201
|
}
|
|
174
202
|
updateConfig(config) {
|
|
@@ -230,31 +258,22 @@ async function createAudioPipeline(sourceTrack, config = {}) {
|
|
|
230
258
|
const context = getAudioContext();
|
|
231
259
|
registerPipeline();
|
|
232
260
|
const nsConfig = {
|
|
233
|
-
|
|
234
|
-
|
|
261
|
+
...DEFAULT_NOISE_SUPPRESSION_CONFIG,
|
|
262
|
+
...config.noiseSuppression
|
|
263
|
+
};
|
|
264
|
+
const speakingConfig = {
|
|
265
|
+
...DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
266
|
+
...config.speaking
|
|
267
|
+
};
|
|
268
|
+
const outputConfig = {
|
|
269
|
+
...DEFAULT_OUTPUT_GAIN_CONFIG,
|
|
270
|
+
...config.output
|
|
235
271
|
};
|
|
236
|
-
if (config.noiseSuppression?.assetConfig) {
|
|
237
|
-
nsConfig.assetConfig = config.noiseSuppression.assetConfig;
|
|
238
|
-
}
|
|
239
272
|
const fullConfig = {
|
|
240
273
|
noiseSuppression: nsConfig,
|
|
241
|
-
speaking:
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
speakOnRatio: config.speaking?.speakOnRatio ?? 0.5,
|
|
245
|
-
speakOffRatio: config.speaking?.speakOffRatio ?? 0.3,
|
|
246
|
-
hangoverMs: config.speaking?.hangoverMs ?? 500,
|
|
247
|
-
attackMs: config.speaking?.attackMs ?? 100,
|
|
248
|
-
releaseMs: config.speaking?.releaseMs ?? 120
|
|
249
|
-
},
|
|
250
|
-
output: {
|
|
251
|
-
speechGain: config.output?.speechGain ?? 1,
|
|
252
|
-
silenceGain: config.output?.silenceGain ?? 0,
|
|
253
|
-
gainRampTime: config.output?.gainRampTime ?? 0.015,
|
|
254
|
-
maxGainDb: config.output?.maxGainDb ?? 6,
|
|
255
|
-
smoothTransitions: config.output?.smoothTransitions ?? true
|
|
256
|
-
},
|
|
257
|
-
muteWhenSilent: config.muteWhenSilent ?? false
|
|
274
|
+
speaking: speakingConfig,
|
|
275
|
+
output: outputConfig,
|
|
276
|
+
muteWhenSilent: config.muteWhenSilent ?? DEFAULT_LIVEKIT_SPEAKING_OPTIONS.muteWhenSilent ?? false
|
|
258
277
|
};
|
|
259
278
|
if (!sourceTrack || sourceTrack.kind !== "audio") {
|
|
260
279
|
throw new Error(
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAudioPipeline
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-MVWRBGIR.mjs";
|
|
4
4
|
import "../chunk-IS37FHDN.mjs";
|
|
5
|
-
import "../chunk-AQ5RVY33.mjs";
|
|
6
|
-
import "../chunk-OZ7KMC4S.mjs";
|
|
7
5
|
import "../chunk-QNQK6QFB.mjs";
|
|
6
|
+
import "../chunk-645QO2TA.mjs";
|
|
7
|
+
import "../chunk-ANM5JP7I.mjs";
|
|
8
|
+
import "../chunk-OZ7KMC4S.mjs";
|
|
8
9
|
export {
|
|
9
10
|
createAudioPipeline
|
|
10
11
|
};
|
|
@@ -124,6 +124,20 @@ async function createLevelDetectorNode(context, onLevel, options) {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
// src/defaults.ts
|
|
128
|
+
var DEFAULT_SPEAKING_DETECTION_CONFIG = {
|
|
129
|
+
minDb: -65,
|
|
130
|
+
maxDb: -20,
|
|
131
|
+
speakOnRatio: 0.5,
|
|
132
|
+
speakOffRatio: 0.3,
|
|
133
|
+
hangoverMs: 500,
|
|
134
|
+
attackMs: 100,
|
|
135
|
+
releaseMs: 120
|
|
136
|
+
};
|
|
137
|
+
var DEFAULT_REMOTE_SPEAKING_OPTIONS = {
|
|
138
|
+
speaking: DEFAULT_SPEAKING_DETECTION_CONFIG
|
|
139
|
+
};
|
|
140
|
+
|
|
127
141
|
// src/vad/vad-state.ts
|
|
128
142
|
var LevelBasedVAD = class {
|
|
129
143
|
config;
|
|
@@ -132,13 +146,13 @@ var LevelBasedVAD = class {
|
|
|
132
146
|
pendingSilenceSince = null;
|
|
133
147
|
constructor(config) {
|
|
134
148
|
this.config = {
|
|
135
|
-
minDb: config.minDb,
|
|
136
|
-
maxDb: config.maxDb,
|
|
137
|
-
speakOnRatio: config.speakOnRatio ??
|
|
138
|
-
speakOffRatio: config.speakOffRatio ??
|
|
139
|
-
hangoverMs: config.hangoverMs ??
|
|
140
|
-
attackMs: config.attackMs ??
|
|
141
|
-
releaseMs: config.releaseMs ??
|
|
149
|
+
minDb: config.minDb ?? DEFAULT_SPEAKING_DETECTION_CONFIG.minDb,
|
|
150
|
+
maxDb: config.maxDb ?? DEFAULT_SPEAKING_DETECTION_CONFIG.maxDb,
|
|
151
|
+
speakOnRatio: config.speakOnRatio ?? DEFAULT_SPEAKING_DETECTION_CONFIG.speakOnRatio,
|
|
152
|
+
speakOffRatio: config.speakOffRatio ?? DEFAULT_SPEAKING_DETECTION_CONFIG.speakOffRatio,
|
|
153
|
+
hangoverMs: config.hangoverMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.hangoverMs,
|
|
154
|
+
attackMs: config.attackMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.attackMs,
|
|
155
|
+
releaseMs: config.releaseMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.releaseMs
|
|
142
156
|
};
|
|
143
157
|
}
|
|
144
158
|
updateConfig(config) {
|
|
@@ -201,13 +215,9 @@ async function createRemoteAudioMonitor(sourceTrack, config = {}) {
|
|
|
201
215
|
registerPipeline();
|
|
202
216
|
const fullConfig = {
|
|
203
217
|
speaking: {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
speakOffRatio: config.speaking?.speakOffRatio ?? 0.3,
|
|
208
|
-
hangoverMs: config.speaking?.hangoverMs ?? 500,
|
|
209
|
-
attackMs: config.speaking?.attackMs ?? 100,
|
|
210
|
-
releaseMs: config.speaking?.releaseMs ?? 120
|
|
218
|
+
...DEFAULT_SPEAKING_DETECTION_CONFIG,
|
|
219
|
+
...DEFAULT_REMOTE_SPEAKING_OPTIONS.speaking,
|
|
220
|
+
...config.speaking
|
|
211
221
|
}
|
|
212
222
|
};
|
|
213
223
|
if (!sourceTrack || sourceTrack.kind !== "audio") {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRemoteAudioMonitor
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-AQ5RVY33.mjs";
|
|
5
|
-
import "../chunk-OZ7KMC4S.mjs";
|
|
3
|
+
} from "../chunk-IT365EBN.mjs";
|
|
6
4
|
import "../chunk-QNQK6QFB.mjs";
|
|
5
|
+
import "../chunk-645QO2TA.mjs";
|
|
6
|
+
import "../chunk-ANM5JP7I.mjs";
|
|
7
|
+
import "../chunk-OZ7KMC4S.mjs";
|
|
7
8
|
export {
|
|
8
9
|
createRemoteAudioMonitor
|
|
9
10
|
};
|
package/dist/vad/vad-state.js
CHANGED
|
@@ -23,6 +23,19 @@ __export(vad_state_exports, {
|
|
|
23
23
|
LevelBasedVAD: () => LevelBasedVAD
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(vad_state_exports);
|
|
26
|
+
|
|
27
|
+
// src/defaults.ts
|
|
28
|
+
var DEFAULT_SPEAKING_DETECTION_CONFIG = {
|
|
29
|
+
minDb: -65,
|
|
30
|
+
maxDb: -20,
|
|
31
|
+
speakOnRatio: 0.5,
|
|
32
|
+
speakOffRatio: 0.3,
|
|
33
|
+
hangoverMs: 500,
|
|
34
|
+
attackMs: 100,
|
|
35
|
+
releaseMs: 120
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/vad/vad-state.ts
|
|
26
39
|
var LevelBasedVAD = class {
|
|
27
40
|
config;
|
|
28
41
|
speaking = false;
|
|
@@ -30,13 +43,13 @@ var LevelBasedVAD = class {
|
|
|
30
43
|
pendingSilenceSince = null;
|
|
31
44
|
constructor(config) {
|
|
32
45
|
this.config = {
|
|
33
|
-
minDb: config.minDb,
|
|
34
|
-
maxDb: config.maxDb,
|
|
35
|
-
speakOnRatio: config.speakOnRatio ??
|
|
36
|
-
speakOffRatio: config.speakOffRatio ??
|
|
37
|
-
hangoverMs: config.hangoverMs ??
|
|
38
|
-
attackMs: config.attackMs ??
|
|
39
|
-
releaseMs: config.releaseMs ??
|
|
46
|
+
minDb: config.minDb ?? DEFAULT_SPEAKING_DETECTION_CONFIG.minDb,
|
|
47
|
+
maxDb: config.maxDb ?? DEFAULT_SPEAKING_DETECTION_CONFIG.maxDb,
|
|
48
|
+
speakOnRatio: config.speakOnRatio ?? DEFAULT_SPEAKING_DETECTION_CONFIG.speakOnRatio,
|
|
49
|
+
speakOffRatio: config.speakOffRatio ?? DEFAULT_SPEAKING_DETECTION_CONFIG.speakOffRatio,
|
|
50
|
+
hangoverMs: config.hangoverMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.hangoverMs,
|
|
51
|
+
attackMs: config.attackMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.attackMs,
|
|
52
|
+
releaseMs: config.releaseMs ?? DEFAULT_SPEAKING_DETECTION_CONFIG.releaseMs
|
|
40
53
|
};
|
|
41
54
|
}
|
|
42
55
|
updateConfig(config) {
|
package/dist/vad/vad-state.mjs
CHANGED