diff --git a/README.md b/README.md index 75e1b94..8a1898f 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ Watching TV used to mean turning the dial to 4 (NBC), 5 (CBS), or 9 (ABC). Now o Part of the agent is a box within reach of the couch: press its button and talk. Its ears and voice, speech recognition and synthesis, run on a computer at home, so recordings of you never leave the house; the language model behind it sees only a transcript. + +voice kit with IR remote + + ## "Put on the ballgame," says Dad One request from the couch becomes a dozen steps for the agent, with a look at the screen when it needs one: @@ -23,10 +27,10 @@ The game isn't on 4, 5, or 9. It's on a sports network in the hundreds, behind t ## How it works -The agent has two parts: the box within reach of the couch, with an IR emitter on a cord where the TV can see it, and a home server that runs speech and the brain; the diagram draws those two apart, since they can be. +The agent has two parts: the box within reach of the couch, with an IR emitter on a cord where the TV can see it, and a Linux machine at home that serves as speech server and agent host; the diagram draws those two apart, since they can be. ``` - near the couch speech server brain host + near the couch speech server agent host ┌───────────────┐ hear ──▶ ┌──────────────┐ │ the box │ speak ──▶ │ whisper.cpp │ │ Pi 3B │ │ piper │ @@ -55,18 +59,9 @@ An agent in the living room should be able to do what it's for, and no more. A c The parts talk over [Cap'n Web](https://github.com/cloudflare/capnweb); [CONTRIBUTING](CONTRIBUTING.md#capabilities-on-the-wire) says how. -## Parts - -The agent is built from parts you can buy and solder: - -- **The box:** a Raspberry Pi 3B with a Google AIY Voice Kit v1 (speaker, two mics, the button), running [NixOS](box/module.nix). -- **The IR emitter:** a Raspberry Pi Pico H with an IR transceiver ([wiring](ir-pico/wiring.md)), on a USB cord from the box, aimed at the equipment. -- **The camera:** an RTSP camera on the LAN, aimed at the TV. -- **Home server:** any Linux machine with Nix and systemd, for speech and the brain; x86_64 with AVX2 is plenty. whisper.cpp's base.en model transcribes an 11 s clip in about 2 s. - ## Make your own -You'll need the parts above, a Linux home server with Nix, and an afternoon. You choose a few names: the box's, your home server's, your Wi-Fi network's. Everything else has a default. The [setup guide](docs/setup.md) walks through it. +I made mine from a [Raspberry Pi and Voice Kit from a 2017 project](https://www.madmode.com/2017/sel4-rpi). The [setup guide](docs/setup.md) covers the parts I used; other suitable parts might be easier to find now. ## License diff --git a/box/system.nix b/box/system.nix index 1845447..d89275b 100644 --- a/box/system.nix +++ b/box/system.nix @@ -1,6 +1,6 @@ # A box's whole system, from a few names: what lib.mkBox adds to the box's services. # name the box's host name -# server the home server's name, where speech and the brain listen +# server the speech server and agent host's name: speech and the brain listen there # wifi the Wi-Fi network the box joins; its PSK goes on the card after imaging (make wifi-secret) # admin who looks after the box, and logs in with sshKeys to deploy { name, server, wifi, admin, sshKeys }: diff --git a/docs/setup.md b/docs/setup.md index fa4424a..73c83e8 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -1,6 +1,19 @@ # Setting up the agent at the TV -You'll need the [parts](../README.md#parts), a Linux home server with Nix and systemd, a private network both it and the box can join (Tailscale, by default), and an afternoon. The steps below are in the order they depend on each other. Each `make` target says more with `make help`. +The steps below are in the order they depend on each other. Each `make` target says more with `make help`. + +## What you need + + +electronics workbench with raspberry pi pico and IR transceiver + + +- **The box:** a Raspberry Pi 3B with a [Google AIY Voice Kit v1](https://aiyprojects.withgoogle.com/voice-v1/) (speaker, two mics, the button). +- **The IR emitter:** a Raspberry Pi Pico H with an IR transceiver ([wiring](../ir-pico/wiring.md)), on a USB cord from the box, aimed at the equipment. +- **The camera:** an RTSP camera on the LAN, aimed at the TV. +- **A speech server and agent host:** any Linux machine with Nix and systemd, on whenever the box is in use. It runs speech and the brain, and builds the box's image. x86_64 with AVX2 is plenty: whisper.cpp's base.en model transcribes an 11 s clip in about 2 s. +- **A private network** that the box, the speech server, and the agent host can all join: Tailscale, by default. +- **An afternoon.** ## 1. Make a repository for your household @@ -16,7 +29,7 @@ A private git repository of your own holds what's yours: the names you choose, a outputs = { self, pdtv26, ... }: { nixosConfigurations.pimote = pdtv26.lib.mkBox { name = "pimote"; # the box's host name on your network - server = "den-pc"; # your home server's host name: speech and the brain + server = "den-pc"; # the speech server and agent host's name wifi = "MyNetwork"; # your Wi-Fi network's name (SSID), spelled exactly admin = "pat"; # who looks after the box, and logs in to deploy sshKeys = [ "ssh-ed25519 AAAA... pat@laptop" ]; @@ -29,9 +42,9 @@ A private git repository of your own holds what's yours: the names you choose, a Ports have defaults, and the box finds the IR emitter by its USB IDs. Anything else about the box's system goes in `modules = [ ./household.nix ]`, alongside: a status page (`pdtv26.box.statusUrl`), another Wi-Fi network, another private network (`pdtv26.box.network`), or no camera (`pdtv26.box.look.enable = false`). -## 2. Set up the home server +## 2. Set up the speech server -Any Linux with systemd and [Nix](https://nixos.org/download/) will do; it needn't be NixOS. Clone pdtv26 there, then: +[Install Nix](https://nixos.org/download/) if it isn't there yet. Clone pdtv26, then: 1. `sudo make -C speech install`: the speech server, its models (about 200 MB), its key, and its systemd unit. 2. `sudo make -C status install BOX=pimote`: the status page, if you want one. @@ -51,11 +64,11 @@ After this, changes to the box go over ssh, from your household repository: `nix ## 4. Join the private network -On the box and the home server: `tailscale up`, or whatever private network you use. +On the box, the speech server, and the agent host: `tailscale up`, or whatever private network you use. ## 5. Make the keys, and start the brain -On the home server, as the user the brain will run as, in pdtv26's `box/`: +On the agent host, as the user the brain will run as, in pdtv26's `box/`: 1. `make keys BOX=pimote ADMIN=pat`: one key per connection, piped to both its ends; the box's ir and look keys come back for the brain. Put the camera's RTSP URL in `~/.config/pdtv26-camera/rtsp-url` first, or skip `rtsp-url`. If speech runs on another host, add `SPEECH=` that host: its key comes over ssh. 2. Make a fine-grained GitHub token for one repository, Issues read/write only, for problem reports, and save it as `~/.config/pdtv26-brain/report-token`.