Skip to content

Python reference

Alkove on device: keep the user’s voice (Focus), find speech (Cue), hear words (Spot, Lex), know a voice (Timbre), the same to the bit as the web SDK.

Terminal window
pip install alkove

Start with the Python quick start.

Name Description
AlkoveError An error with the code the web SDK gives for the same cause (models.fetch, models.hash…).
Chain The real-time chain, one hop of 256 samples at 16 kHz at a time: Focus, Cue, the mix with the raw mic, the level, the gate. Its output is delay samples late.
Enroller The user says the word takes times: thresholds set from these takes and from what is heard between them.
Heard One of Spot’s frames, every 30 ms: its step, the speech probability (None for the first), each word’s score, the wakes.
Lex Text to phonemes in fr, en, es, pt, it, ca, ro: Lex’s beam search, word by word.
Listener Spot and the words it listens for, on 16 kHz audio of any block size: a wake word on a raw microphone.
Live The chain on a live stream at any rate, as the web SDK runs it in real time: frames in, the processed samples that are ready out, at the same rate.
Models Models loaded once and shared by every Processor and Chain, in any thread.
Part One block of a stream: its audio at 16 kHz, and what was found while it went through, in seconds from the stream’s start.
Processor Focus, Cue and Spot over audio pushed in blocks of any size, as real time feeds them: the output comes back aligned with the input, at 16 kHz.
Resampler Windowed sinc between any two rates, across chunks; aligned puts output k exactly on input k × ratio (files), else half a window late (real time).
Speech A stretch of speech, in seconds from the stream’s start.
SpeechParams Cue’s state machine: speech opens on one frame over confidence, counts after start_secs, closes after stop_secs under exit_confidence.
SpeechTracker Cue’s state machine on its probabilities, frame by frame: what Processor and the web SDK decide, for frameworks that want each step.
Timbre Who is speaking: a print from 16 kHz audio (1.5 s or more), compared with others.
Voiceprint A voice, bound to this version’s Timbre: give it to Focus (voiceprint=), compare it (Timbre.verify), store to_json().
VoiceprintLearner A print learned from the user’s speech, as the inputs of the web SDK learn it: a window joins only if it sounds like the others.
Word A word Spot listens for: its text, pronunciations and thresholds, bound to this version’s Spot. Store to_json(), read it back with Word.from_json.
Name Description
cache_dir Where fetch keeps the models: ~/Library/Caches/alkove on macOS, %LOCALAPPDATA%\alkove on Windows, $XDG_CACHE_HOME/alkove or ~/.cache/alkove elsewhere.
compile A typed word in one or more languages (needs lex), or phonemes between slashes like “/kamij/” (does not).
fetch Downloads the models into the cache once, checked by their sha256, and gives their paths. Nothing goes on the network afterwards; download=False only reads the cache.
process A whole recording, as real time would go through it: the audio as long as the input at 16 kHz, the speech, the wakes, the diag.
resample A whole signal from one rate to another, as long as the input at the new rate.
to_int16 Float samples to int16 as the web SDK writes them: clipped, scaled by 32768 below zero and 32767 above, truncated.
Name Description
MANIFEST The models this version runs: under models, by name, their file, size, sha256 and revision on Hugging Face.
RATE = 16000 The models’ rate, and the rate of every output, in Hz.