This is a brief of a project created to control the gadgets in home with voice commands. It uses Amazon Alexa for voice and Pubnub for messaging across the devices. Full blog is available on abszeroblog.wordpress.com.
2. This is the basic hardware
setup. Raspberry Pi 3 with a
USB Microphone, speakers.
HDMI connection,
keyboard/mouse are not
shown for simplicity.
A beaglebone black with an
LED connected on a GPIO.
Both boards connected to
Internet.
Internet
Internet
https://abszeroblog.wordpress.com/
3. We also need accounts on
Amazon developer, AWS and
Pubnub.
Amazon hosts Alexa voice
service and our skill.
AWS hosts our skill adapter
code.
Pubnub is used for message
passing from skill adapter to
beaglebone.
•Alexa Skill adapter
Lambda function
Publish /
Subscribe
architecture
Internet
Internet
•Alexa voice service
•Alexa Skill (‘My home’)
https://abszeroblog.wordpress.com/
4. Subscribed to Pubnub
channel ‘Alexa_World’
•Alexa Skill adapter
Lambda function
Publish /
Subscribe
architecture
Running Alexa app
with wakeword agent
Internet
Internet
•Alexa voice service
•Alexa Skill (‘My home’)
https://abszeroblog.wordpress.com/
Run the Alexa app on
Raspberry Pi.
Run the Pubnub subscribing
and GPIO controller code on
beaglebone.
5. Alexa app is continuously
listening for the keyword
‘Alexa’. When user speaks
the keyword, the app listens
to the voice until a pause. In
this case it is the sentence
‘Alexa, ask my home to turn
on bedroom light’.
•Alexa voice service
•Alexa Skill (‘My home’)
•Alexa Skill adapter
Lambda function
Publish /
Subscribe
architecture
Alexa, ask
My Home
to turn on
bedroom
light
Running Alexa app
with wakeword agent
Subscribed to Pubnub
channel ‘Alexa_World’
Internet
Internet
https://abszeroblog.wordpress.com/
6. Alexa app sends the audio to
Alexa voice service running
in Amazon cloud
(developer.amazon.com)
along with device
authentication details and
other metadata.
Audio
•Alexa Skill adapter
Lambda function
Publish /
Subscribe
architecture
Alexa, ask
My Home
to turn on
bedroom
light
Running Alexa app
with wakeword agent
Subscribed to Pubnub
channel ‘Alexa_World’
Internet
Internet
•Alexa voice service
•Alexa Skill (‘My home’)
https://abszeroblog.wordpress.com/
7. In this case, the intent is
to ‘turn on’ something and
the slot is ‘bedroom light’.
This data is then passed on
to an AWS endpoint running
skill adapter code.
Alexa voice service
interprets the voice and
determines that this is a
request for the skill ‘My
home’. It then further
decodes the voice data and
parses it into an intent
(action to be done)
and slot (object to be
acted upon).
Audio
•Alexa Skill adapter
Lambda function
Publish /
Subscribe
architecture
Alexa, ask
My Home
to turn on
bedroom
light
Parsed data to Skill adapter
Intent: “Turn on”
Slot: “Bedroom light”
Running Alexa app
with wakeword agent
Subscribed to Pubnub
channel ‘Alexa_World’
Internet
Internet
•Alexa voice service
•Alexa Skill (‘My home’)
https://abszeroblog.wordpress.com/
8. Skill dapter code processes
the intent and publishes a
message to Pubnub network
on channel named
‘Alexa_World’. This message
contains command as
‘TURN_ON’ and gadget as
‘bedroom light’.
Audio
•Alexa Skill adapter
Lambda function
Publish /
Subscribe
architecture
Alexa, ask
My Home
to turn on
bedroom
light
Parsed data to Skill adapter
Intent: “Turn on”
Slot: “Bedroom light”
Publish message to
channel ‘Alexa_World’:
Command: “TURN_ON”
Gadget: “bedroom light”
Running Alexa app
with wakeword agent
Subscribed to Pubnub
channel ‘Alexa_World’
Internet
Internet
•Alexa voice service
•Alexa Skill (‘My home’)
https://abszeroblog.wordpress.com/
9. Skill adapter also sends an
ACK to voice service which is
passed back to the alexa app
running on pi. This can
contain a voice feedback
such as “Ok”
Audio
•Alexa Skill adapter
Lambda function
Publish /
Subscribe
architecture
Alexa, ask
My Home
to turn on
bedroom
light
Parsed data to Skill adapter
Intent: “Turn on”
Slot: “Bedroom light”
Publish message to
channel ‘Alexa_World’:
Command: “TURN_ON”
Gadget: “bedroom light”
Running Alexa app
with wakeword agent
Subscribed to Pubnub
channel ‘Alexa_World’
Internet
Internet
•Alexa voice service
•Alexa Skill (‘My home’)
“Ok”
(Voice
feedback)
ACK from
skill adapter
(with voice
feedback)
https://abszeroblog.wordpress.com/
10. Pubnub network sends out
the same message to all
devices subscribed to
channel ‘Alexa_World’. In
this case, the beaglebone is
subscribed to this channel
and hence receives the
message.
Audio
•Alexa Skill adapter
Lambda function
Publish /
Subscribe
architecture
Alexa, ask
My Home
to turn on
bedroom
light
Parsed data to Skill adapter
Intent: “Turn on”
Slot: “Bedroom light”
Publish message to
channel ‘Alexa_World’:
Command: “TURN_ON”
Gadget: “bedroom light”
Send message to subscribers
of channel ‘Alexa_World’:
Command: “TURN_ON”
Gadget: “bedroom light”
Running Alexa app
with wakeword agent
Subscribed to Pubnub
channel ‘Alexa_World’
Internet
Internet
•Alexa voice service
•Alexa Skill (‘My home’)
https://abszeroblog.wordpress.com/
11. Audio
•Alexa Skill adapter
Lambda function
Publish /
Subscribe
architecture
Alexa, ask
My Home
to turn on
bedroom
light
Parsed data to Skill adapter
Intent: “Turn on”
Slot: “Bedroom light”
Publish message to
channel ‘Alexa_World’:
Command: “TURN_ON”
Gadget: “bedroom light”
Send message to subscribers
of channel ‘Alexa_World’:
Command: “TURN_ON”
Gadget: “bedroom light”
Running Alexa app
with wakeword agent
Subscribed to Pubnub
channel ‘Alexa_World’
Internet
Internet
•Alexa voice service
•Alexa Skill (‘My home’)
https://abszeroblog.wordpress.com/
Beaglebone then processes
received message and turns
on the GPIO corresponding
to ‘bedroom light’.
Editor's Notes
This is the basic hardware setup needed. Raspberry Pi 3 with a USB Microphone, speakers. HDMI connection, keyboard/mouse are not shown for simplicity.
A beaglebone black with an LED connected on a GPIO. Both boards connected to Internet.
We also need accounts on Amazon developer site, AWS and Pubnub.
Amazon hosts the Alexa voice service and our skill.
AWS hosts the skill adapter code.
Pubnub is used for message passing between skill adapter and beaglebone.
Run the Alexa app on Raspberry Pi.
Run the Pubnub subscribing and GPIO controller code on beaglebone.
Alexa app is continuously looking for the keyword ‘Alexa’.
When the user speaks with the keyword, the app listens to the voice until a pause. In this case it is the sentence ‘Alexa, ask my home to turn on bedroom light’.
Alexa app sends the audio to Alexa voice service running in Amazon cloud (developer.amazon.com) along with device authentication details and other metadata required.
Alexa voice service interprets the voice and finds out that this is a voice data meant for the skill ‘My home’. It then further decodes the voice data and parses it into an intent (action to be done) and a slot (object to be acted upon). In this case, the intent is to ‘turn on’ something and the slot is ‘bedroom light’. This data is then passed on to and AWS endpoint running the skill adapter code called as Lambda function.
The adapter Lambda function processes this intent and publishes a message to the Pubnub network on a particular channel named ‘Alexa_World’. This message contains data with the command as ‘TURN_ON’ and gadget as ‘bedroom light’.
Simultaneously the skill adapter also sends back an acknowledgment to the voice service which is passed on back to the alexa app running on pi. This ack contains a voice feedback such as “Ok” which the user hears from speakers.
Pubnub network then sends out the same message to all devices who are subscribed to channel ‘Alexa_World’. In this case, the beaglebone is subscribed to this channel and hence receives the message.
Beaglebone then processes received message and turns on the GPIO corresponding to ‘bedroom light’.