@camstack/addon-export-alexa 1.2.100 → 1.2.102
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/export-alexa.addon.js +218 -5
- package/dist/export-alexa.addon.mjs +218 -5
- package/package.json +1 -1
|
@@ -5372,6 +5372,86 @@ var ZodIssueCode = {
|
|
|
5372
5372
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5373
5373
|
var ZodFirstPartyTypeKind;
|
|
5374
5374
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5375
|
+
//#endregion
|
|
5376
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5377
|
+
/**
|
|
5378
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5379
|
+
* window to float samples (D455).
|
|
5380
|
+
*
|
|
5381
|
+
* ## Why a format at all
|
|
5382
|
+
*
|
|
5383
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5384
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5385
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5386
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5387
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5388
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5389
|
+
*
|
|
5390
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5391
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5392
|
+
* one step further along the same wire.
|
|
5393
|
+
*
|
|
5394
|
+
* ## Why the expansion lives here
|
|
5395
|
+
*
|
|
5396
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5397
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5398
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5399
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5400
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5401
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5402
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5403
|
+
* `camstack deploy` and needs no published server.
|
|
5404
|
+
*
|
|
5405
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5406
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5407
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5408
|
+
*
|
|
5409
|
+
* ## Absent means f32le
|
|
5410
|
+
*
|
|
5411
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5412
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5413
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5414
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5415
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5416
|
+
* deployable one addon at a time across three nodes.
|
|
5417
|
+
*/
|
|
5418
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5419
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5420
|
+
"f32le",
|
|
5421
|
+
"pcmu",
|
|
5422
|
+
"pcma"
|
|
5423
|
+
];
|
|
5424
|
+
/**
|
|
5425
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5426
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5427
|
+
*
|
|
5428
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5429
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5430
|
+
*/
|
|
5431
|
+
function buildUlawTable() {
|
|
5432
|
+
const table = new Float32Array(256);
|
|
5433
|
+
for (let i = 0; i < 256; i++) {
|
|
5434
|
+
const complemented = ~i & 255;
|
|
5435
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5436
|
+
const exponent = complemented >> 4 & 7;
|
|
5437
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5438
|
+
}
|
|
5439
|
+
return table;
|
|
5440
|
+
}
|
|
5441
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5442
|
+
function buildAlawTable() {
|
|
5443
|
+
const table = new Float32Array(256);
|
|
5444
|
+
for (let i = 0; i < 256; i++) {
|
|
5445
|
+
const xored = i ^ 85;
|
|
5446
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5447
|
+
const exponent = xored >> 4 & 7;
|
|
5448
|
+
const mantissa = xored & 15;
|
|
5449
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5450
|
+
}
|
|
5451
|
+
return table;
|
|
5452
|
+
}
|
|
5453
|
+
buildUlawTable();
|
|
5454
|
+
buildAlawTable();
|
|
5375
5455
|
Object.fromEntries([
|
|
5376
5456
|
{
|
|
5377
5457
|
id: "overview",
|
|
@@ -6664,11 +6744,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6664
6744
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6665
6745
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6666
6746
|
*/
|
|
6747
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6667
6748
|
var DecodedAudioChunkSchema = object({
|
|
6668
6749
|
data: _instanceof(Uint8Array),
|
|
6669
6750
|
sampleRate: number().int().positive(),
|
|
6670
6751
|
channels: number().int().positive(),
|
|
6671
|
-
timestamp: number()
|
|
6752
|
+
timestamp: number(),
|
|
6753
|
+
/**
|
|
6754
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6755
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6756
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6757
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6758
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6759
|
+
*/
|
|
6760
|
+
format: AudioChunkFormatSchema.optional()
|
|
6672
6761
|
});
|
|
6673
6762
|
/**
|
|
6674
6763
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6680,7 +6769,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6680
6769
|
var SubscribeAudioChunksInputSchema = object({
|
|
6681
6770
|
brokerId: string(),
|
|
6682
6771
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6683
|
-
tag: string().optional()
|
|
6772
|
+
tag: string().optional(),
|
|
6773
|
+
/**
|
|
6774
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6775
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6776
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6777
|
+
*
|
|
6778
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6779
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6780
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6781
|
+
* deploy one at a time across three nodes.
|
|
6782
|
+
*/
|
|
6783
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6684
6784
|
});
|
|
6685
6785
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6686
6786
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10889,6 +10989,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10889
10989
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10890
10990
|
allowedClasses: array(string()).default([])
|
|
10891
10991
|
});
|
|
10992
|
+
/**
|
|
10993
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10994
|
+
*
|
|
10995
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10996
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10997
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10998
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10999
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
11000
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
11001
|
+
* way to the one expansion that feeds the model.
|
|
11002
|
+
*
|
|
11003
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
11004
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
11005
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
11006
|
+
*/
|
|
11007
|
+
var AudioAttachDeviceInputSchema = object({
|
|
11008
|
+
deviceId: number(),
|
|
11009
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
11010
|
+
brokerId: string(),
|
|
11011
|
+
/**
|
|
11012
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
11013
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
11014
|
+
* the orchestrator's poller pinned them before the move.
|
|
11015
|
+
*/
|
|
11016
|
+
ingestNodeId: string(),
|
|
11017
|
+
/**
|
|
11018
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
11019
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
11020
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
11021
|
+
*/
|
|
11022
|
+
settings: AudioAnalysisSettingsSchema
|
|
11023
|
+
});
|
|
11024
|
+
var AudioAttachDeviceResultSchema = object({
|
|
11025
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
11026
|
+
attached: boolean(),
|
|
11027
|
+
/**
|
|
11028
|
+
* True when the attachment replaced a live one for the same device. An
|
|
11029
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
11030
|
+
* double the broker's fanout and neither would know about the other.
|
|
11031
|
+
*/
|
|
11032
|
+
replaced: boolean()
|
|
11033
|
+
});
|
|
11034
|
+
var AudioDetachDeviceResultSchema = object({
|
|
11035
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
11036
|
+
detached: boolean() });
|
|
10892
11037
|
var AudioClassificationResultSchema = object({
|
|
10893
11038
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10894
11039
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10897,7 +11042,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10897
11042
|
method(object({
|
|
10898
11043
|
chunk: AudioChunkInputSchema,
|
|
10899
11044
|
settings: AudioAnalysisSettingsSchema
|
|
10900
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11045
|
+
}), 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() }), {
|
|
10901
11046
|
kind: "mutation",
|
|
10902
11047
|
auth: "admin"
|
|
10903
11048
|
});
|
|
@@ -25086,8 +25231,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
|
|
|
25086
25231
|
*
|
|
25087
25232
|
* An **empty array reads NOTHING** — `[]` is an empty page, never
|
|
25088
25233
|
* "every camera". A request for no devices is a request, not an
|
|
25089
|
-
* omission; same contract as `deviceManager.
|
|
25090
|
-
* `pipelineAnalytics.listRecentTracks`.
|
|
25234
|
+
* omission; same contract as `deviceManager.listAll`'s `deviceIds`
|
|
25235
|
+
* and `pipelineAnalytics.listRecentTracks`.
|
|
25091
25236
|
*
|
|
25092
25237
|
* Absent (`undefined`) is the omission, and keeps the cluster-wide view.
|
|
25093
25238
|
*/
|
|
@@ -30855,12 +31000,24 @@ Object.freeze({
|
|
|
30855
31000
|
addonId: null,
|
|
30856
31001
|
access: "create"
|
|
30857
31002
|
},
|
|
31003
|
+
"audioAnalyzer.attachDevice": {
|
|
31004
|
+
capName: "audio-analyzer",
|
|
31005
|
+
capScope: "system",
|
|
31006
|
+
addonId: null,
|
|
31007
|
+
access: "create"
|
|
31008
|
+
},
|
|
30858
31009
|
"audioAnalyzer.classify": {
|
|
30859
31010
|
capName: "audio-analyzer",
|
|
30860
31011
|
capScope: "system",
|
|
30861
31012
|
addonId: null,
|
|
30862
31013
|
access: "view"
|
|
30863
31014
|
},
|
|
31015
|
+
"audioAnalyzer.detachDevice": {
|
|
31016
|
+
capName: "audio-analyzer",
|
|
31017
|
+
capScope: "system",
|
|
31018
|
+
addonId: null,
|
|
31019
|
+
access: "create"
|
|
31020
|
+
},
|
|
30864
31021
|
"audioAnalyzer.dispose": {
|
|
30865
31022
|
capName: "audio-analyzer",
|
|
30866
31023
|
capScope: "system",
|
|
@@ -36704,11 +36861,21 @@ Object.freeze({
|
|
|
36704
36861
|
form: "single",
|
|
36705
36862
|
optional: false
|
|
36706
36863
|
}],
|
|
36864
|
+
"audioAnalyzer.attachDevice": [{
|
|
36865
|
+
name: "deviceId",
|
|
36866
|
+
form: "single",
|
|
36867
|
+
optional: false
|
|
36868
|
+
}],
|
|
36707
36869
|
"audioAnalyzer.classify": [{
|
|
36708
36870
|
name: "deviceId",
|
|
36709
36871
|
form: "single",
|
|
36710
36872
|
optional: true
|
|
36711
36873
|
}],
|
|
36874
|
+
"audioAnalyzer.detachDevice": [{
|
|
36875
|
+
name: "deviceId",
|
|
36876
|
+
form: "single",
|
|
36877
|
+
optional: false
|
|
36878
|
+
}],
|
|
36712
36879
|
"audioMetrics.getCurrentSnapshot": [{
|
|
36713
36880
|
name: "deviceId",
|
|
36714
36881
|
form: "single",
|
|
@@ -38560,6 +38727,52 @@ Object.freeze({
|
|
|
38560
38727
|
"network-access": "ingress",
|
|
38561
38728
|
"smtp-provider": "email"
|
|
38562
38729
|
});
|
|
38730
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
38731
|
+
PCMU: 20 * Math.log10(4),
|
|
38732
|
+
PCMA: 20 * Math.log10(8)
|
|
38733
|
+
};
|
|
38734
|
+
/**
|
|
38735
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
38736
|
+
* same intent on the ITU-T scale (D460).
|
|
38737
|
+
*
|
|
38738
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
38739
|
+
*
|
|
38740
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
38741
|
+
* them converts:
|
|
38742
|
+
*
|
|
38743
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
38744
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
38745
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
38746
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
38747
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
38748
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
38749
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
38750
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
38751
|
+
* louder. That is what this function is for.
|
|
38752
|
+
*
|
|
38753
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
38754
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
38755
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
38756
|
+
* mandatory.
|
|
38757
|
+
*
|
|
38758
|
+
* ## Why a function and not a typed-in number
|
|
38759
|
+
*
|
|
38760
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
38761
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
38762
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
38763
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
38764
|
+
* having to reverse-engineer the sum.
|
|
38765
|
+
*
|
|
38766
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
38767
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
38768
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
38769
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
38770
|
+
* an extra place to argue with (D459).
|
|
38771
|
+
*/
|
|
38772
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
38773
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
38774
|
+
}
|
|
38775
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
38563
38776
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
38564
38777
|
var NC_AUDIO_DEFAULTS = {
|
|
38565
38778
|
hitPercent: 60,
|
|
@@ -5345,6 +5345,86 @@ var ZodIssueCode = {
|
|
|
5345
5345
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5346
5346
|
var ZodFirstPartyTypeKind;
|
|
5347
5347
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5348
|
+
//#endregion
|
|
5349
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5350
|
+
/**
|
|
5351
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5352
|
+
* window to float samples (D455).
|
|
5353
|
+
*
|
|
5354
|
+
* ## Why a format at all
|
|
5355
|
+
*
|
|
5356
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5357
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5358
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5359
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5360
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5361
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5362
|
+
*
|
|
5363
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5364
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5365
|
+
* one step further along the same wire.
|
|
5366
|
+
*
|
|
5367
|
+
* ## Why the expansion lives here
|
|
5368
|
+
*
|
|
5369
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5370
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5371
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5372
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5373
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5374
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5375
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5376
|
+
* `camstack deploy` and needs no published server.
|
|
5377
|
+
*
|
|
5378
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5379
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5380
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5381
|
+
*
|
|
5382
|
+
* ## Absent means f32le
|
|
5383
|
+
*
|
|
5384
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5385
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5386
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5387
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5388
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5389
|
+
* deployable one addon at a time across three nodes.
|
|
5390
|
+
*/
|
|
5391
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5392
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5393
|
+
"f32le",
|
|
5394
|
+
"pcmu",
|
|
5395
|
+
"pcma"
|
|
5396
|
+
];
|
|
5397
|
+
/**
|
|
5398
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5399
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5400
|
+
*
|
|
5401
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5402
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5403
|
+
*/
|
|
5404
|
+
function buildUlawTable() {
|
|
5405
|
+
const table = new Float32Array(256);
|
|
5406
|
+
for (let i = 0; i < 256; i++) {
|
|
5407
|
+
const complemented = ~i & 255;
|
|
5408
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5409
|
+
const exponent = complemented >> 4 & 7;
|
|
5410
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5411
|
+
}
|
|
5412
|
+
return table;
|
|
5413
|
+
}
|
|
5414
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5415
|
+
function buildAlawTable() {
|
|
5416
|
+
const table = new Float32Array(256);
|
|
5417
|
+
for (let i = 0; i < 256; i++) {
|
|
5418
|
+
const xored = i ^ 85;
|
|
5419
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5420
|
+
const exponent = xored >> 4 & 7;
|
|
5421
|
+
const mantissa = xored & 15;
|
|
5422
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5423
|
+
}
|
|
5424
|
+
return table;
|
|
5425
|
+
}
|
|
5426
|
+
buildUlawTable();
|
|
5427
|
+
buildAlawTable();
|
|
5348
5428
|
Object.fromEntries([
|
|
5349
5429
|
{
|
|
5350
5430
|
id: "overview",
|
|
@@ -6637,11 +6717,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6637
6717
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6638
6718
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6639
6719
|
*/
|
|
6720
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6640
6721
|
var DecodedAudioChunkSchema = object({
|
|
6641
6722
|
data: _instanceof(Uint8Array),
|
|
6642
6723
|
sampleRate: number().int().positive(),
|
|
6643
6724
|
channels: number().int().positive(),
|
|
6644
|
-
timestamp: number()
|
|
6725
|
+
timestamp: number(),
|
|
6726
|
+
/**
|
|
6727
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6728
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6729
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6730
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6731
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6732
|
+
*/
|
|
6733
|
+
format: AudioChunkFormatSchema.optional()
|
|
6645
6734
|
});
|
|
6646
6735
|
/**
|
|
6647
6736
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6653,7 +6742,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6653
6742
|
var SubscribeAudioChunksInputSchema = object({
|
|
6654
6743
|
brokerId: string(),
|
|
6655
6744
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6656
|
-
tag: string().optional()
|
|
6745
|
+
tag: string().optional(),
|
|
6746
|
+
/**
|
|
6747
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6748
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6749
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6750
|
+
*
|
|
6751
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6752
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6753
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6754
|
+
* deploy one at a time across three nodes.
|
|
6755
|
+
*/
|
|
6756
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6657
6757
|
});
|
|
6658
6758
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6659
6759
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10862,6 +10962,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10862
10962
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10863
10963
|
allowedClasses: array(string()).default([])
|
|
10864
10964
|
});
|
|
10965
|
+
/**
|
|
10966
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10967
|
+
*
|
|
10968
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10969
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10970
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10971
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10972
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
10973
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
10974
|
+
* way to the one expansion that feeds the model.
|
|
10975
|
+
*
|
|
10976
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
10977
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
10978
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
10979
|
+
*/
|
|
10980
|
+
var AudioAttachDeviceInputSchema = object({
|
|
10981
|
+
deviceId: number(),
|
|
10982
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
10983
|
+
brokerId: string(),
|
|
10984
|
+
/**
|
|
10985
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
10986
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
10987
|
+
* the orchestrator's poller pinned them before the move.
|
|
10988
|
+
*/
|
|
10989
|
+
ingestNodeId: string(),
|
|
10990
|
+
/**
|
|
10991
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
10992
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
10993
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
10994
|
+
*/
|
|
10995
|
+
settings: AudioAnalysisSettingsSchema
|
|
10996
|
+
});
|
|
10997
|
+
var AudioAttachDeviceResultSchema = object({
|
|
10998
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
10999
|
+
attached: boolean(),
|
|
11000
|
+
/**
|
|
11001
|
+
* True when the attachment replaced a live one for the same device. An
|
|
11002
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
11003
|
+
* double the broker's fanout and neither would know about the other.
|
|
11004
|
+
*/
|
|
11005
|
+
replaced: boolean()
|
|
11006
|
+
});
|
|
11007
|
+
var AudioDetachDeviceResultSchema = object({
|
|
11008
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
11009
|
+
detached: boolean() });
|
|
10865
11010
|
var AudioClassificationResultSchema = object({
|
|
10866
11011
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10867
11012
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10870,7 +11015,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10870
11015
|
method(object({
|
|
10871
11016
|
chunk: AudioChunkInputSchema,
|
|
10872
11017
|
settings: AudioAnalysisSettingsSchema
|
|
10873
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11018
|
+
}), 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() }), {
|
|
10874
11019
|
kind: "mutation",
|
|
10875
11020
|
auth: "admin"
|
|
10876
11021
|
});
|
|
@@ -25059,8 +25204,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
|
|
|
25059
25204
|
*
|
|
25060
25205
|
* An **empty array reads NOTHING** — `[]` is an empty page, never
|
|
25061
25206
|
* "every camera". A request for no devices is a request, not an
|
|
25062
|
-
* omission; same contract as `deviceManager.
|
|
25063
|
-
* `pipelineAnalytics.listRecentTracks`.
|
|
25207
|
+
* omission; same contract as `deviceManager.listAll`'s `deviceIds`
|
|
25208
|
+
* and `pipelineAnalytics.listRecentTracks`.
|
|
25064
25209
|
*
|
|
25065
25210
|
* Absent (`undefined`) is the omission, and keeps the cluster-wide view.
|
|
25066
25211
|
*/
|
|
@@ -30828,12 +30973,24 @@ Object.freeze({
|
|
|
30828
30973
|
addonId: null,
|
|
30829
30974
|
access: "create"
|
|
30830
30975
|
},
|
|
30976
|
+
"audioAnalyzer.attachDevice": {
|
|
30977
|
+
capName: "audio-analyzer",
|
|
30978
|
+
capScope: "system",
|
|
30979
|
+
addonId: null,
|
|
30980
|
+
access: "create"
|
|
30981
|
+
},
|
|
30831
30982
|
"audioAnalyzer.classify": {
|
|
30832
30983
|
capName: "audio-analyzer",
|
|
30833
30984
|
capScope: "system",
|
|
30834
30985
|
addonId: null,
|
|
30835
30986
|
access: "view"
|
|
30836
30987
|
},
|
|
30988
|
+
"audioAnalyzer.detachDevice": {
|
|
30989
|
+
capName: "audio-analyzer",
|
|
30990
|
+
capScope: "system",
|
|
30991
|
+
addonId: null,
|
|
30992
|
+
access: "create"
|
|
30993
|
+
},
|
|
30837
30994
|
"audioAnalyzer.dispose": {
|
|
30838
30995
|
capName: "audio-analyzer",
|
|
30839
30996
|
capScope: "system",
|
|
@@ -36677,11 +36834,21 @@ Object.freeze({
|
|
|
36677
36834
|
form: "single",
|
|
36678
36835
|
optional: false
|
|
36679
36836
|
}],
|
|
36837
|
+
"audioAnalyzer.attachDevice": [{
|
|
36838
|
+
name: "deviceId",
|
|
36839
|
+
form: "single",
|
|
36840
|
+
optional: false
|
|
36841
|
+
}],
|
|
36680
36842
|
"audioAnalyzer.classify": [{
|
|
36681
36843
|
name: "deviceId",
|
|
36682
36844
|
form: "single",
|
|
36683
36845
|
optional: true
|
|
36684
36846
|
}],
|
|
36847
|
+
"audioAnalyzer.detachDevice": [{
|
|
36848
|
+
name: "deviceId",
|
|
36849
|
+
form: "single",
|
|
36850
|
+
optional: false
|
|
36851
|
+
}],
|
|
36685
36852
|
"audioMetrics.getCurrentSnapshot": [{
|
|
36686
36853
|
name: "deviceId",
|
|
36687
36854
|
form: "single",
|
|
@@ -38533,6 +38700,52 @@ Object.freeze({
|
|
|
38533
38700
|
"network-access": "ingress",
|
|
38534
38701
|
"smtp-provider": "email"
|
|
38535
38702
|
});
|
|
38703
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
38704
|
+
PCMU: 20 * Math.log10(4),
|
|
38705
|
+
PCMA: 20 * Math.log10(8)
|
|
38706
|
+
};
|
|
38707
|
+
/**
|
|
38708
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
38709
|
+
* same intent on the ITU-T scale (D460).
|
|
38710
|
+
*
|
|
38711
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
38712
|
+
*
|
|
38713
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
38714
|
+
* them converts:
|
|
38715
|
+
*
|
|
38716
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
38717
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
38718
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
38719
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
38720
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
38721
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
38722
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
38723
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
38724
|
+
* louder. That is what this function is for.
|
|
38725
|
+
*
|
|
38726
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
38727
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
38728
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
38729
|
+
* mandatory.
|
|
38730
|
+
*
|
|
38731
|
+
* ## Why a function and not a typed-in number
|
|
38732
|
+
*
|
|
38733
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
38734
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
38735
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
38736
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
38737
|
+
* having to reverse-engineer the sum.
|
|
38738
|
+
*
|
|
38739
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
38740
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
38741
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
38742
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
38743
|
+
* an extra place to argue with (D459).
|
|
38744
|
+
*/
|
|
38745
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
38746
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
38747
|
+
}
|
|
38748
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
38536
38749
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
38537
38750
|
var NC_AUDIO_DEFAULTS = {
|
|
38538
38751
|
hitPercent: 60,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-export-alexa",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.102",
|
|
4
4
|
"description": "Alexa Smart Home Skill export — hub-side OAuth provider + directive handler. The companion AWS Lambda forwards Alexa directives to this addon's /addon/export-alexa/directive endpoint.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|