med-scribe-alliance-ts-sdk 1.0.13 → 2.0.0
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/audio/audio-buffer-manager.d.ts +30 -23
- package/dist/audio/audio-buffer-manager.d.ts.map +1 -1
- package/dist/audio/audio-buffer-manager.js +62 -62
- package/dist/audio/audio-file-manager.d.ts +67 -30
- package/dist/audio/audio-file-manager.d.ts.map +1 -1
- package/dist/audio/audio-file-manager.js +124 -138
- package/dist/audio/constants.d.ts +17 -5
- package/dist/audio/constants.d.ts.map +1 -1
- package/dist/audio/constants.js +22 -5
- package/dist/audio/index.d.ts +3 -6
- package/dist/audio/index.d.ts.map +1 -1
- package/dist/audio/index.js +2 -6
- package/dist/audio/mp3-encoder.d.ts +17 -0
- package/dist/audio/mp3-encoder.d.ts.map +1 -0
- package/dist/audio/mp3-encoder.js +45 -0
- package/dist/audio/vad-client.d.ts +119 -0
- package/dist/audio/vad-client.d.ts.map +1 -0
- package/dist/audio/vad-client.js +326 -0
- package/dist/callbacks/callback-registry.d.ts +37 -0
- package/dist/callbacks/callback-registry.d.ts.map +1 -0
- package/dist/callbacks/callback-registry.js +72 -0
- package/dist/client.d.ts +126 -64
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +290 -265
- package/dist/{constants.d.ts → constants/index.d.ts} +30 -26
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/{constants.js → constants/index.js} +38 -28
- package/dist/discovery/discovery-manager.d.ts +43 -0
- package/dist/discovery/discovery-manager.d.ts.map +1 -0
- package/dist/discovery/discovery-manager.js +126 -0
- package/dist/discovery/resolved-config.d.ts +11 -0
- package/dist/discovery/resolved-config.d.ts.map +1 -0
- package/dist/discovery/resolved-config.js +40 -0
- package/dist/index.d.ts +13 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -9
- package/dist/recording/chunked-recorder.d.ts +98 -0
- package/dist/recording/chunked-recorder.d.ts.map +1 -0
- package/dist/recording/chunked-recorder.js +255 -0
- package/dist/recording/index.d.ts +5 -0
- package/dist/recording/index.d.ts.map +1 -0
- package/dist/recording/index.js +3 -0
- package/dist/recording/recording-manager.d.ts +143 -0
- package/dist/recording/recording-manager.d.ts.map +1 -0
- package/dist/recording/recording-manager.js +491 -0
- package/dist/recording/single-recorder.d.ts +58 -0
- package/dist/recording/single-recorder.d.ts.map +1 -0
- package/dist/recording/single-recorder.js +203 -0
- package/dist/session/session-manager.d.ts +55 -0
- package/dist/session/session-manager.d.ts.map +1 -0
- package/dist/session/session-manager.js +196 -0
- package/dist/transport/http-transport.d.ts +48 -0
- package/dist/transport/http-transport.d.ts.map +1 -0
- package/dist/transport/http-transport.js +227 -0
- package/dist/transport/ipc-transport.d.ts +61 -0
- package/dist/transport/ipc-transport.d.ts.map +1 -0
- package/dist/transport/ipc-transport.js +272 -0
- package/dist/transport/transport.interface.d.ts +9 -0
- package/dist/transport/transport.interface.d.ts.map +1 -0
- package/dist/transport/transport.interface.js +8 -0
- package/dist/types/callbacks.d.ts +113 -0
- package/dist/types/callbacks.d.ts.map +1 -0
- package/dist/types/callbacks.js +4 -0
- package/dist/types/common.d.ts +25 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +4 -0
- package/dist/types/config.d.ts +24 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +4 -0
- package/dist/types/discovery.d.ts +77 -0
- package/dist/types/discovery.d.ts.map +1 -0
- package/dist/types/discovery.js +4 -0
- package/dist/types/index.d.ts +10 -167
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -2
- package/dist/types/recording.d.ts +66 -0
- package/dist/types/recording.d.ts.map +1 -0
- package/dist/types/recording.js +4 -0
- package/dist/types/session.d.ts +75 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +4 -0
- package/dist/types/transport.d.ts +49 -0
- package/dist/types/transport.d.ts.map +1 -0
- package/dist/types/transport.js +4 -0
- package/dist/types/worker.d.ts +39 -0
- package/dist/types/worker.d.ts.map +1 -0
- package/dist/types/worker.js +4 -0
- package/dist/utils/errors.d.ts +23 -9
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +44 -5
- package/dist/utils/retry.d.ts +22 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +58 -0
- package/dist/validation/schemas/discovery-schema.d.ts +59 -0
- package/dist/validation/schemas/discovery-schema.d.ts.map +1 -0
- package/dist/validation/schemas/discovery-schema.js +69 -0
- package/dist/validation/schemas/request-schema.d.ts +20 -0
- package/dist/validation/schemas/request-schema.d.ts.map +1 -0
- package/dist/validation/schemas/request-schema.js +23 -0
- package/dist/validation/schemas/session-schema.d.ts +63 -0
- package/dist/validation/schemas/session-schema.d.ts.map +1 -0
- package/dist/validation/schemas/session-schema.js +78 -0
- package/dist/validation/validator.d.ts +34 -0
- package/dist/validation/validator.d.ts.map +1 -0
- package/dist/validation/validator.js +114 -0
- package/dist/worker/index.d.ts +3 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +1 -0
- package/dist/worker/shared-worker.d.ts +17 -0
- package/dist/worker/shared-worker.d.ts.map +1 -0
- package/dist/worker/shared-worker.js +194 -0
- package/dist/worker/worker-manager.d.ts +88 -0
- package/dist/worker/worker-manager.d.ts.map +1 -0
- package/dist/worker/worker-manager.js +270 -0
- package/package.json +3 -2
- package/dist/api/base.d.ts +0 -44
- package/dist/api/base.d.ts.map +0 -1
- package/dist/api/base.js +0 -119
- package/dist/api/discovery.d.ts +0 -30
- package/dist/api/discovery.d.ts.map +0 -1
- package/dist/api/discovery.js +0 -52
- package/dist/api/session.d.ts +0 -61
- package/dist/api/session.d.ts.map +0 -1
- package/dist/api/session.js +0 -96
- package/dist/audio/chunked-recorder.d.ts +0 -22
- package/dist/audio/chunked-recorder.d.ts.map +0 -1
- package/dist/audio/chunked-recorder.js +0 -119
- package/dist/audio/recorder.interface.d.ts +0 -17
- package/dist/audio/recorder.interface.d.ts.map +0 -1
- package/dist/audio/recorder.interface.js +0 -1
- package/dist/audio/single-recorder.d.ts +0 -24
- package/dist/audio/single-recorder.d.ts.map +0 -1
- package/dist/audio/single-recorder.js +0 -97
- package/dist/audio/types.d.ts +0 -37
- package/dist/audio/types.d.ts.map +0 -1
- package/dist/audio/types.js +0 -1
- package/dist/audio/utils.d.ts +0 -2
- package/dist/audio/utils.d.ts.map +0 -1
- package/dist/audio/utils.js +0 -32
- package/dist/audio/vad-web.d.ts +0 -61
- package/dist/audio/vad-web.d.ts.map +0 -1
- package/dist/audio/vad-web.js +0 -288
- package/dist/constants.d.ts.map +0 -1
- package/dist/utils/events.d.ts +0 -9
- package/dist/utils/events.d.ts.map +0 -1
- package/dist/utils/events.js +0 -27
- package/dist/utils/upload.d.ts +0 -27
- package/dist/utils/upload.d.ts.map +0 -1
- package/dist/utils/upload.js +0 -75
- package/dist/utils/validator.d.ts +0 -21
- package/dist/utils/validator.d.ts.map +0 -1
- package/dist/utils/validator.js +0 -140
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AudioBufferManager — accumulates audio frames into a growable Float32Array buffer.
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* - Append incoming audio frames from VAD
|
|
6
|
+
* - Track sample count, frame count, and duration
|
|
7
|
+
* - Provide the accumulated audio data for chunk processing
|
|
8
|
+
* - Calculate chunk timestamps based on raw sample position
|
|
9
|
+
* - Reset buffer state after a chunk is clipped (without re-allocating)
|
|
10
|
+
*/
|
|
1
11
|
export declare class AudioBufferManager {
|
|
2
12
|
private buffer;
|
|
3
13
|
private currentSampleLength;
|
|
@@ -5,49 +15,46 @@ export declare class AudioBufferManager {
|
|
|
5
15
|
private samplingRate;
|
|
6
16
|
private incrementalAllocationSize;
|
|
7
17
|
/**
|
|
8
|
-
* Class that creates an audio buffer to store frame data
|
|
9
18
|
* @param samplingRate - The sampling rate of the audio in Hz
|
|
10
19
|
* @param allocationTimeInSeconds - The size of each incremental allocation in seconds
|
|
11
20
|
*/
|
|
12
21
|
constructor(samplingRate: number, allocationTimeInSeconds: number);
|
|
13
22
|
/**
|
|
14
|
-
* Append audio frame to the buffer
|
|
15
|
-
*
|
|
16
|
-
* @returns The current position in the buffer after appending
|
|
23
|
+
* Append an audio frame to the buffer.
|
|
24
|
+
* Expands the buffer if needed.
|
|
17
25
|
*/
|
|
18
26
|
append(audioFrame: Float32Array): number;
|
|
19
27
|
/**
|
|
20
|
-
* Get the current audio data as a Float32Array
|
|
28
|
+
* Get the current audio data as a new Float32Array (copy, not reference).
|
|
21
29
|
*/
|
|
22
30
|
getAudioData(): Float32Array;
|
|
23
|
-
/**
|
|
24
|
-
* Get the current length of audio data in samples
|
|
25
|
-
* @returns The number of samples currently in the buffer
|
|
26
|
-
*/
|
|
27
31
|
getCurrentSampleLength(): number;
|
|
28
|
-
/**
|
|
29
|
-
* Get the current length of audio data in samples
|
|
30
|
-
* @returns The number of samples currently in the buffer
|
|
31
|
-
*/
|
|
32
32
|
getCurrentFrameLength(): number;
|
|
33
33
|
/**
|
|
34
|
-
* Get the current
|
|
35
|
-
* @returns The duration of audio currently in the buffer in seconds
|
|
34
|
+
* Get the current duration of buffered audio in seconds.
|
|
36
35
|
*/
|
|
37
36
|
getDurationInSeconds(): number;
|
|
38
37
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Calculate timestamps for an audio chunk
|
|
38
|
+
* Calculate timestamps for the current chunk relative to the overall recording.
|
|
39
|
+
*
|
|
40
|
+
* @param totalRawSamples - Total raw samples received since recording started
|
|
41
|
+
* @returns start and end timestamps formatted as MM:SS.ffffff
|
|
45
42
|
*/
|
|
46
|
-
calculateChunkTimestamps(
|
|
43
|
+
calculateChunkTimestamps(totalRawSamples: number): {
|
|
47
44
|
start: string;
|
|
48
45
|
end: string;
|
|
49
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Reset sample/frame counters without re-allocating the buffer.
|
|
49
|
+
* Called after a chunk is clipped and sent for processing.
|
|
50
|
+
*/
|
|
50
51
|
resetBufferState(): void;
|
|
51
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Full reset — re-allocates buffer memory.
|
|
54
|
+
* Called when recording is completely stopped/reset.
|
|
55
|
+
*/
|
|
56
|
+
resetInstance(): void;
|
|
57
|
+
private expandBuffer;
|
|
58
|
+
private formatTimestamp;
|
|
52
59
|
}
|
|
53
60
|
//# sourceMappingURL=audio-buffer-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audio-buffer-manager.d.ts","sourceRoot":"","sources":["../../src/audio/audio-buffer-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"audio-buffer-manager.d.ts","sourceRoot":"","sources":["../../src/audio/audio-buffer-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,mBAAmB,CAAa;IACxC,OAAO,CAAC,kBAAkB,CAAa;IACvC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,yBAAyB,CAAS;IAE1C;;;OAGG;gBACS,YAAY,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM;IAMjE;;;OAGG;IACH,MAAM,CAAC,UAAU,EAAE,YAAY,GAAG,MAAM;IAiBxC;;OAEG;IACH,YAAY,IAAI,YAAY;IAI5B,sBAAsB,IAAI,MAAM;IAIhC,qBAAqB,IAAI,MAAM;IAI/B;;OAEG;IACH,oBAAoB,IAAI,MAAM;IAI9B;;;;;OAKG;IACH,wBAAwB,CAAC,eAAe,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAgBjF;;;OAGG;IACH,gBAAgB,IAAI,IAAI;IAKxB;;;OAGG;IACH,aAAa,IAAI,IAAI;IAMrB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,eAAe;CAKxB"}
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* AudioBufferManager — accumulates audio frames into a growable Float32Array buffer.
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* - Append incoming audio frames from VAD
|
|
6
|
+
* - Track sample count, frame count, and duration
|
|
7
|
+
* - Provide the accumulated audio data for chunk processing
|
|
8
|
+
* - Calculate chunk timestamps based on raw sample position
|
|
9
|
+
* - Reset buffer state after a chunk is clipped (without re-allocating)
|
|
10
|
+
*/
|
|
2
11
|
export class AudioBufferManager {
|
|
3
12
|
/**
|
|
4
|
-
* Class that creates an audio buffer to store frame data
|
|
5
13
|
* @param samplingRate - The sampling rate of the audio in Hz
|
|
6
14
|
* @param allocationTimeInSeconds - The size of each incremental allocation in seconds
|
|
7
15
|
*/
|
|
8
16
|
constructor(samplingRate, allocationTimeInSeconds) {
|
|
9
17
|
this.currentSampleLength = 0;
|
|
10
18
|
this.currentFrameLength = 0;
|
|
11
|
-
this.samplingRate = 0;
|
|
12
|
-
this.incrementalAllocationSize = 0;
|
|
13
19
|
this.samplingRate = samplingRate;
|
|
14
|
-
// Calculate the size of each incremental allocation in samples
|
|
15
20
|
this.incrementalAllocationSize = Math.floor(samplingRate * allocationTimeInSeconds);
|
|
16
|
-
// Initialize buffer with the first allocation block
|
|
17
21
|
this.buffer = new Float32Array(this.incrementalAllocationSize);
|
|
18
|
-
this.currentSampleLength = 0;
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
21
|
-
* Append audio frame to the buffer
|
|
22
|
-
*
|
|
23
|
-
* @returns The current position in the buffer after appending
|
|
24
|
+
* Append an audio frame to the buffer.
|
|
25
|
+
* Expands the buffer if needed.
|
|
24
26
|
*/
|
|
25
27
|
append(audioFrame) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
try {
|
|
29
|
+
if (this.currentSampleLength + audioFrame.length > this.buffer.length) {
|
|
30
|
+
this.expandBuffer();
|
|
31
|
+
}
|
|
32
|
+
this.buffer.set(audioFrame, this.currentSampleLength);
|
|
33
|
+
this.currentSampleLength += audioFrame.length;
|
|
34
|
+
this.currentFrameLength += 1;
|
|
35
|
+
return this.currentSampleLength;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.error('[ScribeSDK] Error appending audio frame:', error);
|
|
39
|
+
return this.currentSampleLength;
|
|
29
40
|
}
|
|
30
|
-
// Copy the new frame into the buffer
|
|
31
|
-
this.buffer.set(audioFrame, this.currentSampleLength);
|
|
32
|
-
this.currentSampleLength += audioFrame.length; // for 1 frame increase by 1024
|
|
33
|
-
this.currentFrameLength += 1; // for 1 frame increase by 1
|
|
34
|
-
return this.currentSampleLength;
|
|
35
41
|
}
|
|
36
42
|
/**
|
|
37
|
-
* Get the current audio data as a Float32Array
|
|
43
|
+
* Get the current audio data as a new Float32Array (copy, not reference).
|
|
38
44
|
*/
|
|
39
45
|
getAudioData() {
|
|
40
46
|
return this.buffer.slice(0, this.currentSampleLength);
|
|
41
47
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Get the current length of audio data in samples
|
|
44
|
-
* @returns The number of samples currently in the buffer
|
|
45
|
-
*/
|
|
46
48
|
getCurrentSampleLength() {
|
|
47
49
|
return this.currentSampleLength;
|
|
48
50
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Get the current length of audio data in samples
|
|
51
|
-
* @returns The number of samples currently in the buffer
|
|
52
|
-
*/
|
|
53
51
|
getCurrentFrameLength() {
|
|
54
52
|
return this.currentFrameLength;
|
|
55
53
|
}
|
|
56
54
|
/**
|
|
57
|
-
* Get the current
|
|
58
|
-
* @returns The duration of audio currently in the buffer in seconds
|
|
55
|
+
* Get the current duration of buffered audio in seconds.
|
|
59
56
|
*/
|
|
60
57
|
getDurationInSeconds() {
|
|
61
58
|
return this.currentSampleLength / this.samplingRate;
|
|
62
59
|
}
|
|
63
60
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
61
|
+
* Calculate timestamps for the current chunk relative to the overall recording.
|
|
62
|
+
*
|
|
63
|
+
* @param totalRawSamples - Total raw samples received since recording started
|
|
64
|
+
* @returns start and end timestamps formatted as MM:SS.ffffff
|
|
66
65
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
calculateChunkTimestamps(totalRawSamples) {
|
|
67
|
+
try {
|
|
68
|
+
const chunkDuration = this.getDurationInSeconds();
|
|
69
|
+
const endSeconds = totalRawSamples / this.samplingRate;
|
|
70
|
+
const startSeconds = endSeconds - chunkDuration;
|
|
71
|
+
return {
|
|
72
|
+
start: this.formatTimestamp(Math.max(0, startSeconds)),
|
|
73
|
+
end: this.formatTimestamp(endSeconds),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error('[ScribeSDK] Error calculating chunk timestamps:', error);
|
|
78
|
+
return { start: '00:00.000000', end: '00:00.000000' };
|
|
79
|
+
}
|
|
74
80
|
}
|
|
75
81
|
/**
|
|
76
|
-
*
|
|
82
|
+
* Reset sample/frame counters without re-allocating the buffer.
|
|
83
|
+
* Called after a chunk is clipped and sent for processing.
|
|
77
84
|
*/
|
|
78
|
-
calculateChunkTimestamps(rawSamplesLength) {
|
|
79
|
-
const start = rawSamplesLength / SAMPLING_RATE - this.getDurationInSeconds();
|
|
80
|
-
const end = start + this.getDurationInSeconds();
|
|
81
|
-
// Format start time as MM:SS.ffffff
|
|
82
|
-
const startMinutes = Math.floor(start / 60)
|
|
83
|
-
.toString()
|
|
84
|
-
.padStart(2, '0');
|
|
85
|
-
const startSeconds = (start % 60).toFixed(6).toString().padStart(2, '0');
|
|
86
|
-
const formattedStartTime = `${startMinutes}:${startSeconds}`;
|
|
87
|
-
// Format end time as MM:SS.ffffff
|
|
88
|
-
const endMinutes = Math.floor(end / 60)
|
|
89
|
-
.toString()
|
|
90
|
-
.padStart(2, '0');
|
|
91
|
-
const endSeconds = (end % 60).toFixed(6).toString().padStart(2, '0');
|
|
92
|
-
const formattedEndTime = `${endMinutes}:${endSeconds}`;
|
|
93
|
-
// Return timestamp object
|
|
94
|
-
return {
|
|
95
|
-
start: formattedStartTime,
|
|
96
|
-
end: formattedEndTime,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
85
|
resetBufferState() {
|
|
100
|
-
// Zero out the existing buffer instead of allocating new memory
|
|
101
86
|
this.currentSampleLength = 0;
|
|
102
87
|
this.currentFrameLength = 0;
|
|
103
88
|
}
|
|
104
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Full reset — re-allocates buffer memory.
|
|
91
|
+
* Called when recording is completely stopped/reset.
|
|
92
|
+
*/
|
|
93
|
+
resetInstance() {
|
|
105
94
|
this.buffer = new Float32Array(this.incrementalAllocationSize);
|
|
106
95
|
this.currentSampleLength = 0;
|
|
107
96
|
this.currentFrameLength = 0;
|
|
108
97
|
}
|
|
98
|
+
expandBuffer() {
|
|
99
|
+
const newSize = this.buffer.length + this.incrementalAllocationSize;
|
|
100
|
+
const newBuffer = new Float32Array(newSize);
|
|
101
|
+
newBuffer.set(this.buffer, 0);
|
|
102
|
+
this.buffer = newBuffer;
|
|
103
|
+
}
|
|
104
|
+
formatTimestamp(seconds) {
|
|
105
|
+
const minutes = Math.floor(seconds / 60).toString().padStart(2, '0');
|
|
106
|
+
const secs = (seconds % 60).toFixed(6).padStart(9, '0');
|
|
107
|
+
return `${minutes}:${secs}`;
|
|
108
|
+
}
|
|
109
109
|
}
|
|
@@ -1,48 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* AudioFileManager — tracks audio chunk metadata throughout a recording session.
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* - Track chunk metadata (fileName, timestamps, status)
|
|
6
|
+
* - Track total raw samples/frames received from VAD
|
|
7
|
+
* - Track total inserted samples/frames (committed to chunks)
|
|
8
|
+
* - Mark chunks as success/failure after upload
|
|
9
|
+
* - Provide lists of successful/failed uploads
|
|
10
|
+
*
|
|
11
|
+
* This class does NOT handle upload logic — that's delegated to WorkerManager.
|
|
12
|
+
* File naming follows the protocol spec: audio_{sequence_number}.{extension}
|
|
13
|
+
*/
|
|
14
|
+
import { AudioChunkInfo } from '../types';
|
|
7
15
|
export declare class AudioFileManager {
|
|
8
|
-
|
|
9
|
-
private uploadPromises;
|
|
16
|
+
private chunks;
|
|
10
17
|
private successfulUploads;
|
|
11
18
|
private totalRawSamples;
|
|
12
19
|
private totalRawFrames;
|
|
13
20
|
private totalInsertedSamples;
|
|
14
21
|
private totalInsertedFrames;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
uploadUrl: string;
|
|
24
|
-
uploadHeaders?: Record<string, string>;
|
|
25
|
-
}): void;
|
|
26
|
-
setUploadProgressCallback(callback: UploadProgressCallback): void;
|
|
22
|
+
/**
|
|
23
|
+
* Track raw samples received from VAD (before chunking).
|
|
24
|
+
*/
|
|
25
|
+
incrementRawSamples(frame: Float32Array): void;
|
|
26
|
+
/**
|
|
27
|
+
* Track samples/frames committed to a chunk.
|
|
28
|
+
*/
|
|
29
|
+
incrementInsertedSamples(samples: number, frames: number): void;
|
|
27
30
|
getRawSampleDetails(): {
|
|
28
31
|
totalRawSamples: number;
|
|
29
32
|
totalRawFrames: number;
|
|
30
33
|
};
|
|
31
|
-
incrementTotalRawSamples(frames: Float32Array): void;
|
|
32
|
-
incrementInsertedSamples(samples: number, frames: number): void;
|
|
33
34
|
getInsertedSampleDetails(): {
|
|
34
35
|
totalInsertedSamples: number;
|
|
35
36
|
totalInsertedFrames: number;
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Generate the next chunk file name per protocol spec.
|
|
40
|
+
* Format: audio_{sequence_number}.{extension} (1-based index)
|
|
41
|
+
*/
|
|
42
|
+
getNextFileName(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Add a new chunk to the tracking list.
|
|
45
|
+
* Returns the chunk index (zero-based).
|
|
46
|
+
*/
|
|
47
|
+
addChunk(chunk: AudioChunkInfo): number;
|
|
48
|
+
/**
|
|
49
|
+
* Mark a chunk as successfully uploaded.
|
|
50
|
+
*/
|
|
51
|
+
markSuccess(chunkIndex: number, response?: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Mark a chunk as failed upload. Stores the blob for potential retry.
|
|
54
|
+
*/
|
|
55
|
+
markFailure(chunkIndex: number, fileBlob: Blob, errorMessage?: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Get all chunks.
|
|
58
|
+
*/
|
|
59
|
+
getChunks(): AudioChunkInfo[];
|
|
60
|
+
/**
|
|
61
|
+
* Get the total number of chunks.
|
|
62
|
+
*/
|
|
63
|
+
getChunkCount(): number;
|
|
64
|
+
/**
|
|
65
|
+
* Get list of successfully uploaded file names.
|
|
66
|
+
*/
|
|
41
67
|
getSuccessfulUploads(): string[];
|
|
68
|
+
/**
|
|
69
|
+
* Get list of file names that failed to upload.
|
|
70
|
+
*/
|
|
42
71
|
getFailedUploads(): string[];
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Get chunks that are in failure state (have blobs for retry).
|
|
74
|
+
*/
|
|
75
|
+
getFailedChunksWithBlobs(): Array<{
|
|
76
|
+
chunkIndex: number;
|
|
77
|
+
fileName: string;
|
|
78
|
+
fileBlob: Blob;
|
|
79
|
+
}>;
|
|
80
|
+
/**
|
|
81
|
+
* Full reset — clears all state.
|
|
82
|
+
*/
|
|
83
|
+
resetInstance(): void;
|
|
46
84
|
}
|
|
47
|
-
export {};
|
|
48
85
|
//# sourceMappingURL=audio-file-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audio-file-manager.d.ts","sourceRoot":"","sources":["../../src/audio/audio-file-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"audio-file-manager.d.ts","sourceRoot":"","sources":["../../src/audio/audio-file-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,iBAAiB,CAAgB;IACzC,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,cAAc,CAAa;IACnC,OAAO,CAAC,oBAAoB,CAAa;IACzC,OAAO,CAAC,mBAAmB,CAAa;IAExC;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAK9C;;OAEG;IACH,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAK/D,mBAAmB,IAAI;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE;IAO1E,wBAAwB,IAAI;QAAE,oBAAoB,EAAE,MAAM,CAAC;QAAC,mBAAmB,EAAE,MAAM,CAAA;KAAE;IAOzF;;;OAGG;IACH,eAAe,IAAI,MAAM;IAKzB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM;IAKvC;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAsBxD;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IAmB5E;;OAEG;IACH,SAAS,IAAI,cAAc,EAAE;IAI7B;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACH,oBAAoB,IAAI,MAAM,EAAE;IAIhC;;OAEG;IACH,gBAAgB,IAAI,MAAM,EAAE;IAM5B;;OAEG;IACH,wBAAwB,IAAI,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE,CAAC;IAU3F;;OAEG;IACH,aAAa,IAAI,IAAI;CAQtB"}
|