Cov txheej txheem:

Google Assistant ntawm Raspberry Pi Txoj Kev Yooj Yim: 15 Cov Kauj Ruam
Google Assistant ntawm Raspberry Pi Txoj Kev Yooj Yim: 15 Cov Kauj Ruam

Video: Google Assistant ntawm Raspberry Pi Txoj Kev Yooj Yim: 15 Cov Kauj Ruam

Video: Google Assistant ntawm Raspberry Pi Txoj Kev Yooj Yim: 15 Cov Kauj Ruam
Video: 10 самых АТМОСФЕРНЫХ мест Дагестана. БОЛЬШОЙ ВЫПУСК #Дагестан #ПутешествиеПоДагестану 2024, Kaum ib hlis
Anonim
Google Assistant ntawm Raspberry Pi Txoj Kev Yooj Yim
Google Assistant ntawm Raspberry Pi Txoj Kev Yooj Yim

Google Assistant ON Raspberry Pi

Yog li no txhua qhov ua tau li cas?

Ib ntus dhau los Google tau tshaj tawm ua-nws-koj tus kheej AI cov khoom siv nrog teeb meem #57 ntawm The Magpi. Qhov no ua rau nws yooj yim heev los tsim koj li Google tus pab cuam txawm li cas los xij tuav cov khoom siv suab tau nyuaj me ntsis thiab, hauv ntau qhov chaw, nws tau muag tawm hauv cov sijhawm. Qhov no txhais tau tias peb tsis xav tau luam theej tawm ntawm The Magpi kom tau txais txiaj ntsig ntawm txhua qhov kev ua haujlwm nyuaj. uas tau xa nrog nws. Hloov chaw, feem ntau ntawm cov kev qhia sim txhawm rau txhim kho txhua yam los ntawm kos feem ntau ua rau muaj kev cuam tshuam ntawm cov cai uas tsis tuaj yeem ua raws rau Ntau Tus Neeg.

Khoom siv

Dab tsi yuav tsum tau?

Txhawm rau ua kom tiav txoj haujlwm no tiav koj yuav xav tau cov hauv qab no:

· Raspberry Pi (Txhua Tus Qauv)

· Ib tus neeg hais lus yooj yim nrog 3.5 hli txuas txuas

· USB microphones

· Mouse thiab keyboard

Kauj ruam 1: Formatting SD Card

Formatting SD Card
Formatting SD Card

Thawj qhov uas peb yuav tsum tau ua yog los teeb tsa peb daim npav SD. Cia peb siv SD Lub Koom Haum Cov Qauv Txheej Txheem uas tau pom zoo los ntawm nom Raspberry Pi Foundation.

Thaum tau teeb tsa, tso daim ntawv thov thiab nyem 'Kev Xaiv' Koj yuav tsum hloov qhov kev xaiv rau 'FORMAT SIZE ADJUSTMENT' rau 'ON'.

Tam sim no nyem 'OK' thiab tshawb xyuas ob zaug tias peb tab tom teeb tsa lub tsav kom raug, tom qab ntawd nyem 'Format'. Qhov no yuav tsum tsis siv sijhawm ntev, tsuas yog tos rau qhov kev lees paub tias lub tshuab tsav tau ua tiav zoo ua ntej koj txav mus rau kauj ruam tom ntej.

Kauj ruam 2: Npaj SD Card

Npaj SD Card
Npaj SD Card

Tom ntej no peb yuav tsum tau

rub lub Suab Khoom microSD daim npav duab rau Raspberry Pi. Koj tuaj yeem rub daim duab los ntawm

Txhawm rau hloov cov duab uas peb nyuam qhuav rub mus rau peb daim npav SD peb yuav siv qhov program hu ua Etcher.io. Nws yog pub dawb, qhib qhov chaw thiab tsis xav tau kev teeb tsa.

