@nicfox77/parakeet-stt 0.2.6 → 0.2.8

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.6",
3
+ "version": "0.2.8",
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": {
@@ -22,6 +22,8 @@
22
22
  "@sinclair/typebox": "0.34.48"
23
23
  },
24
24
  "openclaw": {
25
- "extensions": ["./index.ts"]
25
+ "extensions": [
26
+ "./index.ts"
27
+ ]
26
28
  }
27
29
  }
@@ -147,42 +147,46 @@ done
147
147
  configure_openclaw() {
148
148
  echo "Configuring OpenClaw to use Parakeet for audio transcription..."
149
149
 
150
- # Try config.patch first (partial update)
150
+ # Use config.patch RPC for partial update
151
151
  if command -v openclaw &> /dev/null; then
152
- openclaw gateway call config.patch --params '{
153
- "patch": {
154
- "tools": {
155
- "media": {
156
- "audio": {
157
- "models": [{
158
- "type": "cli",
159
- "command": "'$PARAKEET_DIR'/parakeet-audio-client.py",
160
- "args": ["{{MediaPath}}", "{{OutputDir}}"]
161
- }]
162
- }
163
- }
164
- }
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
165
  }
166
- }' 2>/dev/null && {
167
- echo "Config updated via config.patch"
168
- echo ""
169
- echo "IMPORTANT: Restart the gateway to activate transcription:"
170
- echo " openclaw gateway restart"
171
- return 0
172
- }
166
+ else
167
+ echo "Warning: Could not get config hash for config.patch"
168
+ fi
169
+ else
170
+ echo "Warning: openclaw CLI not found"
173
171
  fi
174
172
 
175
173
  # Fallback: manual instructions
176
174
  echo ""
177
- echo "Please add to your openclaw.json under tools.media.audio:"
175
+ echo "Please manually add to your openclaw.json:"
178
176
  echo ""
179
- echo ' "models": [{'
180
- echo ' "type": "cli",'
181
- echo ' "command": "'$PARAKEET_DIR'/parakeet-audio-client.py",'
182
- echo ' "args": ["{{MediaPath}}", "{{OutputDir}}"]'
183
- echo ' }]'
177
+ echo ' "tools": {'
178
+ echo ' "media": {'
179
+ echo ' "audio": {'
180
+ echo ' "models": [{'
181
+ echo ' "type": "cli",'
182
+ echo ' "command": "'$PARAKEET_DIR'/parakeet-audio-client.py",'
183
+ echo ' "args": ["{{MediaPath}}"]'
184
+ echo ' }]'
185
+ echo ' }'
186
+ echo ' }'
187
+ echo ' }'
184
188
  echo ""
185
- echo "Then restart: openclaw gateway restart"
189
+ echo "Then run: openclaw gateway restart"
186
190
  }
187
191
 
188
192
  configure_openclaw || true
@@ -199,7 +203,4 @@ echo "To switch models, run:"
199
203
  echo " $0 v2 # English optimized"
200
204
  echo " $0 v3 # Multilingual"
201
205
  echo ""
202
- echo "IMPORTANT: Apply config to activate transcription:"
203
- echo " openclaw gateway call config.apply --params '{\"note\": \"Parakeet STT\"}'"
204
- echo ""
205
- echo "Or restart the gateway service completely."
206
+ echo "Audio transcription is now configured and ready."
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env python3
2
+ """
3
+ Parakeet Audio Client for OpenClaw
4
+ Transcribes audio files using the Parakeet lazy daemon.
5
+ Outputs transcript to stdout (OpenClaw CLI model requirement).
6
+ """
2
7
  import json
3
8
  import os
4
9
  import socket
@@ -10,7 +15,7 @@ SOCKET_PATH = "/tmp/parakeet-lazy.sock"
10
15
  DAEMON_PATH = os.path.expanduser("~/.openclaw/tools/parakeet/parakeet-lazy-daemon.py")
11
16
 
12
17
  def ensure_daemon():
13
- # Check if daemon socket exists and responsive
18
+ """Check if daemon is running, start it if not."""
14
19
  try:
15
20
  with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
16
21
  s.settimeout(0.5)
@@ -32,6 +37,7 @@ def ensure_daemon():
32
37
  sys.exit(1)
33
38
 
34
39
  def query_daemon(audio_path):
40
+ """Query the daemon for transcription."""
35
41
  for attempt in range(3):
36
42
  try:
37
43
  with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
@@ -49,25 +55,36 @@ def query_daemon(audio_path):
49
55
  if response_data:
50
56
  response = json.loads(response_data.strip())
51
57
  if "text" in response:
52
- print(response["text"])
53
- return 0
58
+ return response["text"]
54
59
  else:
55
60
  print(response.get("error", "Unknown error"), file=sys.stderr)
56
- return 1
61
+ return None
57
62
  else:
58
63
  time.sleep(0.5)
59
64
  except Exception as e:
60
65
  if attempt == 2:
61
66
  print(f"Daemon communication failed: {e}", file=sys.stderr)
62
- return 1
67
+ return None
63
68
  time.sleep(0.5)
64
- return 1
69
+ return None
65
70
 
66
71
  if __name__ == "__main__":
67
72
  if len(sys.argv) < 2:
68
- print("Usage: parakeet-audio-client.py <audio_path> [output_dir]", file=sys.stderr)
73
+ print("Usage: parakeet-audio-client.py <audio_path>", file=sys.stderr)
69
74
  sys.exit(1)
75
+
70
76
  audio_path = sys.argv[1]
71
- # output_dir = sys.argv[2] if len(sys.argv) > 2 else None
77
+
78
+ # Start daemon if needed
72
79
  ensure_daemon()
73
- sys.exit(query_daemon(audio_path))
80
+
81
+ # Get transcription
82
+ transcript = query_daemon(audio_path)
83
+
84
+ if transcript:
85
+ # Output transcript to stdout (OpenClaw reads stdout for CLI transcribers)
86
+ print(transcript)
87
+ sys.exit(0)
88
+ else:
89
+ print("Transcription failed", file=sys.stderr)
90
+ sys.exit(1)