repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

quickshell/nuguland/NOKO.md

Raw

Noko

Minimal local speech-to-text tool using Parakeet.

Scope

Noko owns the core transcription flow only:

mic audio
→ mono float samples
→ resample to 16 kHz
→ split into 30 ms frames
→ VAD keeps speech frames
→ concatenate speech samples
→ Parakeet ONNX inference
→ trim/filter text
→ save history/output text

Out of scope for this spec: hotkeys, triggers, UI shell, app updater, system autostart, desktop integration.

Audio contract

VAD contract

VAD is separate from Parakeet. It is a pre-inference speech gate.

Handy-derived defaults:

Smoothing state machine:

not_speech + speech frame
→ count onset
→ if onset threshold met: enter speech, flush pre-roll

speech + speech frame
→ keep frame, reset hangover

speech + noise frame
→ keep frame while hangover remains

not_speech + noise frame
→ drop frame

Parakeet runtime

Engine states:

unloaded → loading → ready → transcribing → ready
                         ↘ failed

Inference contract

Postprocess

Minimal:

Optional:

History

Save after successful transcription.

Fields:

Failure cases

Handle explicitly:

Main lesson from Handy

Parakeet should receive clean, normalized, speech-only 16 kHz mono audio. Resampling, VAD, smoothing, history, and output are app responsibilities outside Parakeet.

Markdown source
File outline
# Noko

Minimal local speech-to-text tool using Parakeet.

## Scope

Noko owns the core transcription flow only:

```text
mic audio
→ mono float samples
→ resample to 16 kHz
→ split into 30 ms frames
→ VAD keeps speech frames
→ concatenate speech samples
→ Parakeet ONNX inference
→ trim/filter text
→ save history/output text
```

Out of scope for this spec: hotkeys, triggers, UI shell, app updater, system autostart, desktop integration.

## Audio contract

- Capture PCM from selected input device.
- Convert all input to mono `float32`.
- Target sample rate is `16_000 Hz`.
- Multi-channel input is averaged to mono.
- If device runs at another rate, resample before VAD/inference.

## VAD contract

VAD is separate from Parakeet. It is a pre-inference speech gate.

- Use Silero VAD ONNX or equivalent.
- Input frames are exactly 30 ms.
- At 16 kHz, one frame is `480` samples.
- Output only speech samples to Parakeet.

Handy-derived defaults:

- threshold: `0.3`
- frame size: `30 ms`
- pre-roll: `15` frames
- onset: `2` frames
- hangover: `15` frames

Smoothing state machine:

```text
not_speech + speech frame
→ count onset
→ if onset threshold met: enter speech, flush pre-roll

speech + speech frame
→ keep frame, reset hangover

speech + noise frame
→ keep frame while hangover remains

not_speech + noise frame
→ drop frame
```

## Parakeet runtime

- Parakeet is directory-based, not a single model file.
- Expected model contents conceptually:
  - preprocessor ONNX
  - encoder ONNX
  - decoder/joint ONNX
  - vocabulary/tokenizer file
- Prefer int8 model directories for size and speed.
- Use ONNX Runtime or a wrapper around it.
- Load model once and reuse it.
- Serialize inference unless runtime thread-safety is proven.

Engine states:

```text
unloaded → loading → ready → transcribing → ready
                         ↘ failed
```

## Inference contract

- Input: one continuous `float32` sample buffer, mono, 16 kHz, speech-only.
- Reject empty buffers.
- Optional: prepend small silence for timestamp/model stability.
- Timestamp granularity can be segment-level; minimal Noko only needs text.
- Output: `result.text.trim()`.

## Postprocess

Minimal:

- trim whitespace
- collapse repeated spaces
- drop empty result
- remove known junk tokens if observed

Optional:

- custom word correction
- punctuation/capitalization cleanup

## History

Save after successful transcription.

Fields:

- timestamp
- transcript
- duration or sample count
- model id/version
- quantization
- runtime provider
- optional audio path
- optional error record for failed transcription

## Failure cases

Handle explicitly:

- no input device
- unsupported sample format
- resampler failure
- VAD model missing
- Parakeet model dir incomplete
- runtime provider unavailable
- empty speech buffer after VAD
- inference error/crash
- CPU instruction incompatibility

## Main lesson from Handy

Parakeet should receive clean, normalized, speech-only 16 kHz mono audio. Resampling, VAD, smoothing, history, and output are app responsibilities outside Parakeet.