Thaum koj tau rub tawm Etcher, khiav qhov program thiab koj yuav tsum pom lub vijtsam zoo li ib qho saum toj no. Nws tuaj yeem siv sijhawm ib lossis ob feeb los thauj khoom yog tias nws tsis thauj tam sim ntawd ua siab ntev.

Nyem 'Xaiv duab' thiab mus rau lub suab khoom duab uas peb nyuam qhuav rub tawm (aiyprojects-2017-05-03.img). Thaum xaiv ob zaug kos uas koj tau sau cov ntsiab lus mus rau qhov tseeb disk. Piv txwv tias peb muaj lub disk raug xaiv xaiv ces nyem 'Flash!'.

Nws tuaj yeem siv sijhawm li 20 feeb lossis ntau dua los sau cov duab rau koj daim npav SD

Kauj Ruam 3: Txuas Txhua Qhov Raws Li Mus Rau Chaw Nres Nkoj

Txuas Txhua Qhov Raws Li Mus Rau Chaw Nres Nkoj
Txuas Txhua Qhov Raws Li Mus Rau Chaw Nres Nkoj

Txuas tag nrho Cov Khoom Siv Xav Tau Xws Li Lub Mic, Hais Lus Etc

Raws li Pinouts Qhia Saum Toj Saum

Kauj Ruam 4: Hwj Chim Li Pi

Hwj chim Li Pi!
Hwj chim Li Pi!
Hwj chim Li Pi!
Hwj chim Li Pi!

Sai li daim npav SD tau npaj tiav peb tuaj yeem tso daim npav microSD rau hauv peb Raspberry Pi. Txog tam sim no peb tseem yuav tsum txuas peb lub zog coj, HDMI cable, keyboard, nas, saib, hais lus thiab USB microphone.

Nrog lub zog txuas txuas txuas tso cai rau koj Raspberry Pi kom khau raj thiab koj yuav sai sai no nthuav tawm nrog tus qauv Pixel desktop.

Kauj Ruam 5: Pib Kho Kho

Thawj Kev Kho
Thawj Kev Kho
Thawj Kev Kho
Thawj Kev Kho
Thawj Kev Kho
Thawj Kev Kho

Lob koj tus cursor thiab mus rau Raspberry Pi logo nyob rau sab laug sab saum toj ntawm koj lub vijtsam. Los ntawm qhov nco cia xaiv 'Nyiam' thiab tom qab ntawd 'Raspberry Pi Configuration'. Tom ntej no, mus rau 'Interfaces' thiab pab kom 'SSH'.

Tam sim no nyem rau ntawm WiFi logo nyob rau sab xis saum toj ntawm lub vijtsam thiab xaiv koj li WiFi network. Yog tias koj li WiFi tau tiv thaiv tus password koj yuav raug hais kom nkag mus rau hauv. Tus zuam ntsuab lees paub tias peb tau txuas nrog ua tiav thiab peb tau npaj txav mus rau kauj ruam tom ntej

Kauj Ruam 6: Hloov kho Kev Txhim Kho

Hloov kho Kev Txhim Kho
Hloov kho Kev Txhim Kho

Qhov no yog hais txog qib siab raws li qhov kev qhia no tau txais. Peb mus

siv lub davhlau ya nyob twg dev los hloov kho Google Assistant SDK, Project Kit & dependencies kom ntseeg tau tias peb muaj cov kho tshiab kawg. Tsis txhob poob siab yog tias tsis muaj ib qho ntawm no ua rau koj nkag siab ntau tab sis nws yog qhov tseem ceeb uas peb tsis hla qhov kauj ruam no. Tsuas yog ua raws li qhov kev qhia no hais tias ua tib zoo saib xyuas kom tsis txhob ua yuam kev thiab nws txhua yam yuav ua haujlwm zoo xwb. Yog li, ntshai dhau, cia pib! Ob npaug nyem rau ntawm lub desktop duab lub npe 'Pib dev davhlau ya nyob twg' Koj yuav tsum pom qhov txaus ntshai saib dev davhlau ya nyob twg qhov rai

