Speech-to-text for Krio and other African languages — powered by Whisper large-v3 via Hugging Face
# krio-stt
Speech-to-text for **Krio** and other African languages — powered by Whisper large-v3 via the Hugging Face Inference API.
Works with voice notes from **WhatsApp**, **Telegram**, local files, or any audio URL. No extra dependencies — pure Node.js.
## Why Whisper large-v3?
Standard STT engines struggle with Krio (Sierra Leonean Creole), Nigerian Pidgin, and heavily accented speech. Whisper large-v3 is trained on a wide range of languages and accents and handles these significantly better than smaller models.
## Installation
```bash
npm install krio-stt
```
Or use it locally in a monorepo:
```bash
npm install ../krio-stt
```
## Quick Start
```js
const { transcribeUrl, transcribeBuffer, transcribeFile } = require('krio-stt');
```
Set your Hugging Face API key (free at
huggingface.co):
```bash
export HUGGINGFACE_API_KEY=hf_...
```
### Transcribe from a URL
```js
// Public URL — no auth needed
const text = await transcribeUrl('
example.com');
// Protected URL — pass a Bearer token
const text = await transcribeUrl(mediaUrl, {
auth: { bearer: process.env.WHAPI_TOKEN },
});
```
### Transcribe from a Buffer
```js
const text = await transcribeBuffer(audioBuffer, {
contentType: 'audio/ogg',
});
```
### Transcribe from a local file
```js
const text = await transcribeFile('/path/to/voice.ogg');
```
## Auth Options
The `auth` option in `transcribeUrl` supports multiple formats:
```js
// Bearer token (WhatsApp / Whapi, most APIs)
{ auth: { bearer: 'TOKEN' } }
// Basic auth
{ auth: { basic: { user: 'username', pass: 'password' } } }
// Arbitrary header
{ auth: { header: { key: 'X-API-Key', value: 'TOKEN' } } }
// Raw Authorization header value
{ auth: 'Bearer TOKEN' }
```
## Platform Examples
### WhatsApp (via Whapi)
```js
const { transcribeUrl } = require('krio-stt');
// In your webhook handler:
if (message.type === 'audio') {
const text = await transcribeUrl(message.media.url, {
auth: { bearer: process.env.WH …