ONNX conversion of NbAiLab/nb-whisper-medium with multiple precision variants.
| Variant | Description | Files |
|---|---|---|
| fp32 | Full precision (float32) | encoder_model.onnx, decoder_model.onnx, decoder_with_past_model.onnx, decoder_model_merged.onnx |
| fp16 | Half precision (float16) | *_fp16.onnx |
| int8 | 8-bit integer (signed) | *_int8.onnx |
| uint8 | 8-bit integer (unsigned) | *_uint8.onnx |
| quantized | Dynamic quantization (avx512_vnni) | *_quantized.onnx |
| q4 | 4-bit weight quantization | *_q4.onnx |
| q4f16 | 4-bit weights + fp16 scales | *_q4f16.onnx |
| bnb4 | BitsAndBytes NF4 quantization | *_bnb4.onnx |
from optimum.onnxruntime import ORTModelForSpeechSeq2Seq
from transformers import AutoProcessor
import librosa
model_id = "path/to/nb-whisper-medium"
processor = AutoProcessor.from_pretrained(model_id)
model = ORTModelForSpeechSeq2Seq.from_pretrained(model_id, subfolder="onnx")
audio, sr = librosa.load("audio.wav", sr=16000, mono=True)
inputs = processor.feature_extractor(audio, sampling_rate=16000, return_tensors="pt")
gen_tokens = model.generate(**inputs, max_length=300)
print(processor.decode(gen_tokens[0], skip_special_tokens=True))
In a browser environment with AudioContext available:
import { pipeline } from "@huggingface/transformers";
const transcriber = await pipeline(
"automatic-speech-recognition",
"path/to/nb-whisper-medium",
);
const result = await transcriber("audio.wav");
console.log(result.text);
In Node.js (AudioContext is not available, so audio must be loaded manually):
import { pipeline } from "@huggingface/transformers";
import fs from "fs";
import wavefile from "wavefile";
// Load and resample audio to 16kHz mono
const buffer = fs.readFileSync("audio.wav");
const wav = new wavefile.WaveFile(buffer);
wav.toBitDepth("32f");
wav.toSampleRate(16000);
const audioData = wav.getSamples(false, Float32Array);
// Mix to mono if stereo
const audio = Array.isArray(audioData)
? audioData[0].map((v, i) => (v + audioData[1][i]) / 2)
: audioData;
const transcriber = await pipeline(
"automatic-speech-recognition",
"path/to/nb-whisper-medium",
);
const result = await transcriber(audio);
console.log(result.text);
This is an ONNX conversion of NbAiLab/nb-whisper-medium. See the original model card for training details, performance metrics, and dataset information.
onnx/decoder_model_merged.onnx 2.0 GBonnx/decoder_model.onnx 2.0 GBonnx/decoder_with_past_model.onnx 1.8 GBonnx/encoder_model.onnx 1.2 GBonnx/decoder_model_merged_fp16.onnx 1.0 GBonnx/decoder_model_fp16.onnx 1.0 GBonnx/decoder_with_past_model_fp16.onnx 919 MBonnx/decoder_model_merged_uint8.onnx 674 MBonnx/decoder_model_merged_int8.onnx 674 MBonnx/decoder_model_uint8.onnx 673 MBonnx/decoder_model_int8.onnx 673 MBonnx/decoder_with_past_model_uint8.onnx 623 MBonnx/decoder_with_past_model_int8.onnx 623 MBonnx/encoder_model_fp16.onnx 615 MBonnx/decoder_model_merged_quantized.onnx 514 MBonnx/decoder_model_quantized.onnx 512 MBonnx/decoder_model_merged_q4.onnx 502 MBonnx/decoder_model_q4.onnx 502 MBonnx/decoder_model_merged_bnb4.onnx 474 MBonnx/decoder_model_bnb4.onnx 473 MBonnx/decoder_with_past_model_q4.onnx 470 MBonnx/decoder_with_past_model_quantized.onnx 462 MBonnx/decoder_with_past_model_bnb4.onnx 445 MBonnx/decoder_model_merged_q4f16.onnx 366 MBonnx/decoder_model_q4f16.onnx 365 MBonnx/decoder_with_past_model_q4f16.onnx 337 MBonnx/encoder_model_uint8.onnx 323 MBonnx/encoder_model_int8.onnx 323 MBonnx/encoder_model_quantized.onnx 313 MBonnx/encoder_model_q4.onnx 210 MBonnx/encoder_model_bnb4.onnx 191 MBonnx/encoder_model_q4f16.onnx 181 MB有文件?提交种子。
提交种子