Cov txheej txheem:

Pi-Assistant: 12 Kauj Ruam
Pi-Assistant: 12 Kauj Ruam

Video: Pi-Assistant: 12 Kauj Ruam

Video: Pi-Assistant: 12 Kauj Ruam
Video: Установка Home Assistant Supervised на Debian в 2023 году.Способ подойдет для любого одноплатного ПК 2024, Hlis ntuj nqeg
Anonim
Pi-Pab
Pi-Pab

Nov yog Google Assistant txoj haujlwm siv Raspberry Pi 3 A+ board.

Qhov no yog tsim rau kuv cov tsev kawm qib siab IEEE txoj haujlwm yog li tib neeg yuav txaus siab rau thev naus laus zis thiab tsim khoom.

Kuv yuav mus txawm hais tias kev teeb tsa yooj yim ntawm OS rau raspi, teeb tsa google pabcuam ntawm raspi, thiab pib pib.

Cia pib!

Kauj Ruam 1: Daim Ntawv Teev Npe

Peb yuav siv Raspberry Pi 3 A+ board

Qhov laj thawj siv A+ pawg thawj coj tsuas yog vim kuv yog nws pheej yig dua pawg B thiab kuv xav siv nws txij li nws nyuam qhuav pib.

1x Raspberry Pi 3 A+

1x Micro USB cable (rau lub zog)

1 x ethernet cable

1x USB rau ethernet

1 x USB hub

1 x Microphone

1x Hais Lus

Nws yuav muaj txiaj ntsig yog tias koj tuaj yeem tau txais USB hub + Ethernet chaw nres nkoj cable.

Tsis tas li, koj yuav xav tau lwm lub khoos phis tawj los ua haujlwm ntawm txoj haujlwm no.

Kauj ruam 2: Raspi Teeb

Koj yuav tsum tau nruab Rasbian OS ntawm daim npav SD.

Mus rau https://www.raspberrypi.org/downloads/raspbian/ thiab rub tawm qhov tseeb Rasbian.

MAC: TSO

Siv Etcher thiab hlawv cov ntaub ntawv img ntawm daim npav sd.

*Daim npav SD yuav raug lwv kom ntseeg tau tias yuav thaub qab yog tias xav tau.

Qhov rai:

Siv Rufus thiab hlawv cov ntaub ntawv img ntawm daim npav sd.

*Daim npav SD yuav raug lwv kom ntseeg tau tias yuav thaub qab yog tias xav tau.

Pab kom SSH los ntawm kev tso cov ntaub ntawv npe "ssh" (tsis muaj kev txuas ntxiv) mus rau qhov muab faib ntawm SD daim npav

Yog tias koj yuav siv lub monitor koj tsis tas yuav ua qhov no.

Kauj Ruam 3: Txuas Kho Vajtse

Tam sim no txuas cov hardwares ua ke.

Siv lub hub usb thiab txuas lub mic thiab ethernet cable. Txuas tus neeg hais lus rau hauv 3.5mm lub tso suab tso suab.

Tam sim no txuas lwm sab ntawm ethernet cable rau koj lub khoos phis tawj.

Thaum kawg, ntsaws rau hauv micro usb cable rau raspi.

Kauj ruam 4: Nkag mus rau Raspi

Qhib davhlau ya nyob twg lossis siv putty thiab ssh rau hauv raspi

yam

ssh pib@raspberrypi

Txhawm rau nkag mus li

username: pib

lo lus zais: raspberry

Tam sim no koj nyob hauv raspi!

Koj tuaj yeem mus rau sudo raspi-teeb tsa los hloov tus password thiab txuas rau wi-fi.

Kauj ruam 5: Teeb Suab

Koj yuav tsum tau teeb tsa lub kaw lus suab ntawm raspi kom tuaj yeem siv google tus pab tus qauv piv txwv.

Hom

cov -l

kev -l

thiab sau tus lej npav thiab tus lej ntaus ntawv.

Txog tus hais lus, koj yuav xav xaiv qhov uas hais tias bcm2835 ALSA.

