@tensamin/audio 0.1.5 → 0.1.6

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.
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  getNoiseSuppressionPlugin,
11
11
  getVADPlugin
12
- } from "./chunk-H5UKZU2Y.mjs";
12
+ } from "./chunk-ZCC7ID7L.mjs";
13
13
 
14
14
  // src/pipeline/audio-pipeline.ts
15
15
  import mitt from "mitt";
@@ -4,7 +4,7 @@ var createEnergyVadWorkletCode = (vadConfig) => {
4
4
  const smoothing = energyParams.smoothing ?? 0.95;
5
5
  const initialNoiseFloor = energyParams.initialNoiseFloor ?? 1e-3;
6
6
  const noiseFloorAdaptRateQuiet = energyParams.noiseFloorAdaptRateQuiet ?? 0.01;
7
- const noiseFloorAdaptRateLoud = energyParams.noiseFloorAdaptRateLoud ?? 1e-3;
7
+ const noiseFloorAdaptRateLoud = energyParams.noiseFloorAdaptRateLoud ?? 1e-4;
8
8
  const minSNR = energyParams.minSNR ?? 2;
9
9
  const snrRange = energyParams.snrRange ?? 8;
10
10
  return `
@@ -47,7 +47,15 @@ class EnergyVadProcessor extends AudioWorkletProcessor {
47
47
  } else {
48
48
  // Even during silence, if we detect a loud signal, adapt very slowly
49
49
  // This could be brief noise we haven't classified as speech yet
50
- this.noiseFloor = this.noiseFloor * (1 - this.noiseFloorAdaptRateLoud) + rms * this.noiseFloorAdaptRateLoud;
50
+
51
+ // SAFEGUARD: If the signal is significantly louder than the noise floor (e.g. > 3x),
52
+ // assume it's unclassified speech or a sudden loud noise and DO NOT adapt.
53
+ // This prevents the noise floor from "chasing" the speech level during brief pauses or onsets.
54
+ const instantSnr = rms / (this.noiseFloor + 1e-6);
55
+
56
+ if (instantSnr < 3.0) {
57
+ this.noiseFloor = this.noiseFloor * (1 - this.noiseFloorAdaptRateLoud) + rms * this.noiseFloorAdaptRateLoud;
58
+ }
51
59
  }
52
60
  }
53
61
  // During speech, freeze the noise floor to maintain consistent detection
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createAudioPipeline
3
- } from "./chunk-XXTNAUYX.mjs";
3
+ } from "./chunk-DF4AYGHJ.mjs";
4
4
 
5
5
  // src/livekit/integration.ts
6
6
  async function attachProcessingToTrack(track, config = {}) {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-XO6B3D4A.mjs";
4
4
  import {
5
5
  EnergyVADPlugin
6
- } from "./chunk-VEJXAEMM.mjs";
6
+ } from "./chunk-TLPO52HV.mjs";
7
7
 
8
8
  // src/extensibility/plugins.ts
9
9
  var nsPlugins = /* @__PURE__ */ new Map();
@@ -107,7 +107,7 @@ var createEnergyVadWorkletCode = (vadConfig) => {
107
107
  const smoothing = energyParams.smoothing ?? 0.95;
108
108
  const initialNoiseFloor = energyParams.initialNoiseFloor ?? 1e-3;
109
109
  const noiseFloorAdaptRateQuiet = energyParams.noiseFloorAdaptRateQuiet ?? 0.01;
110
- const noiseFloorAdaptRateLoud = energyParams.noiseFloorAdaptRateLoud ?? 1e-3;
110
+ const noiseFloorAdaptRateLoud = energyParams.noiseFloorAdaptRateLoud ?? 1e-4;
111
111
  const minSNR = energyParams.minSNR ?? 2;
112
112
  const snrRange = energyParams.snrRange ?? 8;
113
113
  return `
@@ -150,7 +150,15 @@ class EnergyVadProcessor extends AudioWorkletProcessor {
150
150
  } else {
151
151
  // Even during silence, if we detect a loud signal, adapt very slowly
152
152
  // This could be brief noise we haven't classified as speech yet
153
- this.noiseFloor = this.noiseFloor * (1 - this.noiseFloorAdaptRateLoud) + rms * this.noiseFloorAdaptRateLoud;
153
+
154
+ // SAFEGUARD: If the signal is significantly louder than the noise floor (e.g. > 3x),
155
+ // assume it's unclassified speech or a sudden loud noise and DO NOT adapt.
156
+ // This prevents the noise floor from "chasing" the speech level during brief pauses or onsets.
157
+ const instantSnr = rms / (this.noiseFloor + 1e-6);
158
+
159
+ if (instantSnr < 3.0) {
160
+ this.noiseFloor = this.noiseFloor * (1 - this.noiseFloorAdaptRateLoud) + rms * this.noiseFloorAdaptRateLoud;
161
+ }
154
162
  }
155
163
  }
