|
@@ -9,8 +9,7 @@ import RnnoiseProcessor from './RnnoiseProcessor';
|
9
|
9
|
export { RNNOISE_SAMPLE_LENGTH } from './RnnoiseProcessor';
|
10
|
10
|
export type { RnnoiseProcessor };
|
11
|
11
|
|
12
|
|
-let rnnoiseWasmInterface;
|
13
|
|
-let initializePromise;
|
|
12
|
+let rnnoiseModule;
|
14
|
13
|
|
15
|
14
|
/**
|
16
|
15
|
* Creates a new instance of RnnoiseProcessor.
|
|
@@ -18,20 +17,9 @@ let initializePromise;
|
18
|
17
|
* @returns {Promise<RnnoiseProcessor>}
|
19
|
18
|
*/
|
20
|
19
|
export function createRnnoiseProcessor() {
|
21
|
|
- if (!initializePromise) {
|
22
|
|
- initializePromise = new Promise((resolve, reject) => {
|
23
|
|
- rnnoiseWasmInterface = rnnoiseWasmInit({
|
24
|
|
- onRuntimeInitialized() {
|
25
|
|
- resolve();
|
26
|
|
- },
|
27
|
|
- onAbort(reason) {
|
28
|
|
- reject(reason);
|
29
|
|
- }
|
30
|
|
- });
|
31
|
|
- });
|
|
20
|
+ if (!rnnoiseModule) {
|
|
21
|
+ rnnoiseModule = rnnoiseWasmInit();
|
32
|
22
|
}
|
33
|
23
|
|
34
|
|
- return initializePromise.then(
|
35
|
|
- () => new RnnoiseProcessor(rnnoiseWasmInterface)
|
36
|
|
- );
|
|
24
|
+ return rnnoiseModule.then(mod => new RnnoiseProcessor(mod));
|
37
|
25
|
}
|