Cov txheej txheem:

Tswj Lub Ntiaj Teb Nrog Google AIY: 8 Kauj Ruam
Tswj Lub Ntiaj Teb Nrog Google AIY: 8 Kauj Ruam

Video: Tswj Lub Ntiaj Teb Nrog Google AIY: 8 Kauj Ruam

Video: Tswj Lub Ntiaj Teb Nrog Google AIY: 8 Kauj Ruam
Video: Lub Zog Nruab Nrog (Hmong Dubbed) 2024, Hlis ntuj nqeg
Anonim
Tswj Lub Ntiaj Teb Nrog Google AIY
Tswj Lub Ntiaj Teb Nrog Google AIY

Google AIY Projects Voice kit tuaj dawb nrog lub Tsib Hlis 2017 luam tawm ntawm The MagPi, thiab tam sim no koj tseem tuaj yeem yuav nws los ntawm ntau tus neeg siv khoom siv hluav taws xob.

Yam koj yuav kawm

  • Yuav ua li cas txuas lub LED mus rau AIY Lub Suab Khoom
  • Yuav ua li cas rho tawm cov ntaub ntawv los ntawm lub suab txib
  • Yuav ua li cas txhawm rau GPIO koob siv suab lus txib

Kauj Ruam 1: Koj Yuav Xav Li Cas?

Kho vajtse

  • Ib lub computer Raspberry Pi
  • Google AIY Voice Kit
  • LED2 x txiv neej-poj niam jumper coj
  • 50-100Ω resistor

Software

aiyprojects duab

Kauj Ruam 2: Cov laug ntawm Header Pins

Solder ntawm Header Pins
Solder ntawm Header Pins
Solder ntawm Header Pins
Solder ntawm Header Pins

Hauv txoj haujlwm no, koj yuav siv Cov Khoom Siv Lub Suab los ua lub teeb ntsais LED hauv kev teb rau lub suab hais kom ua. Yog tias koj tuaj yeem ua tus LED, tom qab ntawv muaj qhov tsawg heev rau qhov koj tuaj yeem tswj tau.

Thawj qhov ua yog teeb tsa Lub Suab HAT. Raws li koj yuav tswj hwm ib qho LED, koj yuav tsum tau siv qee lub taub hau taub hau kom tso cai rau koj nkag mus rau GPIO pins ntawm Raspberry Pi

Koj tuaj yeem tso cov txheej ntawm peb lub taub hau rau lub qhov ntawm lub rooj tsavxwm uas nyob hauv kab ntawm Cov Tsav Tsheb. Tshwj xeeb, koj xav tau kab 1

Koj tuaj yeem pom daim duab qhia chaw ntawm txhua tus GPIO pins ntawm cov txheej txheem hauv qab no, yog tias koj xav siv tus lej GPIO sib txawv

Yog tias koj tsis tau soldered ua ntej, thiab xav tau kev pab, tom qab ntawd saib ntawm peb Pib nrog cov lus qhia soldering.

Kauj Ruam 3: Teeb Kho Vajtse

Teeb Kho Vajtse
Teeb Kho Vajtse
Teeb Kho Vajtse
Teeb Kho Vajtse
Teeb Kho Vajtse
Teeb Kho Vajtse

Koj tuaj yeem ua raws cov lus qhia tsim hauv Google AIY lub vev xaib yog tias koj xav tau. Txawm li cas los xij, nws siv lub thawv ntawv los ua lub tsev cov khoom siv, thiab qhov no yuav txwv tsis pub nkag mus rau GPIO koob. Yog tias koj xav ua raws phau ntawv qhia yooj yim dua, tom qab ntawd siv cov lus qhia hauv qab no.

Ua ntej, koj yuav tsum tau siv cov yas sawv ntsug los pab txhawb nqa Lub Suab Khoom HAT thaum nws txuas nrog Raspberry Pi. Ntxig qhov standoffs rau hauv qhov sib dhos qhov sib txawv ntawm GPIO pins

Tam sim no koj tuaj yeem tso HAT mus rau Raspberry Pi - nco ntsoov tias cov pins tau koom ua ke

Tom ntej no, txuas tus neeg hais lus rau cov khoom siv. Nws yuav tsum tau xaim ib txoj hauv kev tshwj xeeb: cov xaim liab yuav tsum tau muab tso rau hauv lub qhov ze rau ntawm Raspberry Pi's Ethernet chaw nres nkoj. Cov xaim dub mus rau lwm qhov. Siv Phillips-taub hau ntswj taub hau kom ruaj ntseg cov xov hlau nyob hauv qhov chaw

Tam sim no nws yog lub sijhawm los txuas lub microphone rau nws cov coj. Cov txuas txuas tsuas haum ib txoj hauv kev, yog li qhov no yuav tsum tsis txhob nyuaj heev

Qhov nyuaj tshaj plaws yog sib dhos lub pob. Koj yuav xav tau khawm thiab lub tsev LED, kom pib nrog

Ntxig lub Vaj Tsev LED rau hauv lub pob, thiab tom qab ntawd ntswj nws kom ruaj ntseg

Tom qab ntawd tus tes hloov qhov xav tau txuas. Qhov no tuaj yeem ua tau txawv txawv. Lub qhov ntawm qhov hloov pauv yuav tsum ua kom haum nrog cov pegs ntawm LED vaj tsev. Tsuas yog xyuas kom tseeb tias qhov hloov me me (ntawm no daj) nyob ze rau ntawm lub pob

Tam sim no koj tuaj yeem txuas cov lus coj mus rau khawm

Txuas cov hlau lead raws li qhia hauv daim duab

Txhawm rau ua kom tiav, txuas lub microphone thiab khawm rau HAT raws li qhia

Kauj ruam 4: Nruab Software

Nruab Software
Nruab Software

Yog tias koj nyiam, koj tuaj yeem teeb tsa software rau Lub Suab Khoom siv tus kheej. Google muab phau ntawv qhia no coj koj mus dhau cov txheej txheem. Nws yog qhov yooj yim dua, txawm li cas los xij, siv lawv cov duab ntawm daim npav SD.

Koj tuaj yeem rub lawv cov duab ntawm no. Google duab los ua ntaub ntawv.xz. Txhawm rau rho tawm qhov no ntawm Linux, koj tuaj yeem nruab unxz.

sudo apt hloov tshiab && sudo apt nruab zx-utils -yunxz aiyprojects-2017-05-03.img.xz

Ntawm Windows lossis macOS, Etcher yuav tsum ua qhov no rau koj, tom qab ntawd tsuas yog ntxig koj daim npav SD thiab khau raj koj Raspberry Pi. Koj lub pob yuav tsum maj mam rub thiab koj lub desktop yuav tsum zoo li cov duab pom.

Kauj Ruam 5: Teeb Tus Pabcuam API

Thaum koj lub Raspberry Pi tau khau raj, koj yuav xav tau qee qhov ntawv pov thawj los ntawm Google rau cov khoom siv los ua haujlwm. Ua raws cov theem hauv qab no txhawm rau pab Google Assistant API.

Sau npe rau Google Assistant API

Cov ntaub ntawv zais cia uas koj rub tawm yuav raug hu ua qee yam zoo li

client_secret_89351974213-jsno1i2s7lu9mv4q9bjbf3pas6cpnbe5.apps.googleusercontent.com.json.

Koj yuav tsum tau hloov nws tus pabcuam.json thiab tso nws rau hauv koj /tsev /pi npe.

Txhawm rau ua qhov no, qhib lub davhlau ya nyob twg thiab ntaus:

cd ~/mv Downloads/client_secret* assistant.json

Kauj Ruam 6: Xeem Nws Ua Haujlwm

Test Nws Ua Haujlwm
Test Nws Ua Haujlwm

Nrog rau kho vajtse thiab software txhua yam teeb tsa, koj yuav tsum ntsuas seb koj li Voice Kit ua haujlwm li cas.

Nyem rau ntawm Start dev davhlau ya nyob twg icon ntawm lub desktop qhib lub davhlau ya nyob twg qhov rai

Txhawm rau pib Lub Suab Khoom program los ntawm tus kheej, koj tuaj yeem yooj yim ntaus src/main.py rau hauv lub davhlau ya nyob twg

Yog tias nws yog koj thawj zaug ua haujlwm rau qhov haujlwm no, Chromium yuav qhib thiab nug koj kom nkag mus thiab tso cai siv Google API

Nyem ALLOW kom pab nkag tau rau API. Tam sim no koj yuav tsum tuaj yeem siv lub pob kom pib ntes koj lub suab txib. Muaj ntau qhov kev qhia ua hauv uas koj tuaj yeem siv. Sim thawb lub pob thiab tom qab ntawd hais ib nqe lus hauv qab no:

  1. "Peb txoj cai lij choj ntawm neeg hlau yog dab tsi?""
  2. Lub sijhawm yog dab tsi?”
  3. “IP Chaw Nyob”

Koj tseem tuaj yeem nug nws cov lus nug uas yuav ua rau kev tshawb nrhiav Google yooj yim, piv txwv li:

  • "Leej twg yog Tus Thawj Kav Tebchaws?"
  • "Dab tsi yog cua nrawm-nrawm ntawm ib qho tsis nqos?"
  • "Dab tsi yog huab cua nrawm nrawm ntawm cov neeg Asmeskas tsis tau nqos?"

Muaj kev ua si zoo nrog lub cuab yeej ua ntej kawm paub yuav ua li cas txhawm rau txhawm rau tsim koj tus kheej lub suab txib.

Kauj Ruam 7: Cov Lus Teb Yooj Yim

AIY Voice Kit software tso cai rau koj ntxiv koj tus kheej lub suab lus yooj yim uas yuav ua rau cov lus teb yooj yim.

Siv tus kws kho ntawv lossis IDLE (Ntawv Qhia-> Programming-> Python 3 (IDLE), qhib cov ntawv hu ua action.py. Koj tuaj yeem pom nws hauv /home/pi/voice-recognizer-raspi/src/action.py.

Feem ntau ntawm cov ntawv no suav nrog cov lus qhia yuav siv lub cuab yeej li cas, tab sis yog tias koj nqes mus, koj yuav kawg los rau cov lus hauv qab no:

# =========================================

# Tsim! Ntxiv koj tus kheej cov lus txib ntawm no

# =========================================

Nov yog qhov uas koj tuaj yeem ntxiv qee qhov lus txib yooj yim thiab cov lus teb koj xav tau txais rov qab. Hauv qab cov lus pom, tam sim no koj tuaj yeem ntxiv koj tus kheej cov kev ua. Sim ntxiv cov kab hauv qab no - xyuas kom tseeb tias koj khaws qhov kev nkag mus.

# =========================================

# Tsim! Ntxiv koj tus kheej cov lus txib ntawm no

# =========================================

actor.add_keyword ("ua li cas", Hais Lus (hais tias, "Kuv nyob zoo, ua tsaug"))

Kab no ua dab tsi? actor.add_keyword ("ua li cas" qhia tus lej kom mloog cov ntsiab lus "ua li cas" hais los ntawm tus neeg siv. SpeakAction (hais tias, "Kuv nyob zoo, ua tsaug"), qhia txoj haujlwm kom teb nrog cov lus "Kuv nyob zoo, ua tsaug ".

Tau mus ntawm kev khiav cov cai no, thiab sim tias nws ua haujlwm. Koj yuav tsum rov qab mus rau lub davhlau ya nyob twg lub davhlau ya nyob twg, nias Ctrl + C yog tias txoj haujlwm tam sim no ua haujlwm, thiab tom qab ntawd ntaus src/main.py kom rov pib dua Lub Suab Khoom software.

Nias lub pob thiab tom qab ntawd nug Lub Suab Khoom "Dab tsi tshwm sim?"

Tam sim no sim ntxiv koj tus kheej cov ntsiab lus tseem ceeb thiab cov lus teb hauv qab qhov uas koj nyuam qhuav sau.

Kauj Ruam 8: Tswj LED

Tswj ib qho LED
Tswj ib qho LED
Tswj ib qho LED
Tswj ib qho LED

Tam sim no yog koj lub sijhawm los sim thiab ua LED qhib thiab tua dua thaum cov lus txib tau muab.

Ua ntej tshaj, txuas lub LED mus rau lub header pins koj tau siv rau yav dhau los

Qhov zoo (ntev) ceg ntawm LED yuav tsum txuas nrog tus pin nruab nrab, thiab ceg tsis zoo (ceg luv) yuav tsum txuas nrog tus pin ntawm sab xis ntawm nws

Tam sim no koj yuav tsum ua cov hauv qab no hauv cov ntawv action.py.

Nyob ze rau sab saum toj ntawm cov ntawv, ntshuam chav LED los ntawm gpiozero module

Tsim cov khoom coj ntawm GPIO 17

Tsim kom muaj ControlLED chav kawm uas tig lub LED rau, tos 5 vib nas this, thiab tig lub LED tawm dua

Tsim lub suab tshiab hais kom ua rau chav kawm thaum cov ntawv "LED" tau hais

Ntawm no koj mus, peb tau ua tiav nrog txhua qhov teeb tsa.

Tam sim no koj tuaj yeem tswj hwm LED siv koj lub suab.

Kuv vam tias koj nyiam qhov kev qhia thiab kawm qee yam muaj txiaj ntsig. Yog tias koj muaj lus nug, thov tso lawv rau hauv kab lus hauv qab no. Tsis tas li, ua raws peb ntawm cov lus qhia rau ntau txoj haujlwm zoo li no.

Pom zoo: