Skip to content

fix(example): J-key voice command ack protocol to stop stale repeats - #4

Open
cavonlee wants to merge 1 commit into
masterfrom
fix/j-key-voice-ack
Open

fix(example): J-key voice command ack protocol to stop stale repeats#4
cavonlee wants to merge 1 commit into
masterfrom
fix/j-key-voice-ack

Conversation

@cavonlee

Copy link
Copy Markdown
Contributor

Problem

Client reported that sc.get("J") keeps returning the last voice recognition result forever (see PiCar-X / PiDog app control demos). Root cause on the demo side: the speak variable is assigned once and never reset, so the car keeps executing the last voice command.

Fix

Rework the J-key voice handling in examples/picarx_control.py:

  1. Edge-triggered execution — only execute when J transitions from empty/None to a command, so repeated identical commands (e.g. consecutive "forward") trigger again.
  2. Ack protocol with the App — the App keeps the voice command in its send buffer until the device consumes it:
    • Device receives command → returns J: 1 (ack, action in progress)
    • Device executes the action (~0.3s, adjustable)
    • Device returns J: 0 (action done) → App clears the pending command

This stops the stale repeat and makes repeated voice commands work.

Testing

  1. Run picarx_control.py on the Pi, connect the SunFounder Controller App
  2. Speak a command (e.g. "forward") — car should move briefly then stop
  3. Speak the same command again — car should move again (repeat works)
  4. Check App console for STT read changed (value 1 and 0) + STT value clear

Version bumped to 0.0.4 (0.0.3 is claimed by the open debug-logging PR #3).

- Edge-triggered voice commands: only execute on new command (None/'' -> command),
  so repeated identical commands (e.g. consecutive "forward") trigger again
- Ack protocol with App: device returns J:1 on receipt, executes the action,
  then returns J:0 when done so the App clears the pending command
- Fixes: voice command repeating the last recognition result forever
- Bump version to 0.0.4, add CHANGELOG and README notes
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