Liking cljdoc? Tell your friends :D

com.blockether.vis.internal.speech.asr

Direct Java sherpa-onnx integration for Parakeet TDT ASR.

Direct Java sherpa-onnx integration for Parakeet TDT ASR.
raw docstring

asset-idclj

source

chunk-planclj

(chunk-plan total-samples sample-rate chunk-seconds)

Pure: the [start end] SAMPLE ranges to decode, in order.

A recording shorter than chunk-seconds is ONE range (chunking cannot improve a clip that decodes in a moment, and every extra boundary risks cutting a word). A trailing piece shorter than min-audio-seconds is merged into the one before it: a sliver of audio decodes blank or trips ONNX shape errors, and it would be reported as a whole chunk of progress for nothing.

Pure: the `[start end]` SAMPLE ranges to decode, in order.

A recording shorter than `chunk-seconds` is ONE range (chunking cannot improve
a clip that decodes in a moment, and every extra boundary risks cutting a
word). A trailing piece shorter than [[min-audio-seconds]] is merged into the
one before it: a sliver of audio decodes blank or trips ONNX shape errors, and
it would be reported as a whole chunk of progress for nothing.
sourceraw docstring

default-chunk-secondsclj

Audio longer than this is decoded in pieces so PROGRESS is a measurement and not an animation: each finished piece is a real fraction of the recording. Parakeet is an offline (non-streaming) model, so a single decode call is a black box of unknown length — the only honest progress it can report is how much AUDIO has been consumed.

Audio longer than this is decoded in pieces so PROGRESS is a measurement and
not an animation: each finished piece is a real fraction of the recording.
Parakeet is an offline (non-streaming) model, so a single `decode` call is a
black box of unknown length — the only honest progress it can report is how
much AUDIO has been consumed.
sourceraw docstring

default-model-dirclj

(default-model-dir)

~/.vis model path used when no env/config override is set. A function, never a top-level def: native-image initializes this namespace at BUILD time, so a captured user.home would point every installed binary at the BUILDER's home.

~/.vis model path used when no env/config override is set. A function, never a
top-level `def`: `native-image` initializes this namespace at BUILD time, so a
captured `user.home` would point every installed binary at the BUILDER's home.
sourceraw docstring

ensure-model!clj

(ensure-model!)
(ensure-model! dir)
(ensure-model! dir on-progress)

Download and atomically install the Parakeet model when it is missing.

Download and atomically install the Parakeet model when it is missing.
sourceraw docstring

min-audio-secondsclj

Minimum microphone audio length sent to Parakeet ASR. Very short clips either transcribe blank or trigger opaque ONNX Conv_quant shape errors, so reject them before inference.

Minimum microphone audio length sent to Parakeet ASR.
Very short clips either transcribe blank or trigger opaque ONNX Conv_quant
shape errors, so reject them before inference.
sourceraw docstring

model-assetclj

(model-asset)

This model's manifest entry — where it may be fetched from, what verifies it and what it is licensed under. The URL used to be a literal here; it now lives in one file with an SPDX id beside it.

This model's manifest entry — where it may be fetched from, what verifies it
and what it is licensed under. The URL used to be a literal here; it now lives
in one file with an SPDX id beside it.
sourceraw docstring

model-dirclj

(model-dir)
source

model-dir-envclj

source

model-filesclj

(model-files)
(model-files dir)
source

model-installed?clj

(model-installed?)
(model-installed? dir)
source

model-sample-rateclj

The sample rate Parakeet features are computed at. A recording at another rate is converted to it before it is read, so the whole clip is held in memory at this rate.

The sample rate Parakeet features are computed at. A recording at another rate is
converted to it before it is read, so the whole clip is held in memory at this rate.
sourceraw docstring

model-stateclj

(model-state)

Current voice-model state for a UI to POLL: {:state :ready} model files installed {:state :downloading :progress 0..100} a background download is running {:state :failed :error "…"} the last download failed {:state :absent} not installed, idle (no download)

Current voice-model state for a UI to POLL:
{:state :ready}                        model files installed
{:state :downloading :progress 0..100} a background download is running
{:state :failed :error "…"}          the last download failed
{:state :absent}                       not installed, idle (no download)
sourceraw docstring

release!clj

(release!)

Drop the cached recognizer and free the model it holds — the call for shutdown and for a reconfiguration that must not keep a model in memory. The next transcription loads one again. Safe when nothing is cached.