Tom ntej no ntaus cov lus txib hauv qab no rau hauv lub davhlau ya nyob twg raws li lawv tshwm hauv qab no. Muaj 9 cov lus txib ntawm no thiab txhua tus yuav tsum tau nkag cais hauv qhov kev txiav txim uas lawv tshwm sim. Tom qab ntaus txhua kab lus txib ntaus 'Nkag mus' ntawm koj cov keyboard ua ntej txav mus rau qhov tom ntej. Qee qhov lus txib yuav siv ob peb feeb los ua kom tiav yog li ua siab ntev tos txhua qhov kom ua tiav ua ntej txav mus rau qhov tom ntej.

cd ~/pab-sdk-nab hab sej

git checkout tswv

git rub keeb kwm tus tswv

cd ~/lub suab-lees paub-raspi

git checkout tswv

git rub keeb kwm tus tswv

cd ~/lub suab-lees paub-raspi

rm -rf kev

scripts/install-deps.sh

Kauj Ruam 7: Npaj Cov Txheej Txheem Cov Ntaub Ntawv

Npaj Cov Ntaub Ntawv Kho
Npaj Cov Ntaub Ntawv Kho

Tom ntej no peb yuav tsum tau thaub qab peb cov ntaub ntawv teeb tsa uas twb muaj lawm thiab coj mus rau qhov tshiab tshaj plaws uas nyuam qhuav hloov tshiab. Nov yog 4 cov lus txib ntxiv rau koj kom ua li ntawd. Cov no tuaj yeem ua tiav hauv tib lub davhlau dev uas peb tsuas yog siv. Ib zaug ntxiv, lawv yuav tsum tau ua tiav hauv qhov kev txiav txim no thiab yuav tsum raug ntaus kom raug raws li lawv pom hauv qab no:

cp ~/.config/xwm txheej-led.ini ~/.config/xwm txheej-led.ini ~

cp ~/.config/lub suab-recognizer.ini ~/.config/lub suab-recognizer.ini ~

cp ~/lub suab-lees paub-raspi/teeb tsa/xwm txheej-led.ini.default ~/.config/xwm txheej-led.inicp ~/lub suab-lees paub-raspi/teeb tsa/lub suab-recognizer.ini.default ~/.config/ lub suab-recognizer.ini

Kauj Ruam 8: Teeb tsa Lo Lus Kub

Teeb tsa lo lus Hotword
Teeb tsa lo lus Hotword
Teeb tsa lo lus Hotword
Teeb tsa lo lus Hotword

Ua haujlwm zoo heev txog tam sim no! Peb tau nyob ze tam sim no yog li dai rau ntawd.

Tam sim no peb yuav tsum hloov qhov txhais rau peb cov cuab yeej Google AIY kom nws teb rau peb lub suab thaum peb hais cov lus 'OK Google'. Ntaus cov lus txib hauv qab no rau hauv lub davhlau dev:

nano ~/.config/lub suab-recognizer.ini

Qhov no yuav tsim lub qhov rai no txawm tias tsawg dua. Hauv lub qhov rai tshiab no, saib rau cov cai hauv qab no:

# Xaiv tus txhais: gpio (default), npuaj teg, ok-google.

# trigger = npuaj teg

Peb yuav tsum hloov txoj cai no rau:

# Xaiv tus txhais: gpio (default), npuaj teg, ok-google.

txhais = ok-google

