Skip to content

Use standalone Snowboy package without embedded native code - #109

Open
evancohen wants to merge 4 commits into
masterfrom
fix/standalone-snowboy
Open

evancohen wants to merge 4 commits into
masterfrom
fix/standalone-snowboy

Conversation

@evancohen

@evancohen evancohen commented Sep 11, 2026 •

Copy link
Copy Markdown
Owner

Keep native hotword detection in the separate snowboy package and harden Sonus's recording/recognition lifecycle before merging the behavior changes from Sam's fork.

Depends on evancohen/snowboy#2 (unpublished 1.4.0-rc.0). This PR is based directly on upstream master; no native sources, libraries, or embedded Snowboy history are imported. It replaces #108.

Package separation:

  • Depend on snowboy ^1.4.0-rc.0 and prepare Sonus 1.0.5-rc.0.
  • Resolve Sonus's existing resources relative to its installed directory.
  • Keep conversational mode and audio-gain defaults from Sam's changes.

Correctness fixes found during review:

  • Restore no-argument stop() compatibility, clear started/listening state, and prevent an inactive instance from stopping another recorder.
  • Enforce the underlying recorder's single-process limit; repeated start() no longer spawns duplicate recorders.
  • Remove waitprocess, including its process-name polling and potential kill-by-name behavior. Wait for the exact ChildProcess returned by node-record-lpcm16.stop(), with a timeout and explicit error reporting.
  • Cancel pending rollover on stop, keep byte counters per instance, reconnect conversational audio after rollover, and preserve the detector when the old mic stream ends.
  • Apply language defaults in conversational mode and support requesting another phrase without restarting the microphone.
  • Implement pause/resume using the microphone stream; node-record-lpcm16 0.3.1 does not export pause/resume methods.
  • Clean up cloud streams on final/error/end/close and before callbacks can start another request. Ignore late responses from stopped sessions; do not discard speech-event-only responses that can precede a final transcript.
  • Preserve cloud error causes instead of misreporting them as invalid hotword indexes, and surface detector/recorder errors instead of silently swallowing them.
  • Document lifecycle semantics and error payloads in docs/API.md.

Validation on the final commit: all Node 14.21.3, 20, and 22 jobs passed on Linux x64: https://github.com/evancohen/sonus/actions/runs/34548575527 .

  • Ten CI-only mocked lifecycle regression checks cover stop compatibility, exclusive recording, repeated conversational phrases, cloud error/EOF handling, rollover reconnection, stop/restart races, timeout, pause/resume, and recorder/detector failures.
  • The previous implementation was confirmed to fail the stop() compatibility regression.
  • Actual Snowboy candidate tarball installation, native detector construction/silent-audio processing, and Sonus conversational initialization also passed.
  • Source lint and whitespace checks passed locally. npm pack confirms .github checks and candidate checkout are excluded from the shipped package. No test/ directory is added.

Remaining validation: no physical microphone/arecord device or live Google Speech session was available. These CI checks do not establish recognition quality or Raspberry Pi/macOS hardware compatibility. A device-level recording/rollover/pause/resume and conversational-turn check is still appropriate before release.

Release sequence: publish the approved Snowboy prerelease first, then Sonus. Do not release against the currently nonexistent registry version. CI temporarily builds the pinned Snowboy candidate locally. Nothing has been published, and smart-mirror's dependency remains unchanged.

… fixes

Adapt JavaScript behavior from sdetweil/sonus f01d0b1 without importing embedded native sources or binaries.
@evancohen
evancohen marked this pull request as ready for review September 11, 2026 00:47
@evancohen
evancohen marked this pull request as draft September 11, 2026 00:49
@evancohen
evancohen marked this pull request as ready for review September 11, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant