feat: dynamic loading of kokorojs

This commit is contained in:
Shirasawa 2025-08-18 23:43:54 +08:00
parent 094a82b264
commit dc9445c4ec

View file

@ -1,7 +1,6 @@
<script lang="ts">
import { toast } from 'svelte-sonner';
import { createEventDispatcher, onMount, getContext } from 'svelte';
import { KokoroTTS } from 'kokoro-js';
import { user, settings, config } from '$lib/stores';
import { getVoices as _getVoices } from '$lib/apis/audio';
@ -128,6 +127,7 @@
const model_id = 'onnx-community/Kokoro-82M-v1.0-ONNX';
const { KokoroTTS } = await import('kokoro-js');
TTSModel = await KokoroTTS.from_pretrained(model_id, {
dtype: TTSEngineConfig.dtype, // Options: "fp32", "fp16", "q8", "q4", "q4f16"
device: !!navigator?.gpu ? 'webgpu' : 'wasm', // Detect WebGPU