whispermix 1.6.2 β†’ 1.6.4

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/index.js CHANGED
@@ -49,6 +49,7 @@ const PARAKEET_LAYOUTS = {
49
49
  },
50
50
  },
51
51
  };
52
+ const PARAKEET_DEFAULT_CHUNK_SIZE = 40;
52
53
 
53
54
  class WhisperMix {
54
55
  constructor(setup = {}) {
@@ -118,6 +119,9 @@ class WhisperMix {
118
119
  this.showProgress = this.showProgress || false;
119
120
  this.localBackend = this.config.backend || 'transformers';
120
121
  this.layout = this.config.layout;
122
+ if (setup.chunkSize === undefined && this.localBackend === 'onnx-asr-web') {
123
+ this.chunkSize = PARAKEET_DEFAULT_CHUNK_SIZE;
124
+ }
121
125
  this.transcriber = null;
122
126
  this._onnxAsrNodeModule = null;
123
127
  this._warnedParakeetLanguage = false;
@@ -285,7 +289,7 @@ class WhisperMix {
285
289
  this._warnedParakeetLanguage = true;
286
290
  }
287
291
  const result = await transcriber.transcribeSamples(audioData, 16000);
288
- const text = result?.text || result?.utterance_text;
292
+ const text = result?.text ?? result?.utterance_text;
289
293
  if (typeof text !== 'string') {
290
294
  throw new Error('Parakeet transcription returned no text output.');
291
295
  }
@@ -309,7 +313,10 @@ class WhisperMix {
309
313
  const cacheHint = this.localBackend === 'onnx-asr-web'
310
314
  ? this._getParakeetCacheDir(this.layout)
311
315
  : `${env.cacheDir}${this.modelName}/`;
312
- throw new Error(`Local transcription failed: ${error.message}. If this happened after an interrupted download, remove the model cache at ${cacheHint} and try again.`);
316
+ const chunkHint = this.localBackend === 'onnx-asr-web' && /bad_alloc/i.test(error.message)
317
+ ? ` Parakeet local models should use short chunks; try chunkSize: ${PARAKEET_DEFAULT_CHUNK_SIZE} or less.`
318
+ : '';
319
+ throw new Error(`Local transcription failed: ${error.message}.${chunkHint} If this happened after an interrupted download, remove the model cache at ${cacheHint} and try again.`);
313
320
  }
314
321
  }
315
322
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "whispermix",
3
3
  "description": "πŸŽ™οΈ WhisperMix is a versatile module for transcribing audio using OpenAI’s Whisper or Groq’s Whisper v3 model.",
4
- "version": "1.6.2",
4
+ "version": "1.6.4",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "whisper",
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: whispermix
3
+ description: "Transcribe audio to text with WhisperMix in Node.js (OpenAI, Groq, Whisper local or Parakeet local)."
4
+ ---
5
+
6
+ # WhisperMix
7
+
8
+ WhisperMix transcribes audio to text with one API and multiple backends.
9
+
10
+ Use this skill when the user wants speech-to-text from an audio file (`.mp3`, `.wav`, `.m4a`, `.ogg`, `.flac`, `.webm`) in a Node.js project.
11
+
12
+ Do not use for TTS, translation, or live microphone streaming.
13
+
14
+ ## Choose a model (quick)
15
+
16
+ - **Cloud, best quality/speed:** `groq/whisper-large-v3` or `openai/whisper-1`
17
+ - **Local, fastest startup:** `efederici/parakeet-tdt-0.6b-v3-int4`
18
+ - **Local, better language control:** `xenova/whisper-large-v3`
19
+
20
+ Important limits:
21
+ - Local models are file-only (`fromFile`), no `fromStream`.
22
+ - API models need `OPENAI_API_KEY` or `GROQ_API_KEY`.
23
+ - `ffmpeg` is required for long files.
24
+
25
+ ## Basic usage
26
+
27
+ Install:
28
+
29
+ ```bash
30
+ npm install whispermix
31
+ ```
32
+
33
+ File transcription:
34
+
35
+ ```javascript
36
+ import WhisperMix from 'whispermix';
37
+
38
+ const w = new WhisperMix({ model: 'groq/whisper-large-v3' });
39
+ const text = await w.fromFile('audio.mp3');
40
+ console.log(text);
41
+ ```
42
+
43
+ Word timestamps:
44
+
45
+ ```javascript
46
+ import WhisperMix from 'whispermix';
47
+
48
+ const w = new WhisperMix({ model: 'openai/whisper-1' });
49
+ const result = await w.fromFile('audio.mp3', { wordTimestamps: true });
50
+ console.log(result.text);
51
+ console.log(result.words);
52
+ ```
53
+
54
+ ## Troubleshooting
55
+
56
+ - `OPENAI_API_KEY` / `GROQ_API_KEY is not set`: set env var or use a local model.
57
+ - `fromStream not supported`: use `fromFile` with local models.
58
+ - `Cannot find ffmpeg`: install `ffmpeg` and retry.
package/SKILL.md DELETED
@@ -1,100 +0,0 @@
1
- ---
2
- name: whispermix
3
- description: Transcribe audio to text using WhisperMix, a Node.js wrapper around OpenAI Whisper, Groq Whisper Large v3, local Whisper (xenova) and local Parakeet TDT v3 models. Use when the user asks to "transcribe audio", "speech to text", "convert audio/voice to text", mentions an audio file (.mp3, .wav, .m4a, .ogg, .flac, .webm) to turn into text, or names any of these models/providers: Whisper, OpenAI Whisper, Groq Whisper, Whisper Large v3, Parakeet, NVIDIA Parakeet, xenova/whisper, onnx-asr. Also use when the user wants to pick between a cloud API and a local on-device transcription model in a Node.js project.
4
- ---
5
-
6
- # WhisperMix
7
-
8
- Single Node.js entry point for audio transcription. Picks one of four backends behind the same API: OpenAI Whisper, Groq Whisper Large v3, local Whisper (xenova), or local Parakeet TDT v3. Handles long files by chunking and rate-limits API calls automatically.
9
-
10
- Do NOT use for TTS, live microphone streaming, or translation. WhisperMix is one-way: a complete audio file/stream β†’ text.
11
-
12
- ## Model selection (decide first)
13
-
14
- | Need | Pick |
15
- |---|---|
16
- | Offline, lowest latency | `istupakov/parakeet-tdt-0.6b-v3` |
17
- | Offline, smallest footprint (~410 MB) | `efederici/parakeet-tdt-0.6b-v3-int4` |
18
- | Highest accuracy, cloud | `groq/whisper-large-v3` (fast) or `openai/whisper-1` |
19
- | Offline + per-language control | `xenova/whisper-large-v3` or `xenova/whisper-base` |
20
- | Node stream input (not a file) | API only: `openai/whisper-1` or `groq/whisper-large-v3` |
21
-
22
- Constraints to surface before coding:
23
- - Local models (`xenova/*`, `*/parakeet-tdt-0.6b-v3*`) accept **files only**, not streams.
24
- - `language` option applies only to local Whisper. Parakeet is multilingual and ignores it.
25
- - API models need `OPENAI_API_KEY` or `GROQ_API_KEY` in the environment.
26
- - First Parakeet run downloads weights to `~/.cache/whispermix/parakeet/<modelKey>/` β€” warn the user.
27
- - Requires `ffmpeg` on `PATH` for long-audio chunking (>15 min split automatically).
28
- - `wordTimestamps: true` changes the return value from plain text to `{ text, words }`, where each word has `start` and `end` times in seconds.
29
-
30
- ## API
31
-
32
- ```bash
33
- npm install whispermix
34
- ```
35
-
36
- ESM only. If the consumer is CommonJS, use `const WhisperMix = (await import('whispermix')).default;`.
37
-
38
- ```javascript
39
- import WhisperMix from 'whispermix';
40
-
41
- const w = new WhisperMix({ model: '<modelKey>' });
42
- const text = await w.fromFile('path/to/audio.mp3');
43
- // API models only:
44
- const text2 = await w.fromStream(fs.createReadStream('path/to/audio.mp3'));
45
- ```
46
-
47
- Constructor options:
48
- - `model` (required) β€” see selection table.
49
- - `language` β€” local Whisper only, e.g. `'spanish'`. Default `'auto'`.
50
- - `chunkSize` β€” seconds per chunk for long audio. Default `890` (~14m50s).
51
- - `bottleneck` β€” Bottleneck config for API models. Defaults: `minTime: 3000`, `maxConcurrent: 1`, `reservoir: 18`, `reservoirRefreshAmount: 18`, `reservoirRefreshInterval: 60000`.
52
- - `showProgress` β€” boolean, prints chunk/decoding progress.
53
- - `wordTimestamps` β€” boolean, returns `{ text, words }` instead of a string. Can also be passed per call to `fromFile(filePath, { wordTimestamps: true })` or `fromStream(stream, { wordTimestamps: true })`.
54
-
55
- ## Examples
56
-
57
- Cheapest local:
58
-
59
- ```javascript
60
- import WhisperMix from 'whispermix';
61
- const w = new WhisperMix({ model: 'efederici/parakeet-tdt-0.6b-v3-int4', showProgress: true });
62
- console.log(await w.fromFile('meeting.wav'));
63
- ```
64
-
65
- Groq with custom rate limit:
66
-
67
- ```javascript
68
- import WhisperMix from 'whispermix';
69
- const w = new WhisperMix({
70
- model: 'groq/whisper-large-v3',
71
- bottleneck: { minTime: 4000, maxConcurrent: 1 },
72
- });
73
- console.log(await w.fromFile('podcast.mp3'));
74
- ```
75
-
76
- Word-level timestamps:
77
-
78
- ```javascript
79
- import WhisperMix from 'whispermix';
80
- const w = new WhisperMix({ model: 'openai/whisper-1' });
81
- const result = await w.fromFile('meeting.mp3', { wordTimestamps: true });
82
- console.log(result.text);
83
- console.log(result.words); // [{ word, start, end }, ...]
84
- ```
85
-
86
- Local Whisper, fixed language:
87
-
88
- ```javascript
89
- import WhisperMix from 'whispermix';
90
- const w = new WhisperMix({ model: 'xenova/whisper-large-v3', language: 'spanish' });
91
- console.log(await w.fromFile('entrevista.m4a'));
92
- ```
93
-
94
- ## Troubleshooting
95
-
96
- - **`OPENAI_API_KEY`/`GROQ_API_KEY is not set`** β€” export the key, or switch to a local model.
97
- - **`fromStream` not supported** β€” local models are file-only. Use `fromFile`, or switch to an API model.
98
- - **`Cannot find ffmpeg`** β€” install it (`brew install ffmpeg` / `apt install ffmpeg`).
99
- - **First Parakeet call hangs** β€” weights downloading; enable `showProgress: true`.
100
- - **`ERR_REQUIRE_ESM`** β€” WhisperMix is ESM-only; use dynamic `import()` from CommonJS.