Create Kokoro TTS JavaScript library (#3)
* Set up JS project * Finalise JS library * Update README * Fix package.json repository url * Rename package -> `kokoro-js` * Fix samples in README * Cleanup README * Bump `phonemizer` version * Create web demo * Run prettier * Link to model used in demo * Enable multithreading in HF space demo (~40% faster) * Add link to demo in README * Bump to v1.0.1
This commit is contained in:
42
kokoro.js/rollup.config.js
Normal file
42
kokoro.js/rollup.config.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import terser from "@rollup/plugin-terser";
|
||||
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
||||
|
||||
const plugins = (browser) => [nodeResolve({ browser }), terser({ format: { comments: false } })];
|
||||
|
||||
const OUTPUT_CONFIGS = [
|
||||
// Node versions
|
||||
{
|
||||
file: "./dist/kokoro.cjs",
|
||||
format: "cjs",
|
||||
},
|
||||
{
|
||||
file: "./dist/kokoro.js",
|
||||
format: "esm",
|
||||
},
|
||||
|
||||
// Web version
|
||||
{
|
||||
file: "./dist/kokoro.web.js",
|
||||
format: "esm",
|
||||
},
|
||||
];
|
||||
|
||||
const WEB_SPECIFIC_CONFIG = {
|
||||
onwarn: (warning, warn) => {
|
||||
if (!warning.message.includes("@huggingface/transformers")) warn(warning);
|
||||
},
|
||||
};
|
||||
|
||||
const NODE_SPECIFIC_CONFIG = {
|
||||
external: ["@huggingface/transformers", "phonemizer"],
|
||||
};
|
||||
|
||||
export default OUTPUT_CONFIGS.map((output) => {
|
||||
const web = output.file.endsWith(".web.js");
|
||||
return {
|
||||
input: "./src/kokoro.js",
|
||||
output,
|
||||
plugins: plugins(web),
|
||||
...(web ? WEB_SPECIFIC_CONFIG : NODE_SPECIFIC_CONFIG),
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user