Tom qab ntawd koj yuav ua cov ntawv.asoundrc hauv qab /home /pi

Hom

nano.asoundrc

Tam sim no luam cov kab ntawv hauv qab no thiab hloov tus lej npav thiab tus lej ntaus nrog koj tus lej.

pwm! default {

asym laj

capture.pcm "mic"

playback.pcm "hais lus"

}

pcm.mic {

hom ntsaws

qhev

pcm "hw: tus lej npav, tus lej ntaus ntawv"

}

}

pcm.speaker {

hom ntsaws

qhev

pcm "hw: tus lej npav, tus lej ntaus ntawv"

}

}

Tam sim no siv cov cai hauv qab no txhawm rau sim ua haujlwm ntawm tus hais lus thiab lub mic.

speaker -test -t yav

arecord --format = S16_LE --duration = 5 --rate = 16000 --file-type = raw out.raw

aplay --format = S16_LE --rate = 16000 tawm.raw

Kauj Ruam 6: Nruab SDK thiab Qauv Qauv

Nruab SDK thiab cov qauv piv txwv ntawm raspi los ntawm kev ua cov lus txib no.

Ua ntej koj yuav nruab Python 3

sudo apt-tau hloov tshiab

sudo apt-tau nruab python3-dev python3-venv # Siv python3.4-venv yog tias pob tsis tuaj yeem pom.

python3 -m venv env

env/bin/nab hab sej -m pip nruab -hloov kho pip setuptools log

qhov chaw env/bin/qhib

Tau txais Google Assistant pob

sudo apt-tau nruab portaudio19-dev libffi-dev libssl-dev libmpg123-dev

nab hab sej -m pip nruab-hloov kho google-assistant-library

nab hab sej -m pip nruab-hloov kho google-assistant-sdk [kuaj]

Kauj Ruam 7: Sau Koj Tus Pabcuam Pi

Koj yuav tsum tau sau npe koj txoj haujlwm thiab lub cuab yeej kom muaj peev xwm siv Google Assistant.

Kauj ruam txawm tias cov lus qhia hauv qab no.

1. Pab kom Google Assistant API

a Qhib qhov Action Console

b. Nyem rau Ntxiv/ntshuam qhov project.

c. Tsim ib txoj haujlwm tshiab, ntaus lub npe hauv lub npov Project npe thiab nyem CREATE PROJECT.

d. Nyem Ntaus ntawv sau npe nyob ze rau hauv qab ntawm nplooj ntawv.

e. Pab kom Google Assistant API

Mus rau qhov txuas thiab Nyem Enable.

f. Koj yuav tsum teeb tsa OAuth kev tshuaj ntsuam pom zoo rau koj txoj haujlwm hauv Cloud Platform Console.

2. Rov qhib Action Console txhawm rau sau npe tus qauv ntaus ntawv.

a Sau cov ntaub ntawv

b. Thaum koj ua tiav Nyem Sau Tus Qauv

c. Tom ntej no koj yuav rub tawm daim ntawv pov thawj

Koj tseem yuav xav tau muab cov ntawv no tso rau ntawm raspberry pi

Txhawm rau ua qhov no, koj tuaj yeem ntaus cov lus txib hauv lub davhlau ya nyob twg (hloov cov neeg siv-id nrog koj tus kheej daim npav)

scp ~/Downloads/client_secret_ client-id.json pi@raspberrypi-ip:/home/pi/Download

d. Koj tuaj yeem hla qhov tshwj xeeb cov yam ntxwv

e. Yog tias koj hloov tus qauv koj yuav tsum rov rub dua qhov kev ntseeg siab

Kauj Ruam 8: Tsim Cov Ntawv Pov Thawj

Nruab lossis hloov kho cov cuab yeej tso cai:

python -m pip install-upgrade google-auth-oauthlib [cuab yeej]

Tsim cov ntaub ntawv pov thawj kom muaj peev xwm khiav cov qauv piv txwv thiab cov cuab yeej. Siv JSON cov ntaub ntawv koj rub tawm hauv ib qib dhau los; tej zaum koj yuav tsum tau luam nws lub cuab yeej. Tsis txhob rename cov ntaub ntawv no.

google-oauthlib-tool -scope https://www.googleapis.com/auth/assistant-sdk-prototype / --scope https://www.googleapis.com/auth/gcm / --save --headless- -client-secrets /path/to/client_secret_client-id.json

Kauj Ruam 9: Sim Cov Qauv Piv Txwv

Tam sim no koj tuaj yeem khiav qhov program piv txwv.

Txhawm rau ua qhov no khiav cov lus txib hauv qab no hloov pauv my-dev-project thiab kuv tus qauv

googlesamples-assistant-hotword-project-id my-dev-project --device-model-id my-model

Thaum nws pib khiav sim

Hav Google, huab cua zoo li cas?

Lub sijhawm twg?

Yog tias nws ua rau koj yuam kev txog lub suab sim thiab khiav cov lus txib no

sudo apt-tau nruab matrixio-creator-xxxx

Kauj ruam 10: Teeb Autostart: Tsim Tsab Ntawv

Txhawm rau ua kom raspi tuaj yeem pib siv google tus pabcuam software, peb yuav kho cov ntaub ntawv pib pib.

Ua ntej tshaj sau tsab ntawv hu ua google_autostart.sh

nano google_autostart.sh

Tom qab ntawd koj yuav ntaus

#!/bin/tsoo

qhov chaw env/bin/qhib

google-pab-demo &

& qhov kawg ntawm kab yuav ua rau software khiav ntawm keeb kwm yav dhau.

Thaum koj ua ib tsab ntawv, cov ntaub ntawv yuav tsis muaj kev tso cai ua.

Koj tuaj yeem tshawb xyuas los ntawm kev khiav

ls -l google_autostart.sh

nws yuav tsum ua rau koj nrog

-rw-r-r-- l pi pi hnub tim google_autostart

Txhawm rau muab tsab ntawv no tso cai ua cov ntawv sau

sudo chmod +x google_autostart.sh

Tam sim no yog tias koj txheeb xyuas cov ntawv xim ntawm.sh ntawv yuav tsum hloov pauv thiab hais

-rwxr-xr-x l pi pi hnub tim google_autostart.sh

Sim thiab yog tias nws ua haujlwm koj ua tiav tsim cov ntawv sau kom pib pib google tus pab.

./google_autostart.sh

Kauj ruam 11: Teeb Autostart: Teeb Tsab Ntawv rau Autostart

Tam sim no koj yuav tsum teeb tsa cov ntawv hauv kom pib ua cov ntaub ntawv hauv raspi.

Mus rau

/etc/xdg/lxsession/LXDE-pi/

ces

nano autostart pib

hauv cov ntawv, ntxiv cov npe thiab cov ntaub ntawv cov ntawv ntawm kab kawg.

/home/pi/google_autostart.sh

Tam sim no koj yuav tsum tuaj yeem tshem lub ethernet cable thiab tsuas yog muaj tus hais lus, mic thiab lub zog ntawm usb thiab google pabcuam software yuav tsum tau pib ua haujlwm.

Kauj Ruam 12: Ntxiv

Cov lus qhia peb mus tab sis ntawm no tsuas yog rau qhov yooj yim Google tus qauv piv txwv.

Koj tuaj yeem hloov kho software los ntawm kev txhim kho cov tsev qiv ntawv sib txawv.

Qhov txuas hauv qab no yuav ntxiv koj pi-pab me ntsis ntxiv fetures

github.com/googlesamples/assistant-sdk-pyt…

Yog tias koj teeb tsa Google Cast SDK koj yuav muaj peev xwm ua tej yam zoo li

Ok Google, ua si Spotify

Koj tseem tuaj yeem siv google tus pabcuam thiab lwm tus pin thiab chaw nres nkoj ntawm raspi los ua ntau yam

zoo li tswj LEDs, Cov Motors, thiab txhua yam uas koj tuaj yeem xav txog !!!

Pom zoo: