speechrecorderng 3.0.0 → 3.0.1
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/esm2020/lib/speechrecorder/recording.mjs +12 -1
- package/esm2020/lib/speechrecorder/recordings/recordings.service.mjs +22 -25
- package/esm2020/lib/speechrecorder/session/recording_file_cache.mjs +22 -9
- package/esm2020/lib/spr.module.version.mjs +2 -2
- package/fesm2015/speechrecorderng.mjs +54 -33
- package/fesm2015/speechrecorderng.mjs.map +1 -1
- package/fesm2020/speechrecorderng.mjs +54 -33
- package/fesm2020/speechrecorderng.mjs.map +1 -1
- package/lib/speechrecorder/recording.d.ts +1 -0
- package/lib/speechrecorder/session/recording_file_cache.d.ts +7 -4
- package/lib/spr.module.version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -2291,6 +2291,17 @@ class SprRecordingFile extends RecordingFile {
|
|
|
2291
2291
|
}
|
|
2292
2292
|
}
|
|
2293
2293
|
class RecordingFileUtils {
|
|
2294
|
+
static equals(recordinFile, otherRecordingFile) {
|
|
2295
|
+
if (recordinFile && otherRecordingFile) {
|
|
2296
|
+
if (otherRecordingFile === recordinFile) {
|
|
2297
|
+
return true;
|
|
2298
|
+
}
|
|
2299
|
+
if (otherRecordingFile.uuid === recordinFile.uuid) {
|
|
2300
|
+
return true;
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
return false;
|
|
2304
|
+
}
|
|
2294
2305
|
static setAudioData(rf, audioDataHolder) {
|
|
2295
2306
|
rf.audioDataHolder = audioDataHolder;
|
|
2296
2307
|
if (audioDataHolder) {
|
|
@@ -9163,8 +9174,15 @@ class BasicRecFilesCache {
|
|
|
9163
9174
|
constructor() {
|
|
9164
9175
|
//public static readonly DEFAULT_MAX_SAMPLES=30*48000; // TEST 30 seconds
|
|
9165
9176
|
this._sampleCount = 0;
|
|
9166
|
-
this.maxSampleCount =
|
|
9167
|
-
this.
|
|
9177
|
+
this.maxSampleCount = BasicRecFilesCache.DEFAULT_MAX_SAMPLES;
|
|
9178
|
+
this._currentRecordingFile = null;
|
|
9179
|
+
}
|
|
9180
|
+
get currentRecordingFile() {
|
|
9181
|
+
return this._currentRecordingFile;
|
|
9182
|
+
}
|
|
9183
|
+
set currentRecordingFile(value) {
|
|
9184
|
+
this._currentRecordingFile = value;
|
|
9185
|
+
this.expire();
|
|
9168
9186
|
}
|
|
9169
9187
|
}
|
|
9170
9188
|
BasicRecFilesCache.DEBUG = false;
|
|
@@ -9189,7 +9207,7 @@ class SprItemsCache extends BasicRecFilesCache {
|
|
|
9189
9207
|
tryExpire(toBeExpiredRf) {
|
|
9190
9208
|
if (BasicRecFilesCache.DEBUG)
|
|
9191
9209
|
console.debug("Rec. files cache: " + toBeExpiredRf.toString() + " try expire:");
|
|
9192
|
-
if (!
|
|
9210
|
+
if (!RecordingFileUtils.equals(toBeExpiredRf, this.currentRecordingFile)) {
|
|
9193
9211
|
if (BasicRecFilesCache.DEBUG)
|
|
9194
9212
|
console.debug("Rec. files cache: " + toBeExpiredRf.toString() + " not current file...");
|
|
9195
9213
|
if (toBeExpiredRf.serverPersisted) {
|
|
@@ -9308,12 +9326,18 @@ class RecFilesCache extends BasicRecFilesCache {
|
|
|
9308
9326
|
}
|
|
9309
9327
|
let toBeExpiredRf = this._recFiles[rfI];
|
|
9310
9328
|
if (toBeExpiredRf.serverPersisted) {
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9329
|
+
if (!RecordingFileUtils.equals(toBeExpiredRf, this.currentRecordingFile)) {
|
|
9330
|
+
// expire recording files first stored to the cache
|
|
9331
|
+
let expiredAudio = RecordingFileUtils.expireAudioData(toBeExpiredRf);
|
|
9332
|
+
if (expiredAudio) {
|
|
9333
|
+
this._sampleCount -= expiredAudio.sampleCounts();
|
|
9334
|
+
if (BasicRecFilesCache.DEBUG)
|
|
9335
|
+
console.debug("Rec. files cache: Expired #" + rfI + ". Cache samples: " + this._sampleCount);
|
|
9336
|
+
}
|
|
9337
|
+
}
|
|
9338
|
+
else {
|
|
9315
9339
|
if (BasicRecFilesCache.DEBUG)
|
|
9316
|
-
console.debug("Rec. files cache:
|
|
9340
|
+
console.debug("Rec. files cache: #" + rfI + " is current file. (not expiring)");
|
|
9317
9341
|
}
|
|
9318
9342
|
}
|
|
9319
9343
|
else {
|
|
@@ -9439,33 +9463,30 @@ class RecordingService {
|
|
|
9439
9463
|
}
|
|
9440
9464
|
if (recordingFile.session && recFileId) {
|
|
9441
9465
|
let obs = this.fetchAudiofile(projectName, recordingFile.session, recFileId);
|
|
9442
|
-
obs.subscribe({
|
|
9443
|
-
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
observer.next(ab);
|
|
9448
|
-
observer.complete();
|
|
9449
|
-
}, error => {
|
|
9450
|
-
observer.error(error);
|
|
9451
|
-
observer.complete();
|
|
9452
|
-
});
|
|
9453
|
-
}
|
|
9454
|
-
else {
|
|
9455
|
-
observer.error('Fetching audio file: response has no body');
|
|
9456
|
-
}
|
|
9457
|
-
},
|
|
9458
|
-
error: (error) => {
|
|
9459
|
-
if (error.status == 404) {
|
|
9460
|
-
// Interpret not as an error, the file ist not recorded yet
|
|
9461
|
-
observer.next(null);
|
|
9466
|
+
obs.subscribe(resp => {
|
|
9467
|
+
// Do not use Promise version, which does not work with Safari 13 (13.0.5)
|
|
9468
|
+
if (resp.body) {
|
|
9469
|
+
aCtx.decodeAudioData(resp.body, ab => {
|
|
9470
|
+
observer.next(ab);
|
|
9462
9471
|
observer.complete();
|
|
9463
|
-
}
|
|
9464
|
-
else {
|
|
9465
|
-
// all other states are errors
|
|
9472
|
+
}, error => {
|
|
9466
9473
|
observer.error(error);
|
|
9467
9474
|
observer.complete();
|
|
9468
|
-
}
|
|
9475
|
+
});
|
|
9476
|
+
}
|
|
9477
|
+
else {
|
|
9478
|
+
observer.error('Fetching audio file: response has no body');
|
|
9479
|
+
}
|
|
9480
|
+
}, (error) => {
|
|
9481
|
+
if (error.status == 404) {
|
|
9482
|
+
// Interpret not as an error, the file ist not recorded yet
|
|
9483
|
+
observer.next(null);
|
|
9484
|
+
observer.complete();
|
|
9485
|
+
}
|
|
9486
|
+
else {
|
|
9487
|
+
// all other states are errors
|
|
9488
|
+
observer.error(error);
|
|
9489
|
+
observer.complete();
|
|
9469
9490
|
}
|
|
9470
9491
|
});
|
|
9471
9492
|
}
|
|
@@ -13886,7 +13907,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
13886
13907
|
}]
|
|
13887
13908
|
}] });
|
|
13888
13909
|
|
|
13889
|
-
const VERSION = '3.0.
|
|
13910
|
+
const VERSION = '3.0.1';
|
|
13890
13911
|
|
|
13891
13912
|
/*
|
|
13892
13913
|
* Public API Surface of speechrecorderng
|