Files
JiboOs/V3.1/build/hub-shim/README.md

74 lines
2.1 KiB
Markdown
Raw Permalink Normal View History

# jibo-hub-shim
Minimal Jibo Hub-compatible shim for `/v1/listen`.
## What it does
- Hosts a WebSocket server on `/v1/listen`.
- Waits for `CONTEXT` + `LISTEN` messages.
- Triggers offline STT by calling `jibo-asr-service` using:
- WebSocket `/simple_port` (event stream)
- HTTP `POST /asr_simple_interface` (start/stop)
and returns:
- `SOS` (start of speech)
- `ASR` (text)
- `NLU` (minimal intent/entities)
- `LISTEN` (final wrapper with `{asr,nlu}`)
- `EOS` (end of speech)
This avoids implementing hub-side audio decoding.
## Configure
Copy the example config:
- `cp config.example.json config.json`
Key fields:
- `asrService.baseUrl`
- If shim runs on the server: set this to your robot IP, e.g. `http://192.168.1.50:8088`
- If shim runs on the robot: keep `http://127.0.0.1:8088`
- `asrService.audioSourceId`
- Usually `alsa1` on-robot. If your robot uses a different input, change it here.
- `listen.port`: hub shim port (default `9000`)
## Dependencies
- Server-hosted shim: needs Node.js + the `ws` module available via normal Node resolution.
- If you have npm: `npm i ws`
- Robot-hosted shim: does not require npm; it will fall back to the already-bundled `ws` at `/opt/jibo/Jibo/Skills/@be/be/node_modules/ws`.
## Run
- `node index.js ./config.json`
## Server deployment (systemd)
From the `hub-shim/` folder on your server:
- `sudo ./install-server.sh`
This installs:
- Code to `/opt/jibo-hub-shim`
- Config to `/etc/jibo-hub-shim/config.json`
- Service unit `jibo-hub-shim.service`
Useful commands:
- `sudo systemctl status jibo-hub-shim`
- `sudo journalctl -u jibo-hub-shim -f`
## Notes
- The shim serializes STT requests to the robot ASR service to reduce crosstalk/timeouts when Jetstream opens multiple listens quickly.
- If you regularly speak longer than 15s, increase `asrService.timeoutMs`.
## Jetstream config
Point Jetstreams HubClient to this shim by setting `HubClient.override` in `/usr/local/etc/jibo-jetstream-service.json`:
- If shim runs on the server: set `hub_hostname` to the server IP.
- If shim runs on the robot: set `hub_hostname` to `127.0.0.1`.