python-and-cli
Enables Porcupine Python SDK usage, low-level engine control, file and microphone demo patterns, device enumeration, and safe local checks.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- python-and-cli
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Enables Porcupine Python SDK usage, low-level engine control, file and microphone demo patterns, device enumeration, and safe local checks.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/python-api-reference.md5.9 KB
- 参考文档references/python-workflows.md4.5 KB
- 参考文档references/troubleshooting.md5.4 KB
- 脚本scripts/porcupine_file_check.py9.2 KB
03 SKILL.md 正文
python-and-cli
Use this sub-skill when you need to:
- install
pvporcupineand confirm the import - create a Porcupine engine in Python
- inspect
version,frame_length, orsample_rate - process a
.wavfile for wake-word detections - enumerate inference devices safely
- read
PorcupineErrorandmessage_stackfailures - adapt the packaged Python file demo into a reusable checker
Included workflow
- Python SDK install and import.
- Low-level engine creation, processing, and cleanup.
- Built-in keyword selection and custom keyword paths.
- Sensitivity handling and frame/sample-rate validation.
- File-based detection.
- Device enumeration and safe preflight checks.
- Reference-only microphone recipe.
Excluded workflow
- Custom wake-word training and asset selection.
- Language/platform matching for
.ppnand.pvfiles. - Node, web, React Native, Android, iOS, Flutter, Java, .NET, or C SDK details.
If the task is about training or model/keyword asset selection, route it to ../custom-keywords-and-assets/SKILL.md.
Read first
references/python-api-reference.mdfor verified signatures, object behavior, device strings, and exception classes.references/python-workflows.mdfor the file recipe, optional demo CLI notes, and the hardware-required microphone flow.references/troubleshooting.mdfor import, AccessKey, model, keyword, WAV, frame, device, and cleanup failures.
Run the bundled helper
scripts/porcupine_file_check.py --helpshows the safe parser without requiring an AccessKey.scripts/porcupine_file_check.py --list-devicesprints the inference devices advertised by the native library.scripts/porcupine_file_check.py --access-key "$ACCESS_KEY" --input-wav sample.wav --keyword picovoicescans a file with a built-in keyword.scripts/porcupine_file_check.py --access-key "$ACCESS_KEY" --input-wav sample.wav --keyword-path /path/to/custom.ppn --model-path /path/to/porcupine_params.pvscans a file with custom assets.
Practical boundaries
pvporcupine.createstill needs a valid AccessKey at initialization.Porcupine.processonly accepts 16-bit, single-channel PCM frames sized exactly toframe_length.available_devices()is the safe no-AccessKey check for loading the native library and discovering inference targets.- If you need to choose
.ppn/.pvassets or train a wake word, move to the sibling asset skill before coming back here. - If a task only needs the packaged demo CLI, the bundled helper and workflow notes are usually enough; you do not need the original repository checkout.
Quick routing guide
- Ask for
scripts/porcupine_file_check.pywhen the user wants a file-based wake-word check, a parser/help smoke test, or a path-safe example for the Python binding. - Ask for
references/python-workflows.mdwhen the user wants the microphone recipe,available_devices()usage, or a command-line comparison point. - Ask for
references/troubleshooting.mdwhen the user reports an import failure, a bad AccessKey, a model or keyword path problem, a sensitivity mismatch, a WAV format issue, or an invalid device selector. - Ask for
references/python-api-reference.mdwhen the user needs exact signatures,Porcupineattributes, or themessage_stackbehavior ofPorcupineErrorsubclasses. - Prefer the helper script over ad hoc code when the task is only to confirm that Porcupine can load a file and emit detections.
- Keep cleanup explicit: if you create the engine yourself, delete it in
finally.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).