@trillboards/edge-sdk 0.2.49 → 0.2.52

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.
Files changed (41) hide show
  1. package/README.md +58 -0
  2. package/dist/AudioOnsetDetector.d.ts +211 -0
  3. package/dist/AudioOnsetDetector.d.ts.map +1 -0
  4. package/dist/AudioOnsetDetector.js +286 -0
  5. package/dist/AudioOnsetDetector.js.map +1 -0
  6. package/dist/CloudSensingManager.d.ts +49 -0
  7. package/dist/CloudSensingManager.d.ts.map +1 -1
  8. package/dist/CloudSensingManager.js +84 -1
  9. package/dist/CloudSensingManager.js.map +1 -1
  10. package/dist/EdgeAgent.d.ts.map +1 -1
  11. package/dist/EdgeAgent.js +20 -2
  12. package/dist/EdgeAgent.js.map +1 -1
  13. package/dist/LiteRtVlmProvider.d.ts +54 -0
  14. package/dist/LiteRtVlmProvider.d.ts.map +1 -1
  15. package/dist/LiteRtVlmProvider.js +132 -0
  16. package/dist/LiteRtVlmProvider.js.map +1 -1
  17. package/dist/SceneChangeDetector.d.ts +27 -1
  18. package/dist/SceneChangeDetector.d.ts.map +1 -1
  19. package/dist/SceneChangeDetector.js +42 -0
  20. package/dist/SceneChangeDetector.js.map +1 -1
  21. package/dist/attachAudioOnset.d.ts +87 -0
  22. package/dist/attachAudioOnset.d.ts.map +1 -0
  23. package/dist/attachAudioOnset.js +87 -0
  24. package/dist/attachAudioOnset.js.map +1 -0
  25. package/dist/config.d.ts +46 -0
  26. package/dist/config.d.ts.map +1 -1
  27. package/dist/config.js.map +1 -1
  28. package/dist/diagnose.d.ts +1 -1
  29. package/dist/diagnose.js +1 -1
  30. package/dist/index.d.ts +5 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +16 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/sensingRunMode.d.ts.map +1 -1
  35. package/dist/sensingRunMode.js +5 -0
  36. package/dist/sensingRunMode.js.map +1 -1
  37. package/dist/wavEncode.d.ts +29 -0
  38. package/dist/wavEncode.d.ts.map +1 -0
  39. package/dist/wavEncode.js +63 -0
  40. package/dist/wavEncode.js.map +1 -0
  41. package/package.json +1 -1
@@ -0,0 +1,29 @@
1
+ /**
2
+ * wavEncode — Float32 PCM → a 16-bit mono RIFF/WAVE buffer.
3
+ *
4
+ * This exists because litert-lm's `input_audio` takes a CONTAINER (wav/flac/mp3
5
+ * base64), not raw samples, while everything upstream of it in this SDK —
6
+ * `AudioProvider.getAudioChunk`, `RTSPAudioProvider`'s ring, the onset
7
+ * detector — speaks Float32. One conversion, in one place, so the header is
8
+ * written correctly once.
9
+ *
10
+ * MEASURED CONSTRAINTS (litert-lm 0.16.0, `gemma-4-E2B-it.litertlm`):
11
+ * mono, 16 kHz, ≤30 s. Those are what `GEMMA_AUDIO_*` below encode. Speech at
12
+ * these settings transcribes verbatim (30/30 trials); acoustic events do not
13
+ * classify at all, which is why nothing in this SDK asks the model for one —
14
+ * see `AudioOnsetDetector`.
15
+ */
16
+ /** Sample rate litert-lm's audio encoder expects. */
17
+ export declare const GEMMA_AUDIO_SAMPLE_RATE = 16000;
18
+ /** Longest clip litert-lm accepts, in seconds. */
19
+ export declare const GEMMA_AUDIO_MAX_SECONDS = 30;
20
+ /**
21
+ * Encode mono Float32 samples (nominally -1..1) as a 16-bit PCM WAV.
22
+ * Out-of-range samples are CLAMPED, not wrapped: a wrapped sample turns a loud
23
+ * transient into full-scale noise of the opposite sign, which is exactly the
24
+ * content an acoustic path is most likely to be handed.
25
+ */
26
+ export declare function encodeWav16(samples: Float32Array, sampleRate: number): Buffer;
27
+ /** The most recent `seconds` of a buffer, for the model's clip-length cap. */
28
+ export declare function takeMostRecentSeconds(samples: Float32Array, sampleRate: number, seconds?: number): Float32Array;
29
+ //# sourceMappingURL=wavEncode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wavEncode.d.ts","sourceRoot":"","sources":["../src/wavEncode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,qDAAqD;AACrD,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAC9C,kDAAkD;AAClD,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAyB7E;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,MAAgC,GACxC,YAAY,CAId"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /**
3
+ * wavEncode — Float32 PCM → a 16-bit mono RIFF/WAVE buffer.
4
+ *
5
+ * This exists because litert-lm's `input_audio` takes a CONTAINER (wav/flac/mp3
6
+ * base64), not raw samples, while everything upstream of it in this SDK —
7
+ * `AudioProvider.getAudioChunk`, `RTSPAudioProvider`'s ring, the onset
8
+ * detector — speaks Float32. One conversion, in one place, so the header is
9
+ * written correctly once.
10
+ *
11
+ * MEASURED CONSTRAINTS (litert-lm 0.16.0, `gemma-4-E2B-it.litertlm`):
12
+ * mono, 16 kHz, ≤30 s. Those are what `GEMMA_AUDIO_*` below encode. Speech at
13
+ * these settings transcribes verbatim (30/30 trials); acoustic events do not
14
+ * classify at all, which is why nothing in this SDK asks the model for one —
15
+ * see `AudioOnsetDetector`.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.GEMMA_AUDIO_MAX_SECONDS = exports.GEMMA_AUDIO_SAMPLE_RATE = void 0;
19
+ exports.encodeWav16 = encodeWav16;
20
+ exports.takeMostRecentSeconds = takeMostRecentSeconds;
21
+ /** Sample rate litert-lm's audio encoder expects. */
22
+ exports.GEMMA_AUDIO_SAMPLE_RATE = 16000;
23
+ /** Longest clip litert-lm accepts, in seconds. */
24
+ exports.GEMMA_AUDIO_MAX_SECONDS = 30;
25
+ /**
26
+ * Encode mono Float32 samples (nominally -1..1) as a 16-bit PCM WAV.
27
+ * Out-of-range samples are CLAMPED, not wrapped: a wrapped sample turns a loud
28
+ * transient into full-scale noise of the opposite sign, which is exactly the
29
+ * content an acoustic path is most likely to be handed.
30
+ */
31
+ function encodeWav16(samples, sampleRate) {
32
+ if (!(sampleRate > 0))
33
+ throw new Error('encodeWav16 requires a positive sampleRate');
34
+ const dataBytes = samples.length * 2;
35
+ const buf = Buffer.alloc(44 + dataBytes);
36
+ buf.write('RIFF', 0, 'ascii');
37
+ buf.writeUInt32LE(36 + dataBytes, 4);
38
+ buf.write('WAVE', 8, 'ascii');
39
+ buf.write('fmt ', 12, 'ascii');
40
+ buf.writeUInt32LE(16, 16); // PCM fmt chunk size
41
+ buf.writeUInt16LE(1, 20); // audioFormat = PCM
42
+ buf.writeUInt16LE(1, 22); // channels = mono
43
+ buf.writeUInt32LE(sampleRate, 24);
44
+ buf.writeUInt32LE(sampleRate * 2, 28); // byte rate (mono, 2 bytes/sample)
45
+ buf.writeUInt16LE(2, 32); // block align
46
+ buf.writeUInt16LE(16, 34); // bits per sample
47
+ buf.write('data', 36, 'ascii');
48
+ buf.writeUInt32LE(dataBytes, 40);
49
+ for (let i = 0; i < samples.length; i++) {
50
+ const clamped = Math.max(-1, Math.min(1, samples[i]));
51
+ // Asymmetric scaling: int16 spans -32768..32767, so 1.0 must map to 32767.
52
+ buf.writeInt16LE(Math.round(clamped * (clamped < 0 ? 32768 : 32767)), 44 + i * 2);
53
+ }
54
+ return buf;
55
+ }
56
+ /** The most recent `seconds` of a buffer, for the model's clip-length cap. */
57
+ function takeMostRecentSeconds(samples, sampleRate, seconds = exports.GEMMA_AUDIO_MAX_SECONDS) {
58
+ const max = Math.max(1, Math.round(sampleRate * seconds));
59
+ if (samples.length <= max)
60
+ return samples;
61
+ return samples.slice(samples.length - max);
62
+ }
63
+ //# sourceMappingURL=wavEncode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wavEncode.js","sourceRoot":"","sources":["../src/wavEncode.ts"],"names":[],"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Aa,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,kBAAkB;IAC7C,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAC/B,GAAG,CAAC,aAAa,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAEjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtD,2EAA2E;QAC3E,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,8EAA8E;AAC9E,SAAgB,qBAAqB,CACnC,OAAqB,EACrB,UAAkB,EAClB,UAAkB,+BAAuB;IAEzC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC;IAC1D,IAAI,OAAO,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,OAAO,CAAC;IAC1C,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;AAC7C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trillboards/edge-sdk",
3
- "version": "0.2.49",
3
+ "version": "0.2.52",
4
4
  "description": "Composable cross-platform Edge AI SDK for audience sensing on DOOH/CTV devices",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",