156
164
  // During speech, freeze the noise floor to maintain consistent detection
@@ -3,9 +3,9 @@ import {
3
3
  getVADPlugin,
4
4
  registerNoiseSuppressionPlugin,
5
5
  registerVADPlugin
6
- } from "../chunk-H5UKZU2Y.mjs";
6
+ } from "../chunk-ZCC7ID7L.mjs";
7
7
  import "../chunk-XO6B3D4A.mjs";
8
- import "../chunk-VEJXAEMM.mjs";
8
+ import "../chunk-TLPO52HV.mjs";
9
9
  export {
10
10
  getNoiseSuppressionPlugin,
11
11
  getVADPlugin,
package/dist/index.js CHANGED
@@ -159,7 +159,7 @@ var createEnergyVadWorkletCode = (vadConfig) => {
159
159
  const smoothing = energyParams.smoothing ?? 0.95;
160
160
  const initialNoiseFloor = energyParams.initialNoiseFloor ?? 1e-3;
161
161
  const noiseFloorAdaptRateQuiet = energyParams.noiseFloorAdaptRateQuiet ?? 0.01;
162
- const noiseFloorAdaptRateLoud = energyParams.noiseFloorAdaptRateLoud ?? 1e-3;
162
+ const noiseFloorAdaptRateLoud = energyParams.noiseFloorAdaptRateLoud ?? 1e-4;
163
163
  const minSNR = energyParams.minSNR ?? 2;
164
164
  const snrRange = energyParams.snrRange ?? 8;
165
165
  return `
@@ -202,7 +202,15 @@ class EnergyVadProcessor extends AudioWorkletProcessor {
202
202
  } else {
203
203
  // Even during silence, if we detect a loud signal, adapt very slowly
204
204
  // This could be brief noise we haven't classified as speech yet
205
- this.noiseFloor = this.noiseFloor * (1 - this.noiseFloorAdaptRateLoud) + rms * this.noiseFloorAdaptRateLoud;
205
+
206
+ // SAFEGUARD: If the signal is significantly louder than the noise floor (e.g. > 3x),
207
+ // assume it's unclassified speech or a sudden loud noise and DO NOT adapt.
208
+ // This prevents the noise floor from "chasing" the speech level during brief pauses or onsets.
209
+ const instantSnr = rms / (this.noiseFloor + 1e-6);
210
+
211
+ if (instantSnr < 3.0) {
212
+ this.noiseFloor = this.noiseFloor * (1 - this.noiseFloorAdaptRateLoud) + rms * this.noiseFloorAdaptRateLoud;
213
+ }
206
214
  }
207
215
  }
208
216
  // During speech, freeze the noise floor to maintain consistent detection
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import "./chunk-WBQAMGXK.mjs";
2
2
  import {
3
3
  attachProcessingToTrack
4
- } from "./chunk-GVKCBKW6.mjs";
4
+ } from "./chunk-TWQJGBBU.mjs";
5
5
  import {
6
6
  createAudioPipeline
7
- } from "./chunk-XXTNAUYX.mjs";
7
+ } from "./chunk-DF4AYGHJ.mjs";
8
8
  import {
9
9
  VADStateMachine
10
10
  } from "./chunk-N553RHTI.mjs";
@@ -21,13 +21,13 @@ import {
21
21
  getVADPlugin,
22
22
  registerNoiseSuppressionPlugin,
23
23
  registerVADPlugin
24
- } from "./chunk-H5UKZU2Y.mjs";
24
+ } from "./chunk-ZCC7ID7L.mjs";
25
25
  import {
26
26
  RNNoisePlugin
27
27
  } from "./chunk-XO6B3D4A.mjs";
28
28
  import {
29
29
  EnergyVADPlugin
30
- } from "./chunk-VEJXAEMM.mjs";
30
+ } from "./chunk-TLPO52HV.mjs";
31
31
  export {
32
32
  EnergyVADPlugin,
33
33
  RNNoisePlugin,
@@ -128,7 +128,7 @@ var createEnergyVadWorkletCode = (vadConfig) => {
128
128
  const smoothing = energyParams.smoothing ?? 0.95;
129
129
  const initialNoiseFloor = energyParams.initialNoiseFloor ?? 1e-3;
130
130
  const noiseFloorAdaptRateQuiet = energyParams.noiseFloorAdaptRateQuiet ?? 0.01;
131
- const noiseFloorAdaptRateLoud = energyParams.noiseFloorAdaptRateLoud ?? 1e-3;
131
+ const noiseFloorAdaptRateLoud = energyParams.noiseFloorAdaptRateLoud ?? 1e-4;
132
132
  const minSNR = energyParams.minSNR ?? 2;
133
133
  const snrRange = energyParams.snrRange ?? 8;
134
134
  return `
@@ -171,7 +171,15 @@ class EnergyVadProcessor extends AudioWorkletProcessor {
171
171
  } else {
172
172
  // Even during silence, if we detect a loud signal, adapt very slowly
173
173
  // This could be brief noise we haven't classified as speech yet
174
- this.noiseFloor = this.noiseFloor * (1 - this.noiseFloorAdaptRateLoud) + rms * this.noiseFloorAdaptRateLoud;
174
+
175
+ // SAFEGUARD: If the signal is significantly louder than the noise floor (e.g. > 3x),
176
+ // assume it's unclassified speech or a sudden loud noise and DO NOT adapt.
177
+ // This prevents the noise floor from "chasing" the speech level during brief pauses or onsets.
178
+ const instantSnr = rms / (this.noiseFloor + 1e-6);
179
+
180
+ if (instantSnr < 3.0) {
181
+ this.noiseFloor = this.noiseFloor * (1 - this.noiseFloorAdaptRateLoud) + rms * this.noiseFloorAdaptRateLoud;
182
+ }
175
183
  }
176
184
  }
177
185
  // During speech, freeze the noise floor to maintain consistent detection
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  attachProcessingToTrack
3
- } from "../chunk-GVKCBKW6.mjs";
4
- import "../chunk-XXTNAUYX.mjs";
3
+ } from "../chunk-TWQJGBBU.mjs";
4
+ import "../chunk-DF4AYGHJ.mjs";
5
5
  import "../chunk-N553RHTI.mjs";
