Hey, trying to use this with a web worker and webpack...
worker.ts
import { KokoroTTS } from 'kokoro-js';
export default () =>
self.addEventListener('message', async (event) => {
const { text } = event.data;
const tts = await KokoroTTS.from_pretrained(
'onnx-community/Kokoro-82M-ONNX',
{ dtype: 'fp16' }
);
const audio = await tts.generate(text, { voice: 'af_nicole' });
self.postMessage({
audioBuffer: audio.toWav()
});
});
tsconfig.json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"module": "esnext", <-- changed to get webpack to start
"jsx": "react-jsx",
"outDir": "./dist",
"target": "esnext",
"moduleResolution": "bundler" <-- changed to get webpack to start
},
"include": ["src/**/*.ts", "src/**/*.tsx"]
}
WARNING in ./node_modules/kokoro-js/dist/kokoro.web.js 1:127084-127093
Critical dependency: the request of a dependency is an expression
@ ./src/utils/worker.ts 10:0-38 13:22-47
@ ./src/pages/index.tsx 16:0-40 22:60-69
@ ./src/index.tsx 9:29-52
WARNING in ./node_modules/kokoro-js/dist/kokoro.web.js 1:465593-465604
Critical dependency: Accessing import.meta directly is unsupported (only property access or destructuring is supported)
@ ./src/utils/worker.ts 10:0-38 13:22-47
@ ./src/pages/index.tsx 16:0-40 22:60-69
@ ./src/index.tsx 9:29-52
2 warnings have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
ERROR in ./node_modules/kokoro-js/dist/kokoro.web.js 1:742156-742185
Module not found: Error: Can't resolve './' in 'C:\code\speechlab\node_modules\kokoro-js\dist'
resolve './' in 'C:\code\speechlab\node_modules\kokoro-js\dist'
Parsed request is a directory
using description file: C:\code\speechlab\node_modules\kokoro-js\package.json (relative path: ./dist)
using description file: C:\code\speechlab\node_modules\kokoro-js\package.json (relative path: ./dist)
as directory
existing directory C:\code\speechlab\node_modules\kokoro-js\dist
using description file: C:\code\speechlab\node_modules\kokoro-js\package.json (relative path: ./dist)
using path: C:\code\speechlab\node_modules\kokoro-js\dist\index
using description file: C:\code\speechlab\node_modules\kokoro-js\package.json (relative path: ./dist/index)
no extension
C:\code\speechlab\node_modules\kokoro-js\dist\index doesn't exist
.js
C:\code\speechlab\node_modules\kokoro-js\dist\index.js doesn't exist
.ts
C:\code\speechlab\node_modules\kokoro-js\dist\index.ts doesn't exist
.tsx
C:\code\speechlab\node_modules\kokoro-js\dist\index.tsx doesn't exist
.json
C:\code\speechlab\node_modules\kokoro-js\dist\index.json doesn't exist
@ ./src/utils/worker.ts 10:0-38 13:22-47
@ ./src/pages/index.tsx 16:0-40 22:60-69
@ ./src/index.tsx 9:29-52
Sorry, I couldn't find a better place to report this. Any ideas?