mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-17 09:51:35 +00:00
fix: Kokoro.js falls back to WASM when the browser has WebGPU but no GPU adapter (#33233)
This commit is contained in:
parent
7a76e9fed6
commit
bafe181330
2 changed files with 4 additions and 2 deletions
|
|
@ -133,9 +133,10 @@
|
|||
const model_id = 'onnx-community/Kokoro-82M-v1.0-ONNX';
|
||||
|
||||
const { KokoroTTS } = await import('kokoro-js');
|
||||
const adapter = await navigator?.gpu?.requestAdapter().catch(() => null);
|
||||
TTSModel = await KokoroTTS.from_pretrained(model_id, {
|
||||
dtype: TTSEngineConfig.dtype, // Options: "fp32", "fp16", "q8", "q4", "q4f16"
|
||||
device: !!navigator?.gpu ? 'webgpu' : 'wasm', // Detect WebGPU
|
||||
device: adapter ? 'webgpu' : 'wasm', // Detect WebGPU
|
||||
progress_callback: (e) => {
|
||||
TTSModelProgress = e;
|
||||
console.log(e);
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@ self.onmessage = async (event) => {
|
|||
self.postMessage({ status: 'init:start' });
|
||||
|
||||
try {
|
||||
const adapter = await navigator?.gpu?.requestAdapter().catch(() => null);
|
||||
tts = await KokoroTTS.from_pretrained(model_id, {
|
||||
dtype,
|
||||
device: !!navigator?.gpu ? 'webgpu' : 'wasm' // Detect WebGPU
|
||||
device: adapter ? 'webgpu' : 'wasm' // Detect WebGPU
|
||||
});
|
||||
isInitialized = true; // Mark as initialized after successful loading
|
||||
self.postMessage({ status: 'init:complete' });
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue