@nicfox77/parakeet-stt 0.2.8 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nicfox77/parakeet-stt",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Parakeet TDT INT8 speech-to-text plugin for OpenClaw. Supports V2 (English) and V3 (Multilingual) models.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -73,7 +73,7 @@ pip install --upgrade pip
73
73
  pip install onnxruntime librosa soundfile
74
74
 
75
75
  # Download and extract model if not present
76
- if [ ! -d "$MODEL_DIR" ] || [ ! -f "$MODEL_DIR/model.onnx" ]; then
76
+ if [ ! -d "$MODEL_DIR" ] || [ ! -f "$MODEL_DIR/encoder-model.int8.onnx" ]; then
77
77
  echo ""
78
78
  echo "Downloading Parakeet TDT $VERSION model (~$MODEL_SIZE)..."
79
79
  echo "URL: $MODEL_URL"
@@ -147,36 +147,67 @@ done
147
147
  configure_openclaw() {
148
148
  echo "Configuring OpenClaw to use Parakeet for audio transcription..."
149
149
 
150
- # Use config.patch RPC for partial update
150
+ CONFIG_FILE="$HOME/.openclaw/openclaw.json"
151
+
152
+ if [ ! -f "$CONFIG_FILE" ]; then
153
+ echo "Warning: OpenClaw config not found at $CONFIG_FILE"
154
+ echo "Please configure manually after running 'openclaw configure'"
155
+ return 1
156
+ fi
157
+
158
+ # Check if jq is available
159
+ if ! command -v jq &> /dev/null; then
160
+ echo "Warning: jq not found. Please install jq for automatic config."
161
+ echo "Then re-run this script or configure manually."
162
+ return 1
163
+ fi
164
+
165
+ # Build the audio config
166
+ AUDIO_CONFIG=$(cat <<EOF
167
+ {
168
+ "enabled": true,
169
+ "scope": {
170
+ "default": "deny",
171
+ "rules": [{ "action": "allow", "match": { "chatType": "direct" } }]
172
+ },
173
+ "models": [{
174
+ "type": "cli",
175
+ "command": "$PARAKEET_DIR/parakeet-audio-client.py",
176
+ "args": ["{{MediaPath}}"]
177
+ }]
178
+ }
179
+ EOF
180
+ )
181
+
182
+ # Merge into config using jq
183
+ # This creates tools.media.audio if it doesn't exist, or updates it
184
+ TMP_CONFIG=$(mktemp)
185
+ jq --argjson audio "$AUDIO_CONFIG" '
186
+ .tools.media.audio = $audio
187
+ ' "$CONFIG_FILE" > "$TMP_CONFIG" && mv "$TMP_CONFIG" "$CONFIG_FILE"
188
+
189
+ echo "Config updated successfully"
190
+
191
+ # Restart gateway to pick up changes
151
192
  if command -v openclaw &> /dev/null; then
152
- # Get current config hash (required for config.patch)
153
- # Hash is at root level in the response, extract with grep
154
- CONFIG_HASH=$(openclaw gateway call config.get --params '{}' --json 2>/dev/null | grep -oP '"hash"\s*:\s*"\K[^"]+' | tail -1)
155
-
156
- if [ -n "$CONFIG_HASH" ] && [ "$CONFIG_HASH" != "null" ]; then
157
- openclaw gateway call config.patch --params '{
158
- "raw": "{ tools: { media: { audio: { models: [{ \"type\": \"cli\", \"command\": \"'$PARAKEET_DIR'/parakeet-audio-client.py\", \"args\": [\"{{MediaPath}}\"] }] } } } } }",
159
- "baseHash": "'$CONFIG_HASH'"
160
- }' 2>/dev/null && {
161
- echo "Applied config.patch - Parakeet configured and gateway reloaded"
162
- return 0
163
- } || {
164
- echo "Warning: config.patch failed"
165
- }
166
- else
167
- echo "Warning: Could not get config hash for config.patch"
168
- fi
169
- else
170
- echo "Warning: openclaw CLI not found"
193
+ echo "Restarting OpenClaw gateway..."
194
+ openclaw gateway restart 2>/dev/null || {
195
+ echo "Note: Gateway restart failed. Run 'openclaw gateway restart' manually."
196
+ }
171
197
  fi
172
198
 
173
- # Fallback: manual instructions
199
+ return 0
200
+ }
201
+
202
+ configure_openclaw || {
174
203
  echo ""
175
- echo "Please manually add to your openclaw.json:"
204
+ echo "Automatic config failed. Please manually add to your openclaw.json:"
176
205
  echo ""
177
206
  echo ' "tools": {'
178
207
  echo ' "media": {'
179
208
  echo ' "audio": {'
209
+ echo ' "enabled": true,'
210
+ echo ' "scope": { "default": "deny", "rules": [{ "action": "allow", "match": { "chatType": "direct" } }] },'
180
211
  echo ' "models": [{'
181
212
  echo ' "type": "cli",'
182
213
  echo ' "command": "'$PARAKEET_DIR'/parakeet-audio-client.py",'
@@ -189,8 +220,6 @@ configure_openclaw() {
189
220
  echo "Then run: openclaw gateway restart"
190
221
  }
191
222
 
192
- configure_openclaw || true
193
-
194
223
  echo ""
195
224
  echo "=== Installation Complete ==="
196
225
  echo ""
@@ -12,7 +12,9 @@ import sys
12
12
  import time
13
13
 
14
14
  SOCKET_PATH = "/tmp/parakeet-lazy.sock"
15
- DAEMON_PATH = os.path.expanduser("~/.openclaw/tools/parakeet/parakeet-lazy-daemon.py")
15
+ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
16
+ DAEMON_PATH = os.path.join(SCRIPT_DIR, "parakeet-lazy-daemon.py")
17
+ VENV_PYTHON = os.path.join(SCRIPT_DIR, ".venv", "bin", "python")
16
18
 
17
19
  def ensure_daemon():
18
20
  """Check if daemon is running, start it if not."""
@@ -23,10 +25,11 @@ def ensure_daemon():
23
25
  return # daemon already running
24
26
  except Exception:
25
27
  pass
26
- # Start daemon in background
28
+ # Start daemon in background with venv Python
29
+ python_exe = VENV_PYTHON if os.path.exists(VENV_PYTHON) else sys.executable
27
30
  try:
28
31
  subprocess.Popen(
29
- [sys.executable, DAEMON_PATH],
32
+ [python_exe, DAEMON_PATH],
30
33
  stdout=subprocess.DEVNULL,
31
34
  stderr=subprocess.DEVNULL,
32
35
  start_new_session=True