ONNX conversion of thorhojhus/whisper-small-danish for
Transformers.js, laid out like the
onnx-community Whisper repos (onnx/encoder_model*.onnx + KV-cached
onnx/decoder_model_merged*.onnx, dtypes fp32, fp16, q8 (_quantized), q4).
All credit for the model goes to its original authors: the thorhojhus Hugging Face account — thorhojhus/whisper-small-danish, a Danish fine-tune of openai/whisper-small. This repository only re-packages those weights in another format; it adds no training. The licence (MIT) is carried over unchanged from the original repository; see its model card for training data, evaluation and limitations.
Danish speech-to-text in the browser, made for whisper_web (browser Whisper app: Transformers.js in the browser, optional faster-whisper server engine): the app picks this repo from its model
catalog and loads it with Transformers.js on WASM (q8/q4) or WebGPU (fp16 encoder + q4
decoder). It also works with any Transformers.js automatic-speech-recognition pipeline:
import { pipeline } from "@huggingface/transformers";
const asr = await pipeline("automatic-speech-recognition", "lucasw89/whisper-small-danish-ONNX", { dtype: "q8" });
const { text } = await asr(audio16kMono, { language: "da", task: "transcribe", chunk_length_s: 30 });
Word error rate on one 21.5 s Danish news-style clip (da_festuge from whisper_web's test set;
lower-cased, punctuation stripped), Transformers.js 4.2.0 on onnxruntime-node (CPU), greedy decoding,
language: "da", 30 s chunks. A single short clip: a sanity check of the conversion, not a benchmark.
Stock column: onnx-community/whisper-small at the same dtype.
| dtype | this conversion | stock Whisper of the same size |
|---|---|---|
| q8 | 0.109 | 0.297 |
| q4 | 0.094 | 0.281 |
| fp16+q4 | 0.094 | — |
| fp16 | 0.094 | — |
# venv: optimum 2.1.0 + optimum-onnx 0.1.0, transformers 4.57.6, torch 2.15.0+cpu, onnx 1.23.2, onnxruntime 1.31.1,
# accelerate 1.15.0 (needed for optimum's tied-weight deduplication: embed_tokens / proj_out stored once)
optimum.exporters.onnx.main_export(<source>, task="automatic-speech-recognition-with-past", dtype="fp32",
do_validation=False)
# -> onnx/encoder_model.onnx, onnx/decoder_model_merged.onnx (KV cache, merged with/without past)
# variants (settings of the stock onnx-community Whisper repos):
# *_fp16.onnx onnxruntime.transformers.float16.convert_float_to_float16(keep_io_types=True), after giving
# the merged decoder's If-branch outputs branch-local names (otherwise the converter
# wires each branch to the outer fp32 Cast and onnxruntime rejects the cyclic graph)
# *_quantized.onnx onnxruntime.quantization.quantize_dynamic(per_channel=False, reduce_range=False,
# weight_type=QUInt8 encoder / QInt8 decoder, EnableSubgraph=True) (Transformers.js "q8")
# *_q4.onnx MatMulNBitsQuantizer(block_size=32, is_symmetric=True) (Transformers.js "q4")
generation_config.json, tokenizer files and <|da|> / task tokens are copied unchanged from the
source repository.
onnx/decoder_model_merged.onnx 615 MBonnx/encoder_model.onnx 353 MBonnx/decoder_model_merged_fp16.onnx 308 MBonnx/decoder_model_merged_q4.onnx 233 MBonnx/encoder_model_fp16.onnx 176 MBonnx/decoder_model_merged_quantized.onnx 155 MBonnx/encoder_model_quantized.onnx 92 MBonnx/encoder_model_q4.onnx 66 MBthorhojhus/whisper-small-danish