Drop the cached recognizer and free the model it holds — the call for shutdown
and for a reconfiguration that must not keep a model in memory. The next
transcription loads one again. Safe when nothing is cached.
sourceraw docstring

start-download!clj

(start-download!)

Idempotent, NON-blocking: if the model is absent and no download is already running, start one on a background thread (progress tracked in the atom). Returns the current model-state immediately.

Idempotent, NON-blocking: if the model is absent and no download is already
running, start one on a background thread (progress tracked in the atom).
Returns the current `model-state` immediately.
sourceraw docstring

tokens->wordsclj

(tokens->words tokens timestamps durations offset-seconds)

Pure: sherpa's sub-word tokens and their start times as whole WORDS — {:text :start :end} in seconds, shifted by offset-seconds.

The pieces are glued back into words, each keeping the first piece's start and the last piece's end, because a reader follows words and not word pieces. durations may be empty — a legal result — and a word without one lasts until the next word begins.

Pure: sherpa's sub-word tokens and their start times as whole WORDS —
`{:text :start :end}` in seconds, shifted by `offset-seconds`.

The pieces are glued back into words, each keeping the first piece's start and the
last piece's end, because a reader follows words and not word pieces. `durations`
may be empty — a legal result — and a word without one lasts until the next word
begins.
sourceraw docstring

transcribe-file!clj

(transcribe-file! audio-path)
(transcribe-file! dir audio-path)
(transcribe-file! dir audio-path {:keys [on-progress chunk-seconds]})

Transcribe audio-path with local Parakeet TDT int8 through the sherpa-onnx Java API. Auto-downloads the model on first use. Returns {:text :words}: the whole transcript, and every WORD with the seconds it occupies in the recording.

opts may carry :on-progress, called with {:phase :progress} (:preparing while the model and the native runtime are being made ready, then :transcribing with 0..100 of the AUDIO consumed) and :chunk-seconds. A throwing or slow callback can never fail a transcription: it is guarded here.

Transcribe `audio-path` with local Parakeet TDT int8 through the sherpa-onnx
Java API. Auto-downloads the model on first use. Returns `{:text :words}`: the
whole transcript, and every WORD with the seconds it occupies in the recording.

`opts` may carry `:on-progress`, called with `{:phase :progress}` (`:preparing`
while the model and the native runtime are being made ready, then
`:transcribing` with 0..100 of the AUDIO consumed) and `:chunk-seconds`. A
throwing or slow callback can never fail a transcription: it is guarded here.
sourceraw docstring

validate-wav-file!clj

(validate-wav-file! audio-path)

Structural RIFF/WAVE check in PURE JVM code before a file reaches sherpa-onnx's native WaveReader, which SIGSEGVs AND ABORTS THE WHOLE JVM on malformed input — including a well-formed header whose declared chunk sizes overrun the bytes actually present (a truncated upload or partial write; observed live). No catchable native exception is on offer, so every chunk in the table must fit inside the file, and a 16-bit PCM fmt chunk plus a data chunk must both be present (the only shape either producer emits — ui.js's encoder and the TUI recorder — and the only one WaveReader reads). Throws ex-info :voice-asr/invalid-wav. Returns audio-path.

Structural RIFF/WAVE check in PURE JVM code before a file reaches
sherpa-onnx's native WaveReader, which SIGSEGVs AND ABORTS THE WHOLE JVM
on malformed input — including a well-formed header whose declared chunk
sizes overrun the bytes actually present (a truncated upload or partial
write; observed live). No catchable native exception is on offer, so
every chunk in the table must fit inside the file, and a 16-bit PCM
`fmt ` chunk plus a `data` chunk must both be present (the only shape
either producer emits — ui.js's encoder and the TUI recorder — and the
only one WaveReader reads). Throws ex-info :voice-asr/invalid-wav.
Returns audio-path.
sourceraw docstring

warm!clj

(warm!)

Load the recognizer NOW, so the FIRST recording decodes instead of waiting for the model. True when one is loaded, false when no model is installed: a head start is never a reason to begin a download nobody asked for — that is start-download!, which a human drives. Cheap and idempotent once warm. The caller provides the native runtime, exactly as it does for transcribe-file!.

Load the recognizer NOW, so the FIRST recording decodes instead of waiting for
the model. True when one is loaded, false when no model is installed: a head
start is never a reason to begin a download nobody asked for — that is
[[start-download!]], which a human drives. Cheap and idempotent once warm. The
caller provides the native runtime, exactly as it does for [[transcribe-file!]].
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close