This is an old revision of the document!
Assistente vocale Mycroft
Installazione
- Scaricare https://mycroft.ai/to/picroft-image
- Estrarre lo zip
- Flashare il file .img sulla sd del raspberry (si può usare balena etcher)
- Aprire terminale nella partizione rootfs della scheda sd:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Aggiungere in fondo al file le credenziali della rete wifi:
network={ ssid="nome rete" psk="password" }
- Salvare e chiudere
- Mettere la scheda sd nel raspberry e avviarlo
- Connettersi via ssh al raspberry:
ssh pi@192.168.0.x
La password di default è “mycroft”
- Saltare la configurazione guidata
- Fare il pairing del device su https://account.mycroft.ai/devices o su un server locale
- Al termine dell'installazione delle skill, chiudere con ctrl+c
Aggiornamento della configurazione
Dal terminale del raspberry:
cd ~ rm .mycroft/mycroft.conf rm .mycroft_cli.conf sudo apt update -y sudo apt upgrade -y sudo apt autoremove -y pip install --upgrade pip cd mycroft-core pip install --upgrade .
Impostare lingua italiana
nano .config/mycroft/mycroft.conf
Aggiungere:
{ ... "lang": "it-it", "system_unit": "metric", "time_format": "full", "date_format": "DMY" // TODO aggiungere "lang": "it-it" al componente tts }
Installazione della scheda audio
Scheda audio modello ReSpeaker 2 Mics Pi HAT (seeedstudio o keyestudio)
- Inserire la scheda respeaker 2-mic nella socket del raspberry
- Collegare un altoparlante all'uscita speaker della scheda
- Dal terminale del raspberry:
deactivate git clone https://github.com/respeaker/seeed-voicecard cd seeed-voicecard sudo ./install.sh
Disattivare la scheda audio integrata:
sudo nano /etc/modprobe.d/raspi-blacklist.conf
Scrivere in fondo al file:
blacklist snd_bcm2835
Chiudere e salvare
Impostare il sample-rate utilizzato da mycroft
sudo nano /etc/pulse/daemon.conf
Scrivere in fondo al file:
default-sample-rate = 48000 alternate-sample-rate = 44100
- Chiudere e salvare
sudo reboot
Test scheda audio
Dal terminale del raspberry
mycroft-stop systemctl --user stop pulseaudio arecord -f cd -Dhw:0 test.wav // Registrare audio, poi premere ctrl+c aplay -Dhw:0 test.wav // Verificare che venga riprodotto l'audio registrato
Regolazione del mixer
Backup della configurazione iniziale:
cd /etc/voicecard sudo cp wm8960_asound.state wm8960_asound.state.save alsamixer
- Premere f6 e selezionare seed-2mic-voicecard
- Premere f5 per mostrare anche il livello del microfono
- Sistemare i volumi (principalmente playback e capture) usando le frecce
- Rendere le modifiche permanenti con:
sudo alsactl -f /etc/voicecard/wm8960_asound.state store sudo reboot
Aprire alsamixer e verificare che le modifiche non siano state cancellate
Nota: il volume di master viene regolato direttamente da mycroft
Skill homeassistant
Dal terminale del raspberry:
pip install quantulum3 mycroft-msm install homeassistant cd ~/mycroft-core/skills/homeassistant.mycroftai git pull
- Creare un long lived access token da home assistant
- Andare su https://home.mycroft.ai/skills (o server locale) e inserire ip di home assistant e token
Installazione DeepSpeech
DeepSpeech è il motore STT di Mozilla
Dal terminale del raspberry:
sudo apt update sudo apt install gfortran libatlas-base-dev libpcap-dev libpq-dev pip install deepspeech==0.9.3 scipy av mkdir deepspeech cd deepspeech curl -LO https://github.com/MozillaItalia/DeepSpeech-Italian-Model/releases/download/2020.08.07/transfer_model_tflite_it.tar.xz tar xvf transfer_model_tflite_it.tar.xz rm transfer_model_tflite_it.tar.xz git clone https://github.com/MainRo/deepspeech-server cd deepspeech-server pip install . cp config.sample.json config.json nano config.json
Aggiungere a config.json:
... "deepspeech": { "model" :"/home/pi/deepspeech/output_graph.tflite", "scorer" :"/home/pi/deepspeech/scorer" }, ...
sudo nano .config/mycroft/mycroft.conf
Aggiungere a mycroft.conf:
... "stt": { "deepspeech_server": { "uri": "http://localhost:8080/stt" }, "module": "deepspeech_server" }, ...
Creare il servizio deepspeech-server
sudo nano /etc/systemd/system/deepspeech-server.service
Scrivere nel file:
[Unit] Description=Deepspeech server [Service] User=pi Type=simple ExecStart=/home/pi/mycroft-core/.venv/bin/deepspeech-server --config /home/pi/deepspeech/deepspeech-server/config.j$ Restart=always RestartSec=3 [Install] WantedBy=multi-user.target
Attivare il servizio:
sudo systemctl enable deepspeech-server sudo systemctl start deepspeech-server
Work in progress