https://github.com/spafedev/whisper-napi
https://github.com/spafedev/whisper-napi
addon bun node-addon nodejs transcription whisper
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/spafedev/whisper-napi
- Owner: SpafeDev
- License: mit
- Created: 2025-07-01T11:29:13.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-07-01T11:33:41.000Z (6 months ago)
- Last Synced: 2025-07-01T12:31:52.938Z (6 months ago)
- Topics: addon, bun, node-addon, nodejs, transcription, whisper
- Language: JavaScript
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# whisper-napi
## Usage Example
```js
const { MutterModel } = require("./whisper-napi.win32-x64-msvc.node");
const model = new MutterModel("./ggml-tiny.bin");
const audioPath = "./example.wav";
(async () => {
try {
// Transcribe audio from WAV file asynchronously
const result = await model.transcribe(audioPath);
console.log("Text:");
console.log(result.text);
console.log("\nSRT:");
console.log(result.srt);
} catch (err) {
console.error("Error:", err);
}
})();
```
## API
### `new MutterModel(modelPath: string)`
Constructs a new MutterModel instance by loading a GGML model from the specified path.
- **modelPath**: Path to the GGML model file (e.g. `"./ggml-tiny.bin"`).
Throws an error if the model fails to load.
---
### `transcribe(wavPath: string): Promise`
Asynchronously transcribes the audio from a WAV file.
- **wavPath**: Path to the WAV audio file to transcribe.
Returns a Promise resolving to a `Transcription` object containing:
- `text` — the transcription as plain text.
- `srt` — the transcription formatted as subtitles (SRT).
Throws an error if reading the WAV file or transcription fails.
---
## Transcription Object
```ts
interface Transcription {
text: string; // plain transcription text
srt: string; // transcription in SRT subtitle format
}
```