Yog tias koj siv cov xub tuav ntawm koj cov keyboard koj yuav pom tus curser tshwm. Siv cov xub xub, coj tus curser nqes mus rau kab ntawv uas peb tab tom sim hloov. Siv tus yuam sij backspace ntawm koj cov keyboard rho tawm kab ntawm kab ntawv uas peb tab tom sim hloov thiab sau nws ib yam li cov piv txwv saum toj no. Daim ntawv ceeb toom tias kuv tseem tau tshem tus cim #, nws yog qhov tseem ceeb uas peb tsis suav nrog # hauv kab ntawv kab ntawv tshiab no. Kuv tau txuas ua ntej thiab tom qab screenshot ntawm qhov no yuav tsum zoo li cas (encase Kuv poob koj nyob ntawd). Piv txwv tias koj lub qhov rais zoo nkaus li zoo li kuv li peb tuaj yeem kaw thiab khaws cov kev hloov pauv. Tuav 'Ctrl' ntawm koj cov keyboard thiab nias 'X' kom kaw lub qhov rais. Peb yuav tom qab ntawd kom txuag qhov kev hloov pauv peb tau ua, nias 'Y' thiab tom qab ntawd ntaus 'Enter' ntawm koj cov keyboard. Tam sim no lub qhov rais yuav kaw thiab cov kev hloov pauv tau raug cawm. Txhawm rau kom ntseeg tau tias cov kev hloov pauv tau cuam tshuam peb yuav tsum rov pib ua haujlwm. Ntaus cov lus txib hauv qab no rau hauv lub qhov rai qhov rai thiab ntaus 'Enter':

sudo systemctl rov pib dua lub suab-lees paub.service

Kauj ruam 9: Suab Kho (Tshooj 1)

Suab Kho (Tshooj 1)
Suab Kho (Tshooj 1)

Tam sim no Google Assistant muaj ntau dua lossis muaj sia nyob thiab npaj ua haujlwm.. Zoo siab!

Txawm li cas los xij, ua ntej koj zoo siab heev, koj tsis tuaj yeem hnov ib leeg. Qhov ntawd yog vim tias Google AIY Project Image tau teeb tsa los ua haujlwm nrog kho vajtse uas tau xa nrog cov khoom siv. Txij li thaum peb tab tom siv tus qauv aux hais lus thiab usb microphone peb yuav tsum tau tweak qee qhov kev teeb tsa. Ib zaug ntxiv peb yuav siv tib lub davhlau ya nyob twg qhov rai, lub sijhawm no:

sudo leafpad /boot/config.txt

Qhov no yuav qhib cov ntawv qhov rai. Nkag mus rau hauv qab ntawm daim ntawv tshaj plaws thiab tshem tawm # nyob rau pem hauv ntej kab kab dtparam = audio = on thiab ntxig rau # nyob rau pem hauv ntej ntawm ob kab hauv qab nws.

# Pab kom lub suab (thauj khoom snd_bcm2835)

dtparam = audio = on

#dtoverlay = i2s-mmap

#dtoverlay = googlevoicehat-soundcard

Kuv kuj tau txuas lub vijtsam los qhia koj tias qhov no yuav zoo li cas. Mus rau 'Cov Ntaub Ntawv' ces nyem 'Txuag. Tam sim no koj tuaj yeem kaw daim ntawv.

Kauj ruam 10: Suab Kho (Ntu 2)

Suab Kho (Tshooj 2)
Suab Kho (Tshooj 2)

Rov qab rau hauv lub davhlau ya nyob twg dev dua, ntaus:

sudo leafpad /etc/asound.conf

Thaum koj ntaus 'Enter' ib daim ntawv tshiab yuav qhib. Lub sijhawm no tshem tawm TXHUA cov ntawv hauv daim ntawv thiab hloov nws nrog cov hauv qab no:

pwm! default {

asym laj

capture.pcm "mic"

playback.pcm "hais lus"

}

pcm.mic {

hom ntsaws

qhev

pwm "hw: 1,0"

}

}

pcm.speaker {

hom ntsaws

qhev

pcm "hwv: 0, 0"

}

}

Ib zaug ntxiv kuv tau txuas lub vijtsam uas qhia koj tias qhov no yuav zoo li cas. Nws rov txuag thiab kaw cov ntawv. Tam sim no nws yog lub sijhawm rov pib dua koj li Raspberry Pi. Nyem rau ntawm Raspberry Pi logo nyob rau sab laug sab saum toj ntawm koj lub vijtsam thiab nyem rau 'Shutdown' ces 'Reboot'. Tom qab koj tau rov pib dua Pi peb tsuas muaj ib qho tweak ntxiv los ua. Ob npaug nias rau ntawm 'Pib dev davhlau ya nyob twg' icon dua thiab ntaus cov hauv qab no:

