Views
No views yet
| Quantization | Encoder | Decoder | Total Size | Use Case |
|---|---|---|---|---|
| q4f16 | 51 MB | 138 MB | ~191 MB | Recommended for browsers - Best balance |
| fp16 | 168 MB | 293 MB | ~463 MB | Higher quality, larger size |
| int8/q8 | 87 MB | 299 MB | ~386 MB | Good quality, moderate size |
| fp32 | 337 MB | 587 MB | ~924 MB | Full precision (reference) |
1import { pipeline } from '@xenova/transformers';
2
3// Create ASR pipeline
4const transcriber = await pipeline(
5 'automatic-speech-recognition',
6 'cmaree/Bagus-whisper-small-id-onnx',
7 {
8 dtype: 'q4f16', // Recommended for browser
9 device: 'wasm', // or 'webgpu' if available
10 }
11);
12
13// Transcribe audio
14const result = await transcriber(audioData, {
15 language: 'indonesian',
16 task: 'transcribe',
17});
18
19console.log(result.text);1import {
2 AutoProcessor,
3 AutoModelForSpeechSeq2Seq,
4 AutoTokenizer
5} from '@xenova/transformers';
6
7class IndonesianWhisper {
8 constructor() {
9 this.model = null;
10 this.processor = null;
11 this.tokenizer = null;
12 }
13
14 async load(options = {}) {
15 const modelId = 'cmaree/Bagus-whisper-small-id-onnx';
16 const device = options.device || 'wasm';
17
18 this.processor = await AutoProcessor.from_pretrained(modelId);
19 this.tokenizer = await AutoTokenizer.from_pretrained(modelId);
20 this.model = await AutoModelForSpeechSeq2Seq.from_pretrained(modelId, {
21 device: device,
22 dtype: device === 'webgpu' ? 'fp32' : 'q4f16'
23 });
24 }
25
26 async transcribe(audioData, options = {}) {
27 const processed = await this.processor(audioData, {
28 sampling_rate: options.sampling_rate || 16000
29 });
30
31 const outputs = await this.model.generate(processed.input_features, {
32 max_new_tokens: 128,
33 num_beams: 1,
34 language: 'indonesian',
35 task: 'transcribe',
36 return_timestamps: false,
37 });
38
39 const transcription = this.tokenizer.batch_decode(outputs, {
40 skip_special_tokens: true
41 });
42
43 return { text: transcription[0] };
44 }
45}
46
47// Usage
48const whisper = new IndonesianWhisper();
49await whisper.load({ device: 'wasm' });
50const result = await whisper.transcribe(audioBuffer);
51console.log(result.text);| Device | Browser | Speed (RTF) | Notes |
|---|---|---|---|
| Desktop (i7) | Chrome | ~0.3x | 3-4 seconds for 10s audio |
| Laptop (M1) | Safari | ~0.2x | 2-3 seconds for 10s audio |
| Mobile (Flagship) | Chrome | ~0.5x | 5-6 seconds for 10s audio |
1@misc{bagus2024whisper,
2 author = {Bagus},
3 title = {Whisper Small Indonesian CV17},
4 year = {2024},
5 publisher = {HuggingFace},
6 url = {https://huggingface.co/Bagus/whisper-small-id-cv17}
7}1@misc{radford2022whisper,
2 title={Robust Speech Recognition via Large-Scale Weak Supervision},
3 author={Alec Radford and Jong Wook Kim and Tao Xu and Greg Brockman and Christine McLeavey and Ilya Sutskever},
4 year={2022},
5 eprint={2212.04356},
6 archivePrefix={arXiv},
7 primaryClass={eess.AS}
8}1@software{transformersjs,
2 author = {Xenova},
3 title = {Transformers.js: State-of-the-art Machine Learning for the web},
4 year = {2024},
5 url = {https://github.com/xenova/transformers.js}
6}