6
6
  import "../chunk-OZ7KMC4S.mjs";
7
- import "../chunk-H5UKZU2Y.mjs";
7
+ import "../chunk-ZCC7ID7L.mjs";
8
8
  import "../chunk-XO6B3D4A.mjs";
9
- import "../chunk-VEJXAEMM.mjs";
9
+ import "../chunk-TLPO52HV.mjs";
10
10
  export {
11
11
  attachProcessingToTrack
12
12
  };
@@ -126,7 +126,7 @@ var createEnergyVadWorkletCode = (vadConfig) => {
126
126
  const smoothing = energyParams.smoothing ?? 0.95;
127
127
  const initialNoiseFloor = energyParams.initialNoiseFloor ?? 1e-3;
128
128
  const noiseFloorAdaptRateQuiet = energyParams.noiseFloorAdaptRateQuiet ?? 0.01;
129
- const noiseFloorAdaptRateLoud = energyParams.noiseFloorAdaptRateLoud ?? 1e-3;
129
+ const noiseFloorAdaptRateLoud = energyParams.noiseFloorAdaptRateLoud ?? 1e-4;
130
130
  const minSNR = energyParams.minSNR ?? 2;
131
131
  const snrRange = energyParams.snrRange ?? 8;
132
132
  return `
@@ -169,7 +169,15 @@ class EnergyVadProcessor extends AudioWorkletProcessor {
169
169
  } else {
170
170
  // Even during silence, if we detect a loud signal, adapt very slowly
171
171
  // This could be brief noise we haven't classified as speech yet
172
- this.noiseFloor = this.noiseFloor * (1 - this.noiseFloorAdaptRateLoud) + rms * this.noiseFloorAdaptRateLoud;
172
+
173
+ // SAFEGUARD: If the signal is significantly louder than the noise floor (e.g. > 3x),
174
+ // assume it's unclassified speech or a sudden loud noise and DO NOT adapt.
175
+ // This prevents the noise floor from "chasing" the speech level during brief pauses or onsets.
176
+ const instantSnr = rms / (this.noiseFloor + 1e-6);
177
+
178
+ if (instantSnr < 3.0) {
179
+ this.noiseFloor = this.noiseFloor * (1 - this.noiseFloorAdaptRateLoud) + rms * this.noiseFloorAdaptRateLoud;
180
+ }
173
181
  }
174
182
  }
175
183
  // During speech, freeze the noise floor to maintain consistent detection
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  createAudioPipeline
3
- } from "../chunk-XXTNAUYX.mjs";
3
+ } from "../chunk-DF4AYGHJ.mjs";
4
4
  import "../chunk-N553RHTI.mjs";
5
5
  import "../chunk-OZ7KMC4S.mjs";
6
- import "../chunk-H5UKZU2Y.mjs";
6
+ import "../chunk-ZCC7ID7L.mjs";
7
7
  import "../chunk-XO6B3D4A.mjs";
8
- import "../chunk-VEJXAEMM.mjs";
8
+ import "../chunk-TLPO52HV.mjs";
9
9
  export {
10
10
  createAudioPipeline
11
11
  };
@@ -28,7 +28,7 @@ var createEnergyVadWorkletCode = (vadConfig) => {
28
28
  const smoothing = energyParams.smoothing ?? 0.95;
29
29
  const initialNoiseFloor = energyParams.initialNoiseFloor ?? 1e-3;
30
30
  const noiseFloorAdaptRateQuiet = energyParams.noiseFloorAdaptRateQuiet ?? 0.01;
31
- const noiseFloorAdaptRateLoud = energyParams.noiseFloorAdaptRateLoud ?? 1e-3;
31
+ const noiseFloorAdaptRateLoud = energyParams.noiseFloorAdaptRateLoud ?? 1e-4;
32
32
  const minSNR = energyParams.minSNR ?? 2;
33
33
  const snrRange = energyParams.snrRange ?? 8;
34
34
  return `
@@ -71,7 +71,15 @@ class EnergyVadProcessor extends AudioWorkletProcessor {
71
71
  } else {
72
72
  // Even during silence, if we detect a loud signal, adapt very slowly
73
73
  // This could be brief noise we haven't classified as speech yet
74
- this.noiseFloor = this.noiseFloor * (1 - this.noiseFloorAdaptRateLoud) + rms * this.noiseFloorAdaptRateLoud;
74
+
75
+ // SAFEGUARD: If the signal is significantly louder than the noise floor (e.g. > 3x),
76
+ // assume it's unclassified speech or a sudden loud noise and DO NOT adapt.
77
+ // This prevents the noise floor from "chasing" the speech level during brief pauses or onsets.
78
+ const instantSnr = rms / (this.noiseFloor + 1e-6);
79
+
80
+ if (instantSnr < 3.0) {
81
+ this.noiseFloor = this.noiseFloor * (1 - this.noiseFloorAdaptRateLoud) + rms * this.noiseFloorAdaptRateLoud;
82
+ }
75
83
  }
76
84
  }
77
85
  // During speech, freeze the noise floor to maintain consistent detection
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EnergyVADPlugin
3
- } from "../chunk-VEJXAEMM.mjs";
3
+ } from "../chunk-TLPO52HV.mjs";
4
4
  export {
5
5
  EnergyVADPlugin
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tensamin/audio",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",