leafpad /home/pi/voice-recognizer-raspi/checkpoints/check_audio.py

Hauv daim ntawv kawg no koj yuav tsum nrhiav kab ntawm kab ntawv uas nyeem:

VOICEHAT_ID = 'googlevoicehat'

Hloov qhov no mus rau: VOICEHAT_ID = 'bcm2835'

Thaum koj tau ua cov kev hloov pauv no, ib yam li peb tau ua ua ntej, txuag tom qab kaw cov ntawv no.

Kauj Ruam 11: Kuaj Lub Suab

Xeem Lub Suab
Xeem Lub Suab

Ntawm lub desktop muaj cov ntawv hu ua 'Check audio'. Nyem ob npaug rau qhov no thiab ua raws cov lus qhia kom ntseeg tau tias ob qho tib si hais lus thiab microphone ua haujlwm.

Yog tias koj ua raws li Cov Lus Qhia no kom raug yuav tsum tsis muaj teeb meem. Txawm li cas los xij yog tias koj tsis tuaj yeem hnov dab tsi, rov xyuas ob zaug tias lub ntim tau qhib thiab koj li Raspberry Pi siv 'Analog' rau lub suab tso tawm. Koj tuaj yeem ua qhov no los ntawm txoj cai-txhaj rau lub cim lub suab nyob rau sab saum toj ntawm lub vijtsam. 'Analog' yuav tsum tau zuam ib yam li cov piv txwv hauv lub screenshot. Piv txwv tias koj dhau qhov kev kuaj lub suab, peb tuaj yeem txav mus rau theem tom ntej

Kauj Ruam 12: Txuas rau Huab

Txuas mus rau Huab
Txuas mus rau Huab

Ua ntej Google Assistant yuav muab peb cov lus teb rau lub neej cov lus nug hlawv peb xav tau txuas nws mus rau Google Cov Kev Pabcuam Huab.

Qhov no yooj yim ua tab sis yog tias koj tsis tau nyob hauv huab ua ntej ces nws yuav zoo li txaus ntshai me ntsis thaum xub thawj. Nov yog yam peb yuav tsum tau ua:

1) Ntawm Raspberry Pi qhib lub Chrome internet browser thiab mus rau Cloud Console:

2) Nkag mus nrog tus lej Google uas twb muaj lawm lossis sau npe yog tias koj tsis muaj.

3) Tsim txoj haujlwm tshiab thiab muab lub npe rau nws. Kuv hu kuv li 'Google Pi'

4) Siv qhov bar tshawb nrhiav pib ntaus ntawv 'Google Assistant' thiab koj yuav tsum pom 'Google Assistant API'. Nyem rau nws thiab tom qab ntawd thaum nplooj ntawv txuas ntxiv mus nyem 'Pab kom' qhib lub API.

5) Mus rau 'API Tus Thawj Coj' tom qab ntawd 'Ntawv Pov Thawj' thiab tsim 'OAuth 2.0 tus neeg siv khoom'.

6) Nyem rau 'Tsim daim ntawv pov thawj' thiab xaiv 'OAuth tus lej ID'. Yog tias koj tsis tau nyob hauv huab ua ntej ces tam sim no koj yuav raug hais kom teeb tsa koj li kev tso cai. Koj yuav tsum tau npe koj li app, Kuv hu kuv li 'Raspberry Pi'. Tag nrho lwm qhov chaw tuaj yeem tsis muaj dab tsi.

7) Hauv Daim Ntawv Pov Thawj Muaj Peev Xwm, nrhiav koj daim ntawv pov thawj tshiab thiab nyem lub cim rub tawm ntawm sab xis.

8) Tam sim no chrome browser yuav rub tawm ib daim ntawv JSON me me nrog rau tag nrho koj cov ntaub ntawv pov thawj khaws ruaj ntseg sab hauv. Nrhiav cov ntawv no thiab hloov nws mus rau 'assistant.json' ces txav nws mus /home/pi/assistant.json.

9) Thaum kawg, mus rau nplooj ntawv Kev Tswj Xyuas Haujlwm: https://console.cloud.google.com/ thiab qhib cov kev pabcuam hauv qab no: Web thiab app kev ua ub no, keeb kwm qhov chaw, Cov ntaub ntawv ntawm lub cuab yeej, Lub suab thiab lub suab ua haujlwm.

Nco ntsoov nkag mus nrog tib tus lej Google zoo li ua ntej! Yog tias koj tau nyam ntawm ib qho twg thaum lub sijhawm no, tsis txhob txaj muag, Google tau ua tiav txoj haujlwm zoo ntawm kev sau cov txheej txheem no nrog cov duab ntxig rau txhua qib hla ntawm Google AIY Kit lub vev xaib.

Kauj Ruam 13: Xeem Kawg

Xeem Kawg
Xeem Kawg

Yog tias txhua yam tau teeb tsa kom raug hauv huab peb tam sim no tau npaj los tham nrog Google.

Siv qhov 'Pib dev davhlau ya nyob twg' lub qhov rai hais kom ua dua, ntaus cov hauv qab no:

src/main.py cov

Qhov no yuav sawv los pab peb tab sis vim qhov no yog thawj zaug uas peb txuas rau Google Cov Kev Pabcuam, lub vev xaib yuav qhib thiab koj yuav tsum tau nkag mus rau Google kom tso cai rau Raspberry Pi nkag mus rau Google Assistant API. Ib zaug ntxiv kom ntseeg tau tias koj siv tib tus lej Google tus lej nkag mus ib yam li koj tau ua dhau los. Thaum koj tau nkag mus ua tiav thiab tso cai tso cai koj yuav raug hais kom kaw lub qhov rai. Lub qhov rai hais kom ua tam sim no zoo li lub screenshot txuas nrog lees paub tias txhua yam tau teeb tsa kom raug. Mus tom ntej, nug ib lo lus nug, nws mloog! Ua ntej koj yuav zoo siab heev txawm hais tias, peb tseem tsis tau tiav. Thaum koj ua tiav kev ua si, kaw lub qhov rais, ua qhov no tsuas yog siv tus ntoo khaub lig dawb nyob rau sab xis saum toj ntawm lub qhov rais.

Kauj Ruam 14: Teeb Google Assistant ntawm Kev Pib

Teeb Google Assistant ntawm Kev Pib
Teeb Google Assistant ntawm Kev Pib

Kuv tau cog lus rau koj tias peb Google Assistant yuav pib ua haujlwm thaum peb txhawb nqa Raspberry Pi.

Txhawm rau ua qhov no, qhib lub qhov rai hais kom ua tshiab siv lub cim 'Pib dev davhlau ya nyob twg' ntawm lub desktop.

Ntaus kab kab hauv qab no rau hauv koj lub qhov rai qhov rai thiab ntaus 'Enter' ntawm koj cov keyboard:

sudo systemctl pab lub suab-lees paub

Peb tsuas yog teeb tsa pib pib ntawm peb Google Assistant nrog ib kab ntawm txoj cai.. Qhov ntawd yooj yim npaum li cas !!

Kauj Ruam 15: Kab Kawg

Kab Kawg
Kab Kawg

Tam sim no koj tau ua tiav txhua cov kauj ruam mus tom ntej thiab rov pib dua koj li Raspberry Pi. Yog tias koj tau ua raws txhua cov lus qhia ua tib zoo ces Google Assistant yuav tsum tau khiav hauv keeb kwm yav dhau thaum Pi thauj khoom. Sim nws, hais OK Google kom nws tsa nws thiab nug nws txhua yam uas koj nyiam!

Pom zoo: