+PHONLET / DOCUMENTATION
Phonlet Wake for Python.
A wheel with the engine built in, for prototypes, research, and Linux devices.
The Python SDK is a wheel that bundles the engine and uses NumPy. It needs no compiler, lexicon, or network at runtime. It is tested on CPython 3.12 on Linux x64.
Example
wake.py
from phonlet_wake import Wake # A phrase is its pronunciations and two calibrated thresholds.hey_kettle = { "name": "hey kettle", "pronunciations": [[16, 13, 20, 11, 31, 3, 21]], "threshold_loose": -1.21875, "threshold_strict": -0.8740234375, "endpoint": True,} # One engine and one model for every phrase.with Wake.create(model="en-1.pwake", keywords=[hey_kettle], sensitivity=0.5) as wake: # Push 16 kHz mono int16 NumPy arrays in chunks of any size. for pcm in audio_chunks(): # your microphone or file for hit in wake.process(pcm): print("Wake word:", hit.keyword)How it works
- Make a keyword file for your phrases with the generator: each phrase gets its pronunciations and its loose and strict thresholds, calibrated for this model.
- Create a Wake with the model and your phrases, inside a with block so it closes on success and on errors. Pass the keyword file from the generator as a path, as the parsed dict, or as phrases written in code; a file that names its model is checked against it by SHA-256.
- Pass int16 NumPy arrays to process(); it returns the detections in that chunk.
- Call finish() at the end of a stream to see how many trailing samples did not fill a frame.
Good to know
- Audio is mono, 16 kHz, signed 16-bit PCM. Push chunks of any size; the engine buffers them into 512-sample (32 ms) frames.
- A phrase always comes with its thresholds: they are calibrated for that phrase and that model, and the engine needs them to decide when it was said. The generator makes them from text (phonletai.com/generator, or the wake-threshold command) and writes them into your keyword file.
- Each detection has keyword_id, keyword, keyword_index, frame_index, sample_index, time_seconds, and the sensitivity used.
- Microphone input is an optional extra (sounddevice with PortAudio); detection itself has no audio dependency.
Get the Python SDK
The Python SDK, the en-1 model and the threshold generator are in release v0.1.0, free for non-commercial use. For a product you sell, get a commercial licence.
Terminal
pip install \ https://github.com/phonlet-ai/wake/releases/download/v0.1.0/phonlet_wake-0.1.0-py3-none-linux_x86_64.whl \ https://github.com/phonlet-ai/wake/releases/download/v0.1.0/phonlet_wake_model_en-0.1.0-py3-none-any.whlThe SDK wheel and the model wheel. In the example, en-1.pwake is the model: english["model"] from phonlet_wake_model_en, or phonlet-wake-en-1.pwake from the release.