96 lines
3.3 KiB
Markdown
96 lines
3.3 KiB
Markdown
Dog Trainer
|
|
===========
|
|
|
|
A device that allows dogs to speak. Click on the picture to see the video with the `dog-trainer` in action
|
|
|
|
[](https://peertube.virtonline.eu/w/hjq33b6N4GuXWMe45GYTtA)
|
|
|
|
Hardware
|
|
--------
|
|
- Raspberry pi (any version with an USB port) e.g. [Raspberry Pi Model B+](https://hackerboards.com/board/raspberry-pi-foundation-raspberry-pi-model-b-plus)
|
|
|
|
- Buttons connected to the Raspberry pi GPIO as shown in the schema to debounce noisy contacts
|
|

|
|
|
|
- USB speaker with a microphone e.g. [Jabra Speak 410](https://www.jabra.com/_/media/Jabra_VXi_Product-Documentation/Jabra-SPEAK-410-Series/technical-specifications/RevB/Jabra-Speak-410-Techsheet-A4-290420-Web.pdf)
|
|
|
|
- microSD card 8GB
|
|
|
|
- USB power supply 5V 500mA
|
|
|
|
Operating system
|
|
----------------
|
|
Install [Raspberry Pi Imager](https://www.raspberrypi.com/news/raspberry-pi-imager-imaging-utility/) into your notebook. Launch it and choose `Raspberry Pi OS Lite` to write into the microSD card
|
|
|
|
Power on the Raspberry pi and finish the installation process. Log into its console using either:
|
|
- ethernet/wifi from your notebook: `ssh pi@raspberrypi`
|
|
- connected keyboard and monitor
|
|
- serial port
|
|
|
|
How to install
|
|
--------------
|
|
|
|
Once you are logged into the `Raspberry pi` console clone the `dog-trainer` source code into your home directory
|
|
> `git clone https://gitea.virtonline.eu/2HoursProject/dog-trainer.git --depth 1`
|
|
|
|
Go into the newly created directory
|
|
> `cd ~/dog-trainer`
|
|
|
|
Dependencies
|
|
------------
|
|
|
|
The recordings must be edited a little bit so some audio processing tool is needed. Install `ffmpeg` which will do the job
|
|
> `apt install -y ffmpeg`
|
|
|
|
Configuration
|
|
-------------
|
|
|
|
First try using default audio device for playback and recording. Edit `dog-trainer.py` and activate `PLAY_DEVICE="default"` and `REC_DEVICE="default"`
|
|
> `nano dog-trainer.py`
|
|
|
|
Skip to the next section `Run it!`. If either playback or recording does not work check your sound cards
|
|
> `aplay -L | grep ^hw:CARD=`
|
|
|
|
If your sound device is other then `USB` then change the line `card USB` in ALSA config
|
|
> `nano .asoundrc`
|
|
|
|
Install the ALSA config file
|
|
> `mv .asoundrc ~/`
|
|
|
|
Run it!
|
|
-------
|
|
|
|
Just run
|
|
> `python3 dog-trainer.py`
|
|
|
|
Pres `Ctrl+c` to exit
|
|
|
|
Make it a service to automaticaly start and run in the backgroud
|
|
------------------------------------------------------
|
|
|
|
If your `$HOME` directory is other then `/home/pi` then modify the systemd service file
|
|
> `sed -i "s#/home/pi#$HOME#g" dog-trainer.service`
|
|
|
|
If your username and group is other then `pi` and `pi` then also run
|
|
> `sed -i "s#User=pi#User=$USER#" dog-trainer.service`
|
|
`sed -i "s#Group=pi#Group=$(id -gn)#" dog-trainer.service`
|
|
|
|
Install the systemd service file
|
|
> `sudo mv dog-trainer.service /etc/systemd/system/`
|
|
|
|
Reload systemd manager configuration
|
|
> `systemctl daemon-reload`
|
|
|
|
Enable the `dog-trainer` service at boot time and also run it
|
|
> `systemctl enable --now dog-trainer`
|
|
|
|
If it does not work check logs
|
|
> `journalctl -f -u dog-trainer`
|
|
|
|
Set volume for playback and recording
|
|
-------------------------------------
|
|
|
|
Launch soundcard mixer
|
|
> `alsamixer`
|
|
|
|
Press F6 to select a soundcard. Find your USB sound device in the list e.g. `Jabra Speak 410 USB`. Press F4 and use up/down arrow keys to set recording volume and repeat also for the playback (F3). Press ESC fo exit. |