@camstack/addon-import-alexa 0.2.94 → 0.2.95
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/addon.js +216 -3
- package/dist/addon.mjs +216 -3
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -5384,6 +5384,86 @@ var ZodIssueCode = {
|
|
|
5384
5384
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5385
5385
|
var ZodFirstPartyTypeKind;
|
|
5386
5386
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5387
|
+
//#endregion
|
|
5388
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5389
|
+
/**
|
|
5390
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5391
|
+
* window to float samples (D455).
|
|
5392
|
+
*
|
|
5393
|
+
* ## Why a format at all
|
|
5394
|
+
*
|
|
5395
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5396
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5397
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5398
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5399
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5400
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5401
|
+
*
|
|
5402
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5403
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5404
|
+
* one step further along the same wire.
|
|
5405
|
+
*
|
|
5406
|
+
* ## Why the expansion lives here
|
|
5407
|
+
*
|
|
5408
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5409
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5410
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5411
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5412
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5413
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5414
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5415
|
+
* `camstack deploy` and needs no published server.
|
|
5416
|
+
*
|
|
5417
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5418
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5419
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5420
|
+
*
|
|
5421
|
+
* ## Absent means f32le
|
|
5422
|
+
*
|
|
5423
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5424
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5425
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5426
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5427
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5428
|
+
* deployable one addon at a time across three nodes.
|
|
5429
|
+
*/
|
|
5430
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5431
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5432
|
+
"f32le",
|
|
5433
|
+
"pcmu",
|
|
5434
|
+
"pcma"
|
|
5435
|
+
];
|
|
5436
|
+
/**
|
|
5437
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5438
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5439
|
+
*
|
|
5440
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5441
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5442
|
+
*/
|
|
5443
|
+
function buildUlawTable() {
|
|
5444
|
+
const table = new Float32Array(256);
|
|
5445
|
+
for (let i = 0; i < 256; i++) {
|
|
5446
|
+
const complemented = ~i & 255;
|
|
5447
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5448
|
+
const exponent = complemented >> 4 & 7;
|
|
5449
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5450
|
+
}
|
|
5451
|
+
return table;
|
|
5452
|
+
}
|
|
5453
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5454
|
+
function buildAlawTable() {
|
|
5455
|
+
const table = new Float32Array(256);
|
|
5456
|
+
for (let i = 0; i < 256; i++) {
|
|
5457
|
+
const xored = i ^ 85;
|
|
5458
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5459
|
+
const exponent = xored >> 4 & 7;
|
|
5460
|
+
const mantissa = xored & 15;
|
|
5461
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5462
|
+
}
|
|
5463
|
+
return table;
|
|
5464
|
+
}
|
|
5465
|
+
buildUlawTable();
|
|
5466
|
+
buildAlawTable();
|
|
5387
5467
|
Object.fromEntries([
|
|
5388
5468
|
{
|
|
5389
5469
|
id: "overview",
|
|
@@ -6676,11 +6756,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6676
6756
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6677
6757
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6678
6758
|
*/
|
|
6759
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6679
6760
|
var DecodedAudioChunkSchema = object({
|
|
6680
6761
|
data: _instanceof(Uint8Array),
|
|
6681
6762
|
sampleRate: number().int().positive(),
|
|
6682
6763
|
channels: number().int().positive(),
|
|
6683
|
-
timestamp: number()
|
|
6764
|
+
timestamp: number(),
|
|
6765
|
+
/**
|
|
6766
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6767
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6768
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6769
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6770
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6771
|
+
*/
|
|
6772
|
+
format: AudioChunkFormatSchema.optional()
|
|
6684
6773
|
});
|
|
6685
6774
|
/**
|
|
6686
6775
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6692,7 +6781,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6692
6781
|
var SubscribeAudioChunksInputSchema = object({
|
|
6693
6782
|
brokerId: string(),
|
|
6694
6783
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6695
|
-
tag: string().optional()
|
|
6784
|
+
tag: string().optional(),
|
|
6785
|
+
/**
|
|
6786
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6787
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6788
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6789
|
+
*
|
|
6790
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6791
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6792
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6793
|
+
* deploy one at a time across three nodes.
|
|
6794
|
+
*/
|
|
6795
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6696
6796
|
});
|
|
6697
6797
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6698
6798
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10818,6 +10918,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10818
10918
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10819
10919
|
allowedClasses: array(string()).default([])
|
|
10820
10920
|
});
|
|
10921
|
+
/**
|
|
10922
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10923
|
+
*
|
|
10924
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10925
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10926
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10927
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10928
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
10929
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
10930
|
+
* way to the one expansion that feeds the model.
|
|
10931
|
+
*
|
|
10932
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
10933
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
10934
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
10935
|
+
*/
|
|
10936
|
+
var AudioAttachDeviceInputSchema = object({
|
|
10937
|
+
deviceId: number(),
|
|
10938
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
10939
|
+
brokerId: string(),
|
|
10940
|
+
/**
|
|
10941
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
10942
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
10943
|
+
* the orchestrator's poller pinned them before the move.
|
|
10944
|
+
*/
|
|
10945
|
+
ingestNodeId: string(),
|
|
10946
|
+
/**
|
|
10947
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
10948
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
10949
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
10950
|
+
*/
|
|
10951
|
+
settings: AudioAnalysisSettingsSchema
|
|
10952
|
+
});
|
|
10953
|
+
var AudioAttachDeviceResultSchema = object({
|
|
10954
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
10955
|
+
attached: boolean(),
|
|
10956
|
+
/**
|
|
10957
|
+
* True when the attachment replaced a live one for the same device. An
|
|
10958
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
10959
|
+
* double the broker's fanout and neither would know about the other.
|
|
10960
|
+
*/
|
|
10961
|
+
replaced: boolean()
|
|
10962
|
+
});
|
|
10963
|
+
var AudioDetachDeviceResultSchema = object({
|
|
10964
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
10965
|
+
detached: boolean() });
|
|
10821
10966
|
var AudioClassificationResultSchema = object({
|
|
10822
10967
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10823
10968
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10826,7 +10971,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10826
10971
|
method(object({
|
|
10827
10972
|
chunk: AudioChunkInputSchema,
|
|
10828
10973
|
settings: AudioAnalysisSettingsSchema
|
|
10829
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
10974
|
+
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(AudioAttachDeviceInputSchema, AudioAttachDeviceResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), AudioDetachDeviceResultSchema, { kind: "mutation" }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
10830
10975
|
kind: "mutation",
|
|
10831
10976
|
auth: "admin"
|
|
10832
10977
|
});
|
|
@@ -35168,12 +35313,24 @@ Object.freeze({
|
|
|
35168
35313
|
addonId: null,
|
|
35169
35314
|
access: "create"
|
|
35170
35315
|
},
|
|
35316
|
+
"audioAnalyzer.attachDevice": {
|
|
35317
|
+
capName: "audio-analyzer",
|
|
35318
|
+
capScope: "system",
|
|
35319
|
+
addonId: null,
|
|
35320
|
+
access: "create"
|
|
35321
|
+
},
|
|
35171
35322
|
"audioAnalyzer.classify": {
|
|
35172
35323
|
capName: "audio-analyzer",
|
|
35173
35324
|
capScope: "system",
|
|
35174
35325
|
addonId: null,
|
|
35175
35326
|
access: "view"
|
|
35176
35327
|
},
|
|
35328
|
+
"audioAnalyzer.detachDevice": {
|
|
35329
|
+
capName: "audio-analyzer",
|
|
35330
|
+
capScope: "system",
|
|
35331
|
+
addonId: null,
|
|
35332
|
+
access: "create"
|
|
35333
|
+
},
|
|
35177
35334
|
"audioAnalyzer.dispose": {
|
|
35178
35335
|
capName: "audio-analyzer",
|
|
35179
35336
|
capScope: "system",
|
|
@@ -41017,11 +41174,21 @@ Object.freeze({
|
|
|
41017
41174
|
form: "single",
|
|
41018
41175
|
optional: false
|
|
41019
41176
|
}],
|
|
41177
|
+
"audioAnalyzer.attachDevice": [{
|
|
41178
|
+
name: "deviceId",
|
|
41179
|
+
form: "single",
|
|
41180
|
+
optional: false
|
|
41181
|
+
}],
|
|
41020
41182
|
"audioAnalyzer.classify": [{
|
|
41021
41183
|
name: "deviceId",
|
|
41022
41184
|
form: "single",
|
|
41023
41185
|
optional: true
|
|
41024
41186
|
}],
|
|
41187
|
+
"audioAnalyzer.detachDevice": [{
|
|
41188
|
+
name: "deviceId",
|
|
41189
|
+
form: "single",
|
|
41190
|
+
optional: false
|
|
41191
|
+
}],
|
|
41025
41192
|
"audioMetrics.getCurrentSnapshot": [{
|
|
41026
41193
|
name: "deviceId",
|
|
41027
41194
|
form: "single",
|
|
@@ -42873,6 +43040,52 @@ Object.freeze({
|
|
|
42873
43040
|
"network-access": "ingress",
|
|
42874
43041
|
"smtp-provider": "email"
|
|
42875
43042
|
});
|
|
43043
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
43044
|
+
PCMU: 20 * Math.log10(4),
|
|
43045
|
+
PCMA: 20 * Math.log10(8)
|
|
43046
|
+
};
|
|
43047
|
+
/**
|
|
43048
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
43049
|
+
* same intent on the ITU-T scale (D460).
|
|
43050
|
+
*
|
|
43051
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
43052
|
+
*
|
|
43053
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
43054
|
+
* them converts:
|
|
43055
|
+
*
|
|
43056
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
43057
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
43058
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
43059
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
43060
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
43061
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
43062
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
43063
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
43064
|
+
* louder. That is what this function is for.
|
|
43065
|
+
*
|
|
43066
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
43067
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
43068
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
43069
|
+
* mandatory.
|
|
43070
|
+
*
|
|
43071
|
+
* ## Why a function and not a typed-in number
|
|
43072
|
+
*
|
|
43073
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
43074
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
43075
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
43076
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
43077
|
+
* having to reverse-engineer the sum.
|
|
43078
|
+
*
|
|
43079
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
43080
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
43081
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
43082
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
43083
|
+
* an extra place to argue with (D459).
|
|
43084
|
+
*/
|
|
43085
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
43086
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
43087
|
+
}
|
|
43088
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
42876
43089
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
42877
43090
|
var NC_AUDIO_DEFAULTS = {
|
|
42878
43091
|
hitPercent: 60,
|
package/dist/addon.mjs
CHANGED
|
@@ -5384,6 +5384,86 @@ var ZodIssueCode = {
|
|
|
5384
5384
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5385
5385
|
var ZodFirstPartyTypeKind;
|
|
5386
5386
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5387
|
+
//#endregion
|
|
5388
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5389
|
+
/**
|
|
5390
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5391
|
+
* window to float samples (D455).
|
|
5392
|
+
*
|
|
5393
|
+
* ## Why a format at all
|
|
5394
|
+
*
|
|
5395
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5396
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5397
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5398
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5399
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5400
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5401
|
+
*
|
|
5402
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5403
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5404
|
+
* one step further along the same wire.
|
|
5405
|
+
*
|
|
5406
|
+
* ## Why the expansion lives here
|
|
5407
|
+
*
|
|
5408
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5409
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5410
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5411
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5412
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5413
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5414
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5415
|
+
* `camstack deploy` and needs no published server.
|
|
5416
|
+
*
|
|
5417
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5418
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5419
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5420
|
+
*
|
|
5421
|
+
* ## Absent means f32le
|
|
5422
|
+
*
|
|
5423
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5424
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5425
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5426
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5427
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5428
|
+
* deployable one addon at a time across three nodes.
|
|
5429
|
+
*/
|
|
5430
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5431
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5432
|
+
"f32le",
|
|
5433
|
+
"pcmu",
|
|
5434
|
+
"pcma"
|
|
5435
|
+
];
|
|
5436
|
+
/**
|
|
5437
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5438
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5439
|
+
*
|
|
5440
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5441
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5442
|
+
*/
|
|
5443
|
+
function buildUlawTable() {
|
|
5444
|
+
const table = new Float32Array(256);
|
|
5445
|
+
for (let i = 0; i < 256; i++) {
|
|
5446
|
+
const complemented = ~i & 255;
|
|
5447
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5448
|
+
const exponent = complemented >> 4 & 7;
|
|
5449
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5450
|
+
}
|
|
5451
|
+
return table;
|
|
5452
|
+
}
|
|
5453
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5454
|
+
function buildAlawTable() {
|
|
5455
|
+
const table = new Float32Array(256);
|
|
5456
|
+
for (let i = 0; i < 256; i++) {
|
|
5457
|
+
const xored = i ^ 85;
|
|
5458
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5459
|
+
const exponent = xored >> 4 & 7;
|
|
5460
|
+
const mantissa = xored & 15;
|
|
5461
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5462
|
+
}
|
|
5463
|
+
return table;
|
|
5464
|
+
}
|
|
5465
|
+
buildUlawTable();
|
|
5466
|
+
buildAlawTable();
|
|
5387
5467
|
Object.fromEntries([
|
|
5388
5468
|
{
|
|
5389
5469
|
id: "overview",
|
|
@@ -6676,11 +6756,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6676
6756
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6677
6757
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6678
6758
|
*/
|
|
6759
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6679
6760
|
var DecodedAudioChunkSchema = object({
|
|
6680
6761
|
data: _instanceof(Uint8Array),
|
|
6681
6762
|
sampleRate: number().int().positive(),
|
|
6682
6763
|
channels: number().int().positive(),
|
|
6683
|
-
timestamp: number()
|
|
6764
|
+
timestamp: number(),
|
|
6765
|
+
/**
|
|
6766
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6767
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6768
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6769
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6770
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6771
|
+
*/
|
|
6772
|
+
format: AudioChunkFormatSchema.optional()
|
|
6684
6773
|
});
|
|
6685
6774
|
/**
|
|
6686
6775
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6692,7 +6781,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6692
6781
|
var SubscribeAudioChunksInputSchema = object({
|
|
6693
6782
|
brokerId: string(),
|
|
6694
6783
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6695
|
-
tag: string().optional()
|
|
6784
|
+
tag: string().optional(),
|
|
6785
|
+
/**
|
|
6786
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6787
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6788
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6789
|
+
*
|
|
6790
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6791
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6792
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6793
|
+
* deploy one at a time across three nodes.
|
|
6794
|
+
*/
|
|
6795
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6696
6796
|
});
|
|
6697
6797
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6698
6798
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10818,6 +10918,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10818
10918
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10819
10919
|
allowedClasses: array(string()).default([])
|
|
10820
10920
|
});
|
|
10921
|
+
/**
|
|
10922
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10923
|
+
*
|
|
10924
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10925
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10926
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10927
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10928
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
10929
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
10930
|
+
* way to the one expansion that feeds the model.
|
|
10931
|
+
*
|
|
10932
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
10933
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
10934
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
10935
|
+
*/
|
|
10936
|
+
var AudioAttachDeviceInputSchema = object({
|
|
10937
|
+
deviceId: number(),
|
|
10938
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
10939
|
+
brokerId: string(),
|
|
10940
|
+
/**
|
|
10941
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
10942
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
10943
|
+
* the orchestrator's poller pinned them before the move.
|
|
10944
|
+
*/
|
|
10945
|
+
ingestNodeId: string(),
|
|
10946
|
+
/**
|
|
10947
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
10948
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
10949
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
10950
|
+
*/
|
|
10951
|
+
settings: AudioAnalysisSettingsSchema
|
|
10952
|
+
});
|
|
10953
|
+
var AudioAttachDeviceResultSchema = object({
|
|
10954
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
10955
|
+
attached: boolean(),
|
|
10956
|
+
/**
|
|
10957
|
+
* True when the attachment replaced a live one for the same device. An
|
|
10958
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
10959
|
+
* double the broker's fanout and neither would know about the other.
|
|
10960
|
+
*/
|
|
10961
|
+
replaced: boolean()
|
|
10962
|
+
});
|
|
10963
|
+
var AudioDetachDeviceResultSchema = object({
|
|
10964
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
10965
|
+
detached: boolean() });
|
|
10821
10966
|
var AudioClassificationResultSchema = object({
|
|
10822
10967
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10823
10968
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10826,7 +10971,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10826
10971
|
method(object({
|
|
10827
10972
|
chunk: AudioChunkInputSchema,
|
|
10828
10973
|
settings: AudioAnalysisSettingsSchema
|
|
10829
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
10974
|
+
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(AudioAttachDeviceInputSchema, AudioAttachDeviceResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), AudioDetachDeviceResultSchema, { kind: "mutation" }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
10830
10975
|
kind: "mutation",
|
|
10831
10976
|
auth: "admin"
|
|
10832
10977
|
});
|
|
@@ -35168,12 +35313,24 @@ Object.freeze({
|
|
|
35168
35313
|
addonId: null,
|
|
35169
35314
|
access: "create"
|
|
35170
35315
|
},
|
|
35316
|
+
"audioAnalyzer.attachDevice": {
|
|
35317
|
+
capName: "audio-analyzer",
|
|
35318
|
+
capScope: "system",
|
|
35319
|
+
addonId: null,
|
|
35320
|
+
access: "create"
|
|
35321
|
+
},
|
|
35171
35322
|
"audioAnalyzer.classify": {
|
|
35172
35323
|
capName: "audio-analyzer",
|
|
35173
35324
|
capScope: "system",
|
|
35174
35325
|
addonId: null,
|
|
35175
35326
|
access: "view"
|
|
35176
35327
|
},
|
|
35328
|
+
"audioAnalyzer.detachDevice": {
|
|
35329
|
+
capName: "audio-analyzer",
|
|
35330
|
+
capScope: "system",
|
|
35331
|
+
addonId: null,
|
|
35332
|
+
access: "create"
|
|
35333
|
+
},
|
|
35177
35334
|
"audioAnalyzer.dispose": {
|
|
35178
35335
|
capName: "audio-analyzer",
|
|
35179
35336
|
capScope: "system",
|
|
@@ -41017,11 +41174,21 @@ Object.freeze({
|
|
|
41017
41174
|
form: "single",
|
|
41018
41175
|
optional: false
|
|
41019
41176
|
}],
|
|
41177
|
+
"audioAnalyzer.attachDevice": [{
|
|
41178
|
+
name: "deviceId",
|
|
41179
|
+
form: "single",
|
|
41180
|
+
optional: false
|
|
41181
|
+
}],
|
|
41020
41182
|
"audioAnalyzer.classify": [{
|
|
41021
41183
|
name: "deviceId",
|
|
41022
41184
|
form: "single",
|
|
41023
41185
|
optional: true
|
|
41024
41186
|
}],
|
|
41187
|
+
"audioAnalyzer.detachDevice": [{
|
|
41188
|
+
name: "deviceId",
|
|
41189
|
+
form: "single",
|
|
41190
|
+
optional: false
|
|
41191
|
+
}],
|
|
41025
41192
|
"audioMetrics.getCurrentSnapshot": [{
|
|
41026
41193
|
name: "deviceId",
|
|
41027
41194
|
form: "single",
|
|
@@ -42873,6 +43040,52 @@ Object.freeze({
|
|
|
42873
43040
|
"network-access": "ingress",
|
|
42874
43041
|
"smtp-provider": "email"
|
|
42875
43042
|
});
|
|
43043
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
43044
|
+
PCMU: 20 * Math.log10(4),
|
|
43045
|
+
PCMA: 20 * Math.log10(8)
|
|
43046
|
+
};
|
|
43047
|
+
/**
|
|
43048
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
43049
|
+
* same intent on the ITU-T scale (D460).
|
|
43050
|
+
*
|
|
43051
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
43052
|
+
*
|
|
43053
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
43054
|
+
* them converts:
|
|
43055
|
+
*
|
|
43056
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
43057
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
43058
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
43059
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
43060
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
43061
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
43062
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
43063
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
43064
|
+
* louder. That is what this function is for.
|
|
43065
|
+
*
|
|
43066
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
43067
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
43068
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
43069
|
+
* mandatory.
|
|
43070
|
+
*
|
|
43071
|
+
* ## Why a function and not a typed-in number
|
|
43072
|
+
*
|
|
43073
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
43074
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
43075
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
43076
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
43077
|
+
* having to reverse-engineer the sum.
|
|
43078
|
+
*
|
|
43079
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
43080
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
43081
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
43082
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
43083
|
+
* an extra place to argue with (D459).
|
|
43084
|
+
*/
|
|
43085
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
43086
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
43087
|
+
}
|
|
43088
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
42876
43089
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
42877
43090
|
var NC_AUDIO_DEFAULTS = {
|
|
42878
43091
|
hitPercent: 60,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-import-alexa",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.95",
|
|
4
4
|
"description": "Alexa device-import provider for CamStack — imports the smart-home devices in a user's Alexa account via the unofficial alexa-remote2 cookie/token client (the inverse of the Alexa exporter)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|