Cov txheej txheem:

Tham Nrog Alexa thiab Google Assistant Ua Ke hauv Raspberry Pi: 4 Cov Kauj Ruam
Tham Nrog Alexa thiab Google Assistant Ua Ke hauv Raspberry Pi: 4 Cov Kauj Ruam

Video: Tham Nrog Alexa thiab Google Assistant Ua Ke hauv Raspberry Pi: 4 Cov Kauj Ruam

Video: Tham Nrog Alexa thiab Google Assistant Ua Ke hauv Raspberry Pi: 4 Cov Kauj Ruam
Video: 10 самых АТМОСФЕРНЫХ мест Дагестана. БОЛЬШОЙ ВЫПУСК #Дагестан #ПутешествиеПоДагестану 2024, Kaum ib hlis
Anonim
Tham Nrog Alexa thiab Google Assistant Ua Ke hauv Raspberry Pi
Tham Nrog Alexa thiab Google Assistant Ua Ke hauv Raspberry Pi
Tham Nrog Alexa thiab Google Assistant Ua Ke hauv Raspberry Pi
Tham Nrog Alexa thiab Google Assistant Ua Ke hauv Raspberry Pi

Khiav Amazon Alexa thiab Google Assistant tib lub sijhawm hauv Raspberry Pi. Hu ib qho ntawm lawv lub npe, lawv qhib lawv tus kheej LEDs thiab lub suab nrov rau cov lus teb. Tom qab ntawd koj nug qee qhov kev thov thiab lawv teb nws rau koj feem. Koj tuaj yeem paub lawv tus yam ntxwv zoo.

[Tham nrog 2 Lub Suab Navigators Ua Ke (hauv Nyij Pooj)]

Nws tsis nyuaj rau nruab ob lub suab navigators hauv Raspberry Pi. Ua tib zoo Kauj Ruam ntawm Kauj Ruam Qhia yog muab hauv web rau ob leeg. Koj tsuas yog yuav tsum teeb tsa "PulseAudio" ntxiv rau tham nrog lawv ua ke. Txaus siab rau!

(*1) Tus Pi nrog 2 Navigators nkag mus rau Lub Suab Qhib Qhib. Yog tias koj nyiam, thov pov npav. Ua tsaug.

(*2) Kuv txaus siab rau Dimeiza rau nws tsab xov xwm dhau los piav ua lus Nyij Pooj.

Kauj ruam 1: Khoom

Khoom
Khoom

Cov Khoom Muag:

  • Raspberry Pi 3
  • Hwj chim Adapter: DC 5V, 2.5A
  • Micro-SD Card: 16GB
  • USB Microphone: Kuv siv lub microphone hauv lub koob yees duab USB pheej yig (Logitech C270).
  • Qee cov LEDs
  • Cov qhob cij
  • Qee cov jumper xov hlau
  • Hais lus lossis Lub Pob Ntseg: TV tuaj yeem siv tau ntawm HDMI chaw nres nkoj.

Kuv tau kov Raspberry Pi thawj zaug 4 lub hlis dhau los. Li no kuv tsis paub nws zoo. Lub OS uas tau teeb tsa yog Raspbian Stretch (NOOBS v.2.4.4). Kuv yuav tsis tuaj yeem muab kev daws teeb meem rau koj rau lwm OS lossis khoos phis tawj.

Kauj ruam 2: Nruab Amazon Alexa Voice Service

Nruab Amazon Alexa Lub Suab Pabcuam
Nruab Amazon Alexa Lub Suab Pabcuam

Ua tib zoo "cov lus qhia ib qib zuj zus" muaj nyob hauv lub vev xaib. Tsuas yog ua raws nws, koj tuaj yeem nruab Alexa Lub Suab Pabcuam SDK hauv koj tus Pi, thiab ua ib qho qauv piv txwv hauv nws. Hu rau "Alexa!"

Txhawm rau paub seb koj hu mus txog koj li Pi, tig LEDs On thiab ua suab nrov luv tau ntxiv hauv cov qauv piv txwv "/home/pi/sdk-folder/sdk-source/avs-device-sdk/SampleApp/src/UIManager.cpp".

1) Ntxiv 5 kab nrog "system (…);" hauv "tsis muaj dab tsi UIManager:: printState () {" hauv tus qauv c ++ code "UIManager.cpp", thiab khaws nws.

*******

hloov (m_dialogState) {

rooj DialogUXState:: IDLE:

system ("gpio -g hom 24 tawm");

system ("gpio -g sau 24 0");

ConsolePrinter:: prettyPrint ("Alexa tam sim no tsis ua haujlwm!");

rov qab;

rooj DialogUXState:: MLOOG:

system ("gpio -g hom 24 tawm");

system ("gpio -g sau 24 1");

system ("aplay /home/pi/sdk-folder/application-necessities/sound-files/re.wav 1>/dev/null 2>/dev/null");

ConsolePrinter:: prettyPrint ("Mloog …");

rov qab;

********

2) Rov qab mus rau "2. Tsim SDK" hauv Step by Step Guide thiab rov ua dua txhua kauj ruam mus txog "4. Khiav tus qauv app" tshwj tsis yog 3.1.

3) Luam cov ntawv luv luv "re.wav" thiab muab nws tso rau hauv "/home/pi/sdk-folder/application-necessities/sound-files".

Kauj ruam 3: Nruab Google Assistant SDK

Nruab Google Assistant SDK
Nruab Google Assistant SDK

Cov Kauj Ruam Kom Zoo Dua Hauv Phau Ntawv Qhia yog muab hauv web. Tsuas yog ua raws nws, koj tuaj yeem teeb tsa Google Assistant Lub Tsev Qiv Ntawv hauv koj Pi, thiab khiav tus qauv piv txwv hauv nws. Hu rau "OK Google!" lossis "Hav Google!"

Txhawm rau paub seb koj hu mus txog koj li Pi, tig LEDs On thiab ua suab nrov luv tau ntxiv hauv cov qauv piv txwv "/home/pi/assistant-sdk-python/google-assistant-sdk/googlesamples/assistant/library/hotword.py".

(*) Tus kws kho mob hauv Cov Lus Qhia tsis tuaj yeem hais tawm qhov nkag. Qhov tsim nyog yuav tsum tau nkag rau hauv txhua kab hauv qab no hauv sej code.

1) Ntxiv 3 kab tom qab "ntshuam json" hauv tus qauv piv txwv "hotword.py"

*******

ntshuam RPi. GPIO ua GPIO

lub sij hawm ntshuam

ntshuam subprocess

********

2) Ntxiv 2 kab tom qab "print ()" hauv "def process_event (event, device_id):" hauv cov qauv piv txwv "hotword.py".

*******

yog event.type == EventType. ON_CONVERSATION_ END_TURN_STARTED:

print () # Ntxiv 2 kab hauv qab no:

GPIO. tawm (23, 1)

subprocess.call ("aplay /home/pi/sdk-folder/application-necessities/sound-files/re2.wav", plhaub = Tseeb)

print (kev tshwm sim)

*******

3) Ntxiv 2 kab tom qab "'device_id:', assistant.device_id + '\ n')" hauv "def main ():" hauv tus qauv piv txwv "hotword.py", thiab khaws nws.

*******

nrog Assistant (daim ntawv pov thawj, args.device_model_id) ua tus pab:

txheej xwm = pab.start ()

print ('ntaus_model_id:', args.device_model_id + '\ n' +

'device_id:', assistant.device_id + '\ n') # Ntxiv 2 kab hauv qab no:

GPIO.setmode (GPIO. BCM)

GPIO.setup (23, GPIO. OUT, pib = GPIO. LOW)

*******

4) Luam cov ntawv luv luv "re2.wav" thiab muab nws tso rau hauv "/home/pi/sdk-folder/application-necessities/sound-files"

Kauj Ruam 4: Nruab PulseAudio thiab Khiav 2 Navigators Ua Ke

Nruab PulseAudio thiab Khiav 2 Navigators Ua Ke
Nruab PulseAudio thiab Khiav 2 Navigators Ua Ke

Qhov kawg ntawm cov kauj ruam qub, koj tuaj yeem khiav txhua lub suab navigators feem; Alexa thiab Google Assistant. Txawm li cas los xij koj tsis tuaj yeem khiav ob tus neeg tsav nkoj no tib lub sijhawm. Yog li nruab "PulseAudio". Koj tuaj yeem khiav ob tus neeg tsav nkoj no tib lub sijhawm.

********

sudo apt-tau nruab pulseaudio

********

[ceeb toom]

Koj yuav tsum khiav Alexa thawj zaug, thiab hu rau Google Assistant tom qab. Yog tias koj xav khiav tsuas yog Google Assistant, nres PulseAudio ua ntej hu nws.

********

pulseaudio -k

********

Yog tias koj hu tus navigator thaum lwm tus hais lus hais lus, koj Pi yuav tsis meej pem. Yog li koj yuav tsum tau tos lossis cuam tshuam qhov tom kawg kom hais lus tas. Txawm li cas los xij, nws yog qhov nthuav los daws qhov tsis meej pem Pi. Txaus siab rau!

Pom zoo: