echogarden 1.7.0 → 1.8.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.
Files changed (54) hide show
  1. package/data/schemas/options.json +22 -10
  2. package/dist/api/Alignment.js +2 -2
  3. package/dist/api/Alignment.js.map +1 -1
  4. package/dist/api/Denoising.js +5 -4
  5. package/dist/api/Denoising.js.map +1 -1
  6. package/dist/api/Recognition.js +2 -2
  7. package/dist/api/Recognition.js.map +1 -1
  8. package/dist/api/SourceSeparation.d.ts +2 -6
  9. package/dist/api/SourceSeparation.js +8 -9
  10. package/dist/api/SourceSeparation.js.map +1 -1
  11. package/dist/api/SpeechLanguageDetection.js +2 -2
  12. package/dist/api/SpeechLanguageDetection.js.map +1 -1
  13. package/dist/api/SpeechTranslation.js +2 -2
  14. package/dist/api/SpeechTranslation.js.map +1 -1
  15. package/dist/api/Synthesis.js +5 -5
  16. package/dist/api/Synthesis.js.map +1 -1
  17. package/dist/api/TranslationAlignment.js +2 -2
  18. package/dist/api/TranslationAlignment.js.map +1 -1
  19. package/dist/audio/AudioUtilities.d.ts +5 -3
  20. package/dist/audio/AudioUtilities.js +39 -25
  21. package/dist/audio/AudioUtilities.js.map +1 -1
  22. package/dist/dsp/FFT.d.ts +2 -1
  23. package/dist/dsp/FFT.js +37 -18
  24. package/dist/dsp/FFT.js.map +1 -1
  25. package/dist/nlp/IPA.d.ts +3 -3
  26. package/dist/recognition/WhisperSTT.d.ts +3 -0
  27. package/dist/recognition/WhisperSTT.js +12 -5
  28. package/dist/recognition/WhisperSTT.js.map +1 -1
  29. package/dist/source-separation/MDXNetSourceSeparation.d.ts +8 -3
  30. package/dist/source-separation/MDXNetSourceSeparation.js +35 -13
  31. package/dist/source-separation/MDXNetSourceSeparation.js.map +1 -1
  32. package/dist/utilities/PackageManager.js +3 -6
  33. package/dist/utilities/PackageManager.js.map +1 -1
  34. package/dist/utilities/WasmMemoryManager.d.ts +9 -1
  35. package/dist/utilities/WasmMemoryManager.js +24 -3
  36. package/dist/utilities/WasmMemoryManager.js.map +1 -1
  37. package/docs/Options.md +9 -9
  38. package/package.json +6 -5
  39. package/src/alignment/SpeechAlignment.ts +1 -1
  40. package/src/api/Alignment.ts +2 -2
  41. package/src/api/Denoising.ts +5 -4
  42. package/src/api/Recognition.ts +3 -3
  43. package/src/api/SourceSeparation.ts +12 -16
  44. package/src/api/SpeechLanguageDetection.ts +2 -2
  45. package/src/api/SpeechTranslation.ts +2 -2
  46. package/src/api/Synthesis.ts +5 -5
  47. package/src/api/TranslationAlignment.ts +2 -2
  48. package/src/audio/AudioUtilities.ts +53 -33
  49. package/src/dsp/FFT.ts +45 -19
  50. package/src/recognition/WhisperSTT.ts +18 -6
  51. package/src/source-separation/MDXNetSourceSeparation.ts +44 -12
  52. package/src/typings/Fillers.d.ts +2 -0
  53. package/src/utilities/PackageManager.ts +3 -7
  54. package/src/utilities/WasmMemoryManager.ts +38 -4
@@ -1,10 +1,35 @@
1
1
  export class WasmMemoryManager {
2
2
  wasmModule: any
3
3
 
4
+ private wasmAlloc: WasmAllocMethod
5
+ private wasmFree: WasmFreeMethod
6
+
4
7
  private allocatedReferences = new Set<WasmRef>()
5
8
 
6
- constructor(wasmModule: any) {
9
+ constructor(wasmModule: any, options?: WasmMemoryManagerOptions) {
10
+ options = options ?? {}
11
+
7
12
  this.wasmModule = wasmModule
13
+
14
+ if (options.wasmAlloc) {
15
+ this.wasmAlloc = options.wasmAlloc
16
+ } else {
17
+ if (!wasmModule._malloc) {
18
+ throw new Error(`Couldn't find a '_malloc' function in the module and no custom 'wasmAlloc' was provided in the options`)
19
+ }
20
+
21
+ this.wasmAlloc = wasmModule._malloc
22
+ }
23
+
24
+ if (options.wasmFree) {
25
+ this.wasmFree = options.wasmFree
26
+ } else {
27
+ if (!wasmModule._free) {
28
+ throw new Error(`Couldn't find a '_malloc' function in the module and no custom 'wasmFree' was provided in the options`)
29
+ }
30
+
31
+ this.wasmFree = wasmModule._free
32
+ }
8
33
  }
9
34
 
10
35
  allocInt8() {
@@ -209,8 +234,9 @@ export class WasmMemoryManager {
209
234
  }
210
235
 
211
236
  private alloc(size: number) {
212
- const ptr = this.wasmModule._malloc(size)
213
- return ptr as number
237
+ const ptr = this.wasmAlloc(size)
238
+
239
+ return ptr
214
240
  }
215
241
 
216
242
  free(wasmReference: WasmRef) {
@@ -218,7 +244,7 @@ export class WasmMemoryManager {
218
244
  return
219
245
  }
220
246
 
221
- this.wasmModule._free(wasmReference.address)
247
+ this.wasmFree(wasmReference.address)
222
248
 
223
249
  this.allocatedReferences.delete(wasmReference)
224
250
  wasmReference.clearAddress()
@@ -514,3 +540,11 @@ export class Float64ArrayRef extends TypedArrayRef<Float64Array> {
514
540
 
515
541
  export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array
516
542
  export type WasmRef = ValueRef<number> | ValueRef<string> | TypedArrayRef<TypedArray>
543
+
544
+ export interface WasmMemoryManagerOptions {
545
+ wasmAlloc?: WasmAllocMethod
546
+ wasmFree?: WasmFreeMethod
547
+ }
548
+
549
+ export type WasmAllocMethod = (size: number) => number
550
+ export type WasmFreeMethod = (address: number) => void