@tryhamster/gerbil 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -16
- package/dist/{architectures-wan0swXu.mjs → architectures-Ol7yUmKf.mjs} +128 -68
- package/dist/architectures-Ol7yUmKf.mjs.map +1 -0
- package/dist/cli.mjs +8 -8
- package/dist/cli.mjs.map +1 -1
- package/dist/{defaults-9komdrbY.mjs → defaults-bJcmOaRG.mjs} +2 -2
- package/dist/defaults-bJcmOaRG.mjs.map +1 -0
- package/dist/frameworks/express.mjs +1 -1
- package/dist/frameworks/fastify.mjs +1 -1
- package/dist/frameworks/hono.mjs +1 -1
- package/dist/frameworks/next.d.mts +2 -2
- package/dist/frameworks/next.mjs +1 -1
- package/dist/frameworks/trpc.mjs +1 -1
- package/dist/gerbil-BjGA5L2E.mjs +4 -0
- package/dist/{gerbil-DZbWbIm2.d.mts → gerbil-CCVOEU-J.d.mts} +2 -2
- package/dist/{gerbil-DZbWbIm2.d.mts.map → gerbil-CCVOEU-J.d.mts.map} +1 -1
- package/dist/{gerbil-CQspp8fS.mjs → gerbil-Cv7rXGOV.mjs} +2 -2
- package/dist/{gerbil-CQspp8fS.mjs.map → gerbil-Cv7rXGOV.mjs.map} +1 -1
- package/dist/gpu/hooks.d.mts +27 -10
- package/dist/gpu/hooks.d.mts.map +1 -1
- package/dist/gpu/hooks.mjs +19 -12
- package/dist/gpu/hooks.mjs.map +1 -1
- package/dist/gpu/index.d.mts +2 -2
- package/dist/gpu/index.mjs +5 -5
- package/dist/{gpu-BYCQ5aTI.mjs → gpu-BWLMlkVW.mjs} +78 -21
- package/dist/gpu-BWLMlkVW.mjs.map +1 -0
- package/dist/{index-CKszv3lt.d.mts → index-CSLqgNu-.d.mts} +212 -133
- package/dist/index-CSLqgNu-.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +6 -6
- package/dist/integrations/ai-sdk.mjs +1 -1
- package/dist/integrations/langchain.mjs +1 -1
- package/dist/integrations/llamaindex.mjs +1 -1
- package/dist/integrations/mcp.d.mts +2 -2
- package/dist/integrations/mcp.mjs +4 -4
- package/dist/{mcp-CszII8GJ.mjs → mcp-C0yKaH39.mjs} +3 -3
- package/dist/{mcp-CszII8GJ.mjs.map → mcp-C0yKaH39.mjs.map} +1 -1
- package/dist/{moonshine-stt-DDUm5WfP.mjs → moonshine-stt-C4GKK-h5.mjs} +45 -5
- package/dist/{moonshine-stt-DDUm5WfP.mjs.map → moonshine-stt-C4GKK-h5.mjs.map} +1 -1
- package/dist/moonshine-stt-zJ9YEi1X.mjs +4 -0
- package/dist/{one-liner-DVche8Eg.mjs → one-liner-DfJh2O0X.mjs} +2 -2
- package/dist/{one-liner-DVche8Eg.mjs.map → one-liner-DfJh2O0X.mjs.map} +1 -1
- package/dist/repl-DTSxHD6t.mjs +9 -0
- package/dist/skills/index.d.mts +2 -2
- package/dist/skills/index.d.mts.map +1 -1
- package/dist/skills/index.mjs +3 -3
- package/dist/{skills-BQI-VSn2.mjs → skills-B5cDRVJ1.mjs} +2 -2
- package/dist/{skills-BQI-VSn2.mjs.map → skills-B5cDRVJ1.mjs.map} +1 -1
- package/package.json +1 -2
- package/dist/architectures-wan0swXu.mjs.map +0 -1
- package/dist/defaults-9komdrbY.mjs.map +0 -1
- package/dist/gerbil-tHnYb9nZ.mjs +0 -4
- package/dist/gpu-BYCQ5aTI.mjs.map +0 -1
- package/dist/index-CKszv3lt.d.mts.map +0 -1
- package/dist/moonshine-stt-BtR-KiSP.mjs +0 -4
- package/dist/repl-BYJA2U7t.mjs +0 -9
- package/docs/PROJECT-STATE.md +0 -321
- package/docs/adding-a-model-family.md +0 -280
- package/docs/ai-sdk.md +0 -205
- package/docs/architecture/README.md +0 -84
- package/docs/architecture/caching.md +0 -227
- package/docs/architecture/inference.md +0 -176
- package/docs/architecture/overview.md +0 -189
- package/docs/architecture/streaming.md +0 -261
- package/docs/architecture/webgpu.md +0 -213
- package/docs/browser.md +0 -762
- package/docs/cli.md +0 -155
- package/docs/embeddings.md +0 -156
- package/docs/frameworks.md +0 -90
- package/docs/gerbil-site-native-migration.md +0 -217
- package/docs/gpu-engine/architectures.md +0 -398
- package/docs/gpu-engine/ir.md +0 -372
- package/docs/gpu-engine/kernels.md +0 -718
- package/docs/gpu-engine/paper.html +0 -1759
- package/docs/gpu-engine/paper.md +0 -2109
- package/docs/gpu-engine/safetensors.md +0 -312
- package/docs/gpu-engine/tokenizer.md +0 -302
- package/docs/kernel-research-queue.md +0 -85
- package/docs/mcp-client.md +0 -224
- package/docs/mcp.md +0 -109
- package/docs/memory-rag.md +0 -91
- package/docs/memory.md +0 -301
- package/docs/metal-safari-intel.md +0 -190
- package/docs/mobile-failure-diagnosis.md +0 -124
- package/docs/mobile.md +0 -99
- package/docs/observability.md +0 -230
- package/docs/onnx-removal-plan.md +0 -339
- package/docs/repl.md +0 -473
- package/docs/research/autoresearch-portable.md +0 -933
- package/docs/research/dispatch-reduction-hivemind.md +0 -84
- package/docs/research/ios-safari-model-caching.md +0 -117
- package/docs/research/mobile-webgpu-speed-fusion.md +0 -135
- package/docs/research/native-stt-model-selection.md +0 -49
- package/docs/research/native-tts-model-selection.md +0 -90
- package/docs/research/native-vs-chromium-decision.md +0 -152
- package/docs/research/nemotron-mamba2-inference.md +0 -910
- package/docs/research/qwen35-multimodal.md +0 -293
- package/docs/research/qwen36-gemma4-targets.md +0 -337
- package/docs/research/sota-embedding-models.md +0 -179
- package/docs/research/sota-mobile-models-2026.md +0 -263
- package/docs/research/sota-modality-models.md +0 -202
- package/docs/research/tps-baselines.md +0 -71
- package/docs/research/webgpu-m4-reference.md +0 -104
- package/docs/site-update-plan.md +0 -155
- package/docs/skills.md +0 -261
- package/docs/structured-output.md +0 -123
- package/docs/stt.md +0 -111
- package/docs/tools.md +0 -304
- package/docs/tts.md +0 -147
- package/docs/vision.md +0 -158
package/dist/gpu/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as resolveDefaultRepo, t as DEFAULT_MODELS } from "../defaults-
|
|
2
|
-
import {
|
|
3
|
-
import { C as generateGemma4VisionGraph, S as dequantizeMLXProjection, T as resolveGemma4VisionInfo, _ as smartResize, a as buildGemma4PosEmbeds, b as generateQwen3_5VisionGraph, c as buildMRoPECosSin, d as buildPositionIds, f as buildRotaryCosSin, g as preprocessImageGemma4, h as preprocessImage, i as buildGemma4PoolMatrix, l as buildMRoPEPositionIds, m as mropeFreqDims, n as GEMMA4_IMAGE_PROCESSOR, o as buildGemma4RotaryCosSin, p as buildVisionPositionTensors, r as QWEN3_5_IMAGE_PROCESSOR, s as buildGemma4VisionPositionTensors, t as WebGPUEngine, u as buildPosEmbeds, v as VisionExecutor, w as patchGemma4VisionClips, x as dequantizeGemma4VisionProjection, y as KaniTTS } from "../gpu-
|
|
4
|
-
import { a as loadMoonshine,
|
|
1
|
+
import { n as resolveDefaultRepo, t as DEFAULT_MODELS } from "../defaults-bJcmOaRG.mjs";
|
|
2
|
+
import { a as generateMoonshineEncoderGraph, h as generateNanoCodecDecoderGraph, i as generateMoonshineDecoderGraph, m as generateKaniTtsGraph, o as moonshineEncoderFrames, r as MOONSHINE_REMAINING_WORK, s as parseMoonshineConfig, u as audioTokensToCodes, x as parseKaniConfig } from "../architectures-Ol7yUmKf.mjs";
|
|
3
|
+
import { C as generateGemma4VisionGraph, S as dequantizeMLXProjection, T as resolveGemma4VisionInfo, _ as smartResize, a as buildGemma4PosEmbeds, b as generateQwen3_5VisionGraph, c as buildMRoPECosSin, d as buildPositionIds, f as buildRotaryCosSin, g as preprocessImageGemma4, h as preprocessImage, i as buildGemma4PoolMatrix, l as buildMRoPEPositionIds, m as mropeFreqDims, n as GEMMA4_IMAGE_PROCESSOR, o as buildGemma4RotaryCosSin, p as buildVisionPositionTensors, r as QWEN3_5_IMAGE_PROCESSOR, s as buildGemma4VisionPositionTensors, t as WebGPUEngine, u as buildPosEmbeds, v as VisionExecutor, w as patchGemma4VisionClips, x as dequantizeGemma4VisionProjection, y as KaniTTS } from "../gpu-BWLMlkVW.mjs";
|
|
4
|
+
import { _ as initGPU, a as loadMoonshine, c as Executor, i as loadModel, n as MoonshineEncoderExecutor, o as quantizeKaniBackbone, r as loadKaniTTS, t as MoonshineSTT } from "../moonshine-stt-C4GKK-h5.mjs";
|
|
5
5
|
|
|
6
|
-
export { DEFAULT_MODELS, Executor, GEMMA4_IMAGE_PROCESSOR, KaniTTS, MOONSHINE_REMAINING_WORK, MoonshineEncoderExecutor, MoonshineSTT, QWEN3_5_IMAGE_PROCESSOR, VisionExecutor, WebGPUEngine, audioTokensToCodes, buildGemma4PoolMatrix, buildGemma4PosEmbeds, buildGemma4RotaryCosSin, buildGemma4VisionPositionTensors, buildMRoPECosSin, buildMRoPEPositionIds, buildPosEmbeds, buildPositionIds, buildRotaryCosSin, buildVisionPositionTensors, dequantizeGemma4VisionProjection, dequantizeMLXProjection, generateGemma4VisionGraph, generateKaniTtsGraph, generateMoonshineDecoderGraph, generateMoonshineEncoderGraph, generateNanoCodecDecoderGraph, generateQwen3_5VisionGraph, initGPU, loadKaniTTS, loadModel, loadMoonshine, moonshineEncoderFrames, mropeFreqDims, parseKaniConfig, parseMoonshineConfig, patchGemma4VisionClips, preprocessImage, preprocessImageGemma4, resolveDefaultRepo, resolveGemma4VisionInfo, smartResize };
|
|
6
|
+
export { DEFAULT_MODELS, Executor, GEMMA4_IMAGE_PROCESSOR, KaniTTS, MOONSHINE_REMAINING_WORK, MoonshineEncoderExecutor, MoonshineSTT, QWEN3_5_IMAGE_PROCESSOR, VisionExecutor, WebGPUEngine, audioTokensToCodes, buildGemma4PoolMatrix, buildGemma4PosEmbeds, buildGemma4RotaryCosSin, buildGemma4VisionPositionTensors, buildMRoPECosSin, buildMRoPEPositionIds, buildPosEmbeds, buildPositionIds, buildRotaryCosSin, buildVisionPositionTensors, dequantizeGemma4VisionProjection, dequantizeMLXProjection, generateGemma4VisionGraph, generateKaniTtsGraph, generateMoonshineDecoderGraph, generateMoonshineEncoderGraph, generateNanoCodecDecoderGraph, generateQwen3_5VisionGraph, initGPU, loadKaniTTS, loadModel, loadMoonshine, moonshineEncoderFrames, mropeFreqDims, parseKaniConfig, parseMoonshineConfig, patchGemma4VisionClips, preprocessImage, preprocessImageGemma4, quantizeKaniBackbone, resolveDefaultRepo, resolveGemma4VisionInfo, smartResize };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as resolveDefaultRepo } from "./defaults-
|
|
2
|
-
import {
|
|
3
|
-
import { _ as
|
|
1
|
+
import { n as resolveDefaultRepo, t as DEFAULT_MODELS } from "./defaults-bJcmOaRG.mjs";
|
|
2
|
+
import { E as GEMMA4_VIS_KEYS, T as DTYPE_BYTES, _ as kaniCosTensor, c as KANI_END_OF_HUMAN, d as buildKaniLayerCosSin, f as computeKaniPositions, g as kaniAttentionLayerIndices, h as generateNanoCodecDecoderGraph, l as KANI_START_OF_HUMAN, m as generateKaniTtsGraph, u as audioTokensToCodes, v as kaniLayerAlpha, w as CANONICAL_KEYS, x as parseKaniConfig, y as kaniSinTensor } from "./architectures-Ol7yUmKf.mjs";
|
|
3
|
+
import { _ as initGPU, c as Executor, d as clearPipelineCache, f as createBindGroup, g as getOrCreatePipeline, h as destroyBuffers, i as loadModel, l as KERNEL_REGISTRY, m as createUniformBuffer, o as quantizeKaniBackbone, p as createStorageBuffer, r as loadKaniTTS, s as remapPrunedToken, u as MATMUL_BIAS_F16C_SPEC, v as verifyGPU } from "./moonshine-stt-C4GKK-h5.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/gpu/architectures/gemma4_vision.ts
|
|
6
6
|
/**
|
|
@@ -802,6 +802,19 @@ function nucleusSample(probs, ids, topP) {
|
|
|
802
802
|
}
|
|
803
803
|
return ids[order[0]];
|
|
804
804
|
}
|
|
805
|
+
/**
|
|
806
|
+
* In-place top-k filter over a probability array: keep only the `k` highest, zero
|
|
807
|
+
* the rest, and renormalize. No-op when k <= 0 or k >= length (keep everything).
|
|
808
|
+
*/
|
|
809
|
+
function applyTopK(scores, k) {
|
|
810
|
+
const n = scores.length;
|
|
811
|
+
if (k <= 0 || k >= n) return;
|
|
812
|
+
const order = Array.from({ length: n }, (_, i) => i).sort((a, b) => scores[b] - scores[a]);
|
|
813
|
+
let keepSum = 0;
|
|
814
|
+
for (let r = 0; r < k; r++) keepSum += scores[order[r]];
|
|
815
|
+
for (let r = k; r < n; r++) scores[order[r]] = 0;
|
|
816
|
+
if (keepSum > 0) for (let i = 0; i < n; i++) scores[i] /= keepSum;
|
|
817
|
+
}
|
|
805
818
|
/** In-place softmax of `scores`. */
|
|
806
819
|
function softmaxInPlace(scores) {
|
|
807
820
|
let maxV = Number.NEGATIVE_INFINITY;
|
|
@@ -829,14 +842,23 @@ var KaniTTS = class KaniTTS {
|
|
|
829
842
|
headDim;
|
|
830
843
|
ropeBase;
|
|
831
844
|
_destroyed = false;
|
|
832
|
-
|
|
833
|
-
|
|
845
|
+
/** Accent/voice tags the loaded checkpoint advertises (empty = single voice). */
|
|
846
|
+
voiceTags;
|
|
847
|
+
/** The loaded checkpoint's architecture string ("KaniTTS2ForCausalLM" or "Lfm2ForCausalLM"). */
|
|
848
|
+
architecture;
|
|
849
|
+
/** The selected backbone precision ("q4" or "f32"). */
|
|
850
|
+
dtype;
|
|
851
|
+
constructor(ctx, loaded, maxSeqLen, dtype) {
|
|
834
852
|
this.ctx = ctx;
|
|
835
853
|
this.loaded = loaded;
|
|
836
854
|
this.tokenizer = loaded.tokenizer;
|
|
837
855
|
this.rawConfig = loaded.rawConfig;
|
|
838
856
|
this.cfg = parseKaniConfig(loaded.rawConfig);
|
|
839
857
|
this.maxSeqLen = maxSeqLen;
|
|
858
|
+
this.dtype = dtype;
|
|
859
|
+
this.architecture = (loaded.rawConfig.architectures ?? [])[0] ?? "Lfm2ForCausalLM";
|
|
860
|
+
const langSettings = loaded.rawConfig.language_settings;
|
|
861
|
+
this.voiceTags = Array.isArray(langSettings?.language_tags_list) ? langSettings.language_tags_list.filter((v) => typeof v === "string") : [];
|
|
840
862
|
const hidden = this.rawConfig.hidden_size;
|
|
841
863
|
const heads = this.rawConfig.num_attention_heads;
|
|
842
864
|
this.headDim = this.rawConfig.head_dim ?? Math.floor(hidden / heads);
|
|
@@ -852,7 +874,8 @@ var KaniTTS = class KaniTTS {
|
|
|
852
874
|
}
|
|
853
875
|
this.layerAlpha.set(layer, alpha);
|
|
854
876
|
}
|
|
855
|
-
const graph = generateKaniTtsGraph(this.rawConfig);
|
|
877
|
+
const graph = generateKaniTtsGraph(this.rawConfig, dtype === "q4" ? "q4" : void 0);
|
|
878
|
+
if (dtype === "q4") quantizeKaniBackbone(graph, loaded.backboneWeights);
|
|
856
879
|
this.backboneExec = new Executor(ctx, graph, {
|
|
857
880
|
maxSeqLen,
|
|
858
881
|
kvMode: "f32"
|
|
@@ -871,7 +894,7 @@ var KaniTTS = class KaniTTS {
|
|
|
871
894
|
onProgress: options.onProgress
|
|
872
895
|
});
|
|
873
896
|
const ctxLen = loaded.rawConfig.max_position_embeddings ?? 4096;
|
|
874
|
-
return new KaniTTS(ctx, loaded, Math.min(options.maxSeqLen ?? 2048, ctxLen));
|
|
897
|
+
return new KaniTTS(ctx, loaded, Math.min(options.maxSeqLen ?? 2048, ctxLen), options.dtype ?? "q4");
|
|
875
898
|
}
|
|
876
899
|
/** Write per-layer cos/sin for token rows [rowStart, rowStart+positions.length). */
|
|
877
900
|
writeCosSin(positions, rowStart) {
|
|
@@ -889,6 +912,20 @@ var KaniTTS = class KaniTTS {
|
|
|
889
912
|
}
|
|
890
913
|
}
|
|
891
914
|
/**
|
|
915
|
+
* Accent/voice tags the loaded checkpoint supports. Multi-accent KaniTTS2
|
|
916
|
+
* checkpoints (kani-tts-2-en) return e.g. ["en_us","en_nyork","en_glasg", …];
|
|
917
|
+
* the plain LFM2 family (the Apache default) returns [] (one trained voice,
|
|
918
|
+
* selectable only by fine-tuning the backbone — there is no runtime voice/
|
|
919
|
+
* speaker-prompt knob, and zero-shot cloning is not wired).
|
|
920
|
+
*/
|
|
921
|
+
availableVoices() {
|
|
922
|
+
return [...this.voiceTags];
|
|
923
|
+
}
|
|
924
|
+
/** NanoCodec's fixed output sample rate (Hz). Not selectable — see SpeakResult. */
|
|
925
|
+
get sampleRate() {
|
|
926
|
+
return KANI_SAMPLE_RATE;
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
892
929
|
* Synthesize speech for `text`. Returns 22 kHz mono PCM.
|
|
893
930
|
*
|
|
894
931
|
* Pipeline: build the [SOH]+text+[EOT,EOH] prompt → prefill the codec-LM →
|
|
@@ -899,12 +936,13 @@ var KaniTTS = class KaniTTS {
|
|
|
899
936
|
if (this._destroyed) throw new Error("KaniTTS has been destroyed.");
|
|
900
937
|
const temperature = opts.temperature ?? 1;
|
|
901
938
|
const topP = opts.topP ?? .95;
|
|
939
|
+
const topK = opts.topK ?? 0;
|
|
902
940
|
const repetitionPenalty = opts.repetitionPenalty ?? 1.1;
|
|
903
|
-
const tag = opts.languageTag ?? "en_us";
|
|
904
941
|
const maxNewTokens = Math.min(opts.maxNewTokens ?? DEFAULT_MAX_NEW_TOKENS, this.maxSeqLen);
|
|
942
|
+
const promptText = this.voiceTags.length > 0 ? `${(opts.languageTag ?? this.voiceTags[0]).trim()}: ${text}` : text;
|
|
905
943
|
const prompt = [
|
|
906
944
|
KANI_START_OF_HUMAN,
|
|
907
|
-
...this.tokenizer.encode(
|
|
945
|
+
...this.tokenizer.encode(promptText),
|
|
908
946
|
KANI_END_OF_TEXT,
|
|
909
947
|
KANI_END_OF_HUMAN
|
|
910
948
|
];
|
|
@@ -917,6 +955,7 @@ var KaniTTS = class KaniTTS {
|
|
|
917
955
|
const { audioTokens, finished } = await this.runDecodeLoop(prompt, logits, {
|
|
918
956
|
temperature,
|
|
919
957
|
topP,
|
|
958
|
+
topK,
|
|
920
959
|
repetitionPenalty,
|
|
921
960
|
maxNewTokens,
|
|
922
961
|
maxFrames: opts.maxFrames ?? Number.POSITIVE_INFINITY
|
|
@@ -953,6 +992,7 @@ var KaniTTS = class KaniTTS {
|
|
|
953
992
|
const nextToken = inSpeech ? this.sampleAudioToken(logits, audioTokens.length % this.cfg.tokensPerFrame, {
|
|
954
993
|
temperature: p.temperature,
|
|
955
994
|
topP: p.topP,
|
|
995
|
+
topK: p.topK,
|
|
956
996
|
repetitionPenalty: p.repetitionPenalty,
|
|
957
997
|
previous: seq
|
|
958
998
|
}) : this.argmax(logits);
|
|
@@ -994,7 +1034,8 @@ var KaniTTS = class KaniTTS {
|
|
|
994
1034
|
/**
|
|
995
1035
|
* Sample one audio token for codebook position `codebook`, constrained to that
|
|
996
1036
|
* codebook's valid window [audio_tokens_start + 4032*c, +4032). Allows end_of_speech
|
|
997
|
-
* only at codebook 0 (frame boundary). Applies
|
|
1037
|
+
* only at codebook 0 (frame boundary). Applies repetition penalty, temperature,
|
|
1038
|
+
* optional top-k, then top-p nucleus sampling.
|
|
998
1039
|
*/
|
|
999
1040
|
sampleAudioToken(logits, codebook, p) {
|
|
1000
1041
|
const winStart = this.cfg.audioTokensStart + this.cfg.codebookSize * codebook;
|
|
@@ -1012,6 +1053,7 @@ var KaniTTS = class KaniTTS {
|
|
|
1012
1053
|
scores[i] = s / p.temperature;
|
|
1013
1054
|
}
|
|
1014
1055
|
softmaxInPlace(scores);
|
|
1056
|
+
applyTopK(scores, p.topK);
|
|
1015
1057
|
return nucleusSample(scores, ids, p.topP);
|
|
1016
1058
|
}
|
|
1017
1059
|
/**
|
|
@@ -3069,29 +3111,44 @@ var WebGPUEngine = class WebGPUEngine {
|
|
|
3069
3111
|
throw new Error(`generateObject failed after ${attemptsMax} attempt(s): ${lastError}. Last output: ${JSON.stringify(lastText.slice(0, 200))}`);
|
|
3070
3112
|
}
|
|
3071
3113
|
/**
|
|
3072
|
-
* Text-to-speech: text → 22 kHz PCM via
|
|
3114
|
+
* Text-to-speech: text → 22 kHz PCM via KaniTTS (LFM2-350M codec-LM + NVIDIA
|
|
3073
3115
|
* NeMo NanoCodec). Returns `{ pcm: Float32Array, sampleRate: 22050 }`.
|
|
3074
3116
|
*
|
|
3075
3117
|
* Runs the full pipeline: the codec-LM backbone autoregressively emits NanoCodec
|
|
3076
|
-
* audio tokens (4 per frame,
|
|
3077
|
-
*
|
|
3078
|
-
*
|
|
3079
|
-
*
|
|
3080
|
-
* checkpoint alongside the backbone).
|
|
3118
|
+
* audio tokens (4 per frame), then the bit-exact NanoCodec decoder (FSQ + causal
|
|
3119
|
+
* HiFi-GAN) turns the codes into PCM. The heavy lifting lives in {@link KaniTTS}
|
|
3120
|
+
* (src/gpu/kani-tts.ts); this lazily constructs that engine on first use
|
|
3121
|
+
* (downloading the NanoCodec codec checkpoint alongside the backbone).
|
|
3081
3122
|
*
|
|
3082
|
-
*
|
|
3123
|
+
* The default checkpoint is the Apache-2.0 `nineninesix/kani-tts-450m-0.2-ft`
|
|
3124
|
+
* (plain `Lfm2ForCausalLM` backbone); the earlier `KaniTTS2ForCausalLM`
|
|
3125
|
+
* checkpoints (multi-accent) also work. The codec-LM backbone defaults to INT4
|
|
3126
|
+
* (`dtype: "q4"`) — pass `dtype: "f32"` for full precision.
|
|
3083
3127
|
*/
|
|
3084
3128
|
async speak(text, options = {}) {
|
|
3085
3129
|
this.checkDestroyed();
|
|
3086
|
-
|
|
3130
|
+
const repo = this._createOptions.repo ?? "";
|
|
3131
|
+
if (!(this._architecture === "KaniTTS2ForCausalLM" || /kani-tts/i.test(repo) || /\btts\b/i.test(repo))) throw new Error(`speak() requires a Kani-TTS checkpoint (e.g. "${DEFAULT_MODELS.tts}"), loaded engine is "${this._architecture}" (repo "${repo}").`);
|
|
3087
3132
|
if (!this._kaniTTS) this._kaniTTS = await KaniTTS.create({
|
|
3088
3133
|
repo: this._createOptions.repo,
|
|
3089
3134
|
revision: this._createOptions.revision,
|
|
3090
3135
|
hfToken: this._createOptions.hfToken,
|
|
3091
3136
|
cacheDir: this._createOptions.cacheDir,
|
|
3092
|
-
maxSeqLen: this.maxSeqLen
|
|
3137
|
+
maxSeqLen: this.maxSeqLen,
|
|
3138
|
+
dtype: options.dtype
|
|
3093
3139
|
});
|
|
3094
|
-
return this._kaniTTS.speak(text,
|
|
3140
|
+
return this._kaniTTS.speak(text, {
|
|
3141
|
+
languageTag: options.voice ?? options.languageTag,
|
|
3142
|
+
temperature: options.temperature,
|
|
3143
|
+
topP: options.topP,
|
|
3144
|
+
topK: options.topK,
|
|
3145
|
+
repetitionPenalty: options.repetitionPenalty,
|
|
3146
|
+
maxFrames: options.maxFrames
|
|
3147
|
+
});
|
|
3148
|
+
}
|
|
3149
|
+
/** Accent/voice tags the lazily-built TTS engine supports ([] = single voice). */
|
|
3150
|
+
ttsVoices() {
|
|
3151
|
+
return this._kaniTTS?.availableVoices() ?? [];
|
|
3095
3152
|
}
|
|
3096
3153
|
/**
|
|
3097
3154
|
* Describe an image: image-in → text-out. Runs the vision encoder, splices the
|
|
@@ -3799,4 +3856,4 @@ var WebGPUEngine = class WebGPUEngine {
|
|
|
3799
3856
|
|
|
3800
3857
|
//#endregion
|
|
3801
3858
|
export { generateGemma4VisionGraph as C, dequantizeMLXProjection as S, resolveGemma4VisionInfo as T, smartResize as _, buildGemma4PosEmbeds as a, generateQwen3_5VisionGraph as b, buildMRoPECosSin as c, buildPositionIds as d, buildRotaryCosSin as f, preprocessImageGemma4 as g, preprocessImage as h, buildGemma4PoolMatrix as i, buildMRoPEPositionIds as l, mropeFreqDims as m, GEMMA4_IMAGE_PROCESSOR as n, buildGemma4RotaryCosSin as o, buildVisionPositionTensors as p, QWEN3_5_IMAGE_PROCESSOR as r, buildGemma4VisionPositionTensors as s, WebGPUEngine as t, buildPosEmbeds as u, VisionExecutor as v, patchGemma4VisionClips as w, dequantizeGemma4VisionProjection as x, KaniTTS as y };
|
|
3802
|
-
//# sourceMappingURL=gpu-
|
|
3859
|
+
//# sourceMappingURL=gpu-BWLMlkVW.mjs.map
|