This is a simple script that forwards keyboard input from a Raspberry Pi to a usb connected computer. Plans to also forward speech-to-text recorded on the pi to the connected computer.
This script is intended to be run on a Raspberry Pi. It has been tested on a Raspberry Pi 4 running Raspbian Bullseye.
- python3
- python3-pip
- python3-venv
- evdev
- Clone this repository
- Create a virtual environment
python3 -m venv venv
- Activate the virtual environment
source venv/bin/activate - Install dependencies
pip install -r requirements.txt
- Run the script
python3 main.py
To have the script run automatically on startup, you can use a systemd service.
-
Create a new service file in
/etc/systemd/system/with a.serviceextension. For example,pi-keyboard-forwarder.service.sudo nano /etc/systemd/system/pi-keyboard-forwarder.service
-
In the service file, add the following:
[Unit] Description=Pi Keyboard Forwarder [Service] ExecStart=/path/to/your/venv/bin/python3 /path/to/your/script/main.py WorkingDirectory=/path/to/your/script/ User=pi Restart=always [Install] WantedBy=multi-user.target
Replace
/path/to/your/venv/and/path/to/your/script/with the actual paths to your virtual environment and script. -
Save and close the file.
-
Enable the service to start on boot:
sudo systemctl enable pi-keyboard-forwarder -
Start the service:
sudo systemctl start pi-keyboard-forwarder
-
Check the status of the service:
sudo systemctl status pi-keyboard-forwarder
Now, the script should start automatically every time your Raspberry Pi boots up.
- Connect the Raspberry Pi to the computer via USB-C power-port on the Raspberry Pi.
- This will power the Raspberry Pi and allow it to communicate with the computer.
- You may get a low-voltage warning on the Raspberry Pi, this may be an issue but I have no idea. 🤷
- Plug a USB keyboard into the Raspberry Pi.
- Plug a USB microphone into the Raspberry Pi.
Thanks to tiny-pilot for doing the hard work of getting the this working. This is a simplification of their work, with the goal of reducing complexity for a simpler use case of keyboard and speech-to-text forwarding.