Continuing from Chapter 1 and Chapter 2, I want to convert Raspberry Pi to Amazon Echo. think.
An article about a pioneer who turned Raspberry Pi into an Echo.
https://qiita.com/bwtakacy/items/32226ed2406b5ebe1984
Register as a new developer by signing in at the top right of the main site below.
https://developer.amazon.com/ja/alexa-voice-service
When you log in, you will be taken to this screen.
From "Getting Started" with Alexa Voice Service
Register four types of URLs in the security profile. There are two types of "Allowed origin" (= Allowed origin). There are two types of "Allowed Return URL" (= Allowed Return URL).
Eventually it will be registered and it will be like this.
If you press "Manage", you can check the client ID and client secret again.
Download the required sample-app as described in the article below.
https://qiita.com/bwtakacy/items/32226ed2406b5ebe1984
git clone https://github.com/alexa/alexa-avs-sample-app.git
cd alexa-avs-sample-app-master
automated_install.sh
#!/bin/bash
#-------------------------------------------------------
# Paste from developer.amazon.com below
#-------------------------------------------------------
# This is the name given to your device or mobile app in the Amazon developer portal. To look this up, navigate to https://developer.amazon.com/edw/home.html. It may be labeled Device Type ID.
ProductID=YOUR_PRODUCT_ID_HERE ← here
# Retrieve your client ID from the web settings tab within the developer console: https://developer.amazon.com/edw/home.html
ClientID=YOUR_CLIENT_ID_HERE ← here
# Retrieve your client secret from the web settings tab within the developer console: https://developer.amazon.com/edw/home.html
ClientSecret=YOUR_CLIENT_SECRET_HERE ← here
After editing this, run the installation.
. ./automated_install.sh
Answer the following questions to complete the installation.
====== AVS + Raspberry Pi Licenses and Agreement ======
This code base is dependent on several external libraries and virtual environments like Kitt-Ai, Sensory, ALSA, Atlas, Portaudio, VLC, NodeJS, npm, Oracle JDK, OpenSSL, Maven & CMake.
Please read the document "Installer_Licenses.txt" from the sample app repository and the corresponding licenses of the above.
Do you agree to the terms and conditions of the necessary software from the third party sources and want to download the necessary software from the third party sources?
=======================================================
[y/quit] >> y
Do you have an Amazon developer account?
[y/n/quit] >> y
ProductID >> ########
ClientID >> ##########
ClientSecret >> ##############
Is this information correct?
[y/n] >> y
Which locale would you like to use?
=======================================================
1) en-US
2) en-GB
3) de-DE
4) en-CA
5) en-IN
6) ja-JP
Please select an option [1-6] 6
==== Setting Audio Output =====
Are you using 3.5mm jack or HDMI cable for audio output?
=======================================================
1) 3.5mm jack
2) HDMI audio output
Please select an option [1-2] 1
=== Enabling Hands Free Experience using Wake Word "Alexa" ====
Do you want to enable "Alexa" Wake Word Detection?
=======================================================
[y/n/quit] >> y
(Installation starts)
...
[100%] Built target wakeWordAgentTest
chown: changing ownership of ‘/home/pi/alexa-avs-sample-app-master/samples/wakeWordAgent/ext/lib/libblas.so.3’: Operation not permitted
=============================
*****************************
========= Finished ==========
*****************************
=============================
To run the demo, do the following in 3 seperate terminals:
Run the companion service: cd /home/pi/alexa-avs-sample-app-master/samples/companionService && npm start
Run the AVS Java Client: cd /home/pi/alexa-avs-sample-app-master/samples/javaclient && mvn exec:exec
Run the wake word agent:
Sensory: cd /home/pi/alexa-avs-sample-app-master/samples/wakeWordAgent/src && ./wakeWordAgent -e sensory
KITT_AI: cd /home/pi/alexa-avs-sample-app-master/samples/wakeWordAgent/src && ./wakeWordAgent -e kitt_ai
GPIO: PLEASE NOTE -- If using this option, run the wake word agent as sudo:
cd /home/pi/alexa-avs-sample-app-master/samples/wakeWordAgent/src && sudo ./wakeWordAgent -e gpio
This completes the installation. The rest is the terminal application and authentication.
Execute 3 in order with the command.
cd alexa-avs-sample-app/samples
cd companionService && npm start & # ①
cd javaclient && mvn exec:exec & # ②
cd wakeWordAgent/src && ./wakeWordAgent -e sensory & # ③
Each program is 1. a web service for authentication, 2.1 a terminal application (screen) that accesses AVS, and 3. a program that watches the microphone and detects the wake command (calling "Alexa"). is.
Now press Yes to launch the browser on the Raspberry Pi side. I used Firefox in my environment, but you can also use Chromium-browser.
firefox &
In the URL input field of the browser, paste the previous URL (since it has already been copied to the Clipboard as a result of pressing the Yes button) with Ctrl + V.
Although it is a certificate error, it can be passed by any browser if it is approved as a special case.
Press Okay,
If you go to this point, authentication with AVS is complete. Go back to your Java app and press OK.
As shown below, the token has been entered and you are logged on.
You can press the button here to start talking from the conversation, or you can execute the command in step 3 to wait for the wake command, so if you talk to "Alexa", the conversation will turn on without permission.
Mike tells you the weather in West Lake when you say "Alexa, what's the weather tomorrow?" The history can also be viewed below. https://alexa.amazon.com/spa/index.html#settings/dialogs (Japanese) https://alexa.amazon.co.jp/spa/index.html#settings/dialogs
~~ Please note that there is also the same management screen of alexa.amazon.co.jp, but for some reason it is not tied to this. ~~ ~~ (I may have set the server somewhere on the developer dashboard, but I'm not sure where) ~~ You can see the history by visiting ~~ alexa.amazon.com. ~~
The above was also a lie. You need to register the amazon.co.jp account properly as a developer account. It seems to be bad if both amazon.com and amazon.co.jp have accounts with the same email address and password. (If you can't authenticate with amazon.com first, you'll skip to amazon.co.jp ... hey) https://qiita.com/Dimeiza/items/182c4847d7c1ead7df54#amazoncojp%E3%81%A8amazoncom%E3%81%AE%E3%82%A2%E3%82%AB%E3%82%A6%E3%83%B3%E3%83%88%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6 https://dev.classmethod.jp/voice-assistant/solution-of-a-problem-amazon-com-account-conflict/
The sound comes out of the analog output for some reason instead of coming out of the bluetooth speaker. .. .. ~~ I've researched various things, but some conditions overlap and it's still unsupported. ~~ ~~-Originally this app is implemented based on Oracle JDK ~~ ~~-Oracle JDK can't support Linux's PulseAudio gimmick ~~ ~~-You can't connect to Bluetooth without using PulseAudio ~~ ~~-When I try to use OpenJDK, it fails with another SSL authentication. .. .. ~~
(Fixed 2018/1/3) There was a sound from bluetooth! [Chapter 1](https://qiita.com/onelittlenightmusic/items/05b262c60c4889c07ca9#201813%E8%BF%BD%E8%A8%98-%E3%81%82%E3%81%A8%E3%81% A7alexa% E3% 82% 92% E3% 81% A1% E3% 82% 83% E3% 82% 93% E3% 81% A8bluetooth% E3% 82% B9% E3% 83% 94% E3% 83% BC% E3% 82% AB% E3% 81% 8B% E3% 82% 89% E3% 81% 97% E3% 82% 83% E3% 81% B9% E3% 82% 89% E3% 81% 9B% E3% 82% 8B% E3% 81% 9F% E3% 82% 81% E3% 81% AEjava% E8% A8% AD% E5% AE% 9A), but by writing the following, PulseAudio → Bluetooth There is a sound.
/usr/lib/jvm/java-8-oracle/jre/lib/sound.properties
javax.sound.sampled.Clip=com.sun.media.sound.DirectAudioDeviceProvider
javax.sound.sampled.Port=com.sun.media.sound.PortMixerProvider
javax.sound.sampled.SourceDataLine=com.sun.media.sound.DirectAudioDeviceProvider
javax.sound.sampled.TargetDataLine=com.sun.media.sound.DirectAudioDeviceProvider