Difference between revisions of "Template:13.3inch Magic Mirror user manual"
m (Text replacement - "https://{{SERVERNAME}}/w/upload/" to "https://files.waveshare.com/upload/") |
|||
(34 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
==Features== | ==Features== | ||
− | *13.3inch IPS screen, | + | *13.3inch IPS screen,1920 x 1080 high resolution. |
− | *Embed Raspberry Pi 3A+ as controller | + | *Embed Raspberry Pi 3A+ as controller. |
− | *One-way mirror, can display news, weather and time. | + | *One-way mirror, can display news, weather, and time. |
− | *Toughened glass capacitive touch panel, 6H hardness, supports up to 10-points touch | + | *Toughened glass capacitive touch panel, 6H hardness, supports up to 10-points touch. |
− | *Embedded ferrite Hi-Fi speaker | + | *Embedded ferrite Hi-Fi speaker. |
− | *Embedded Microphone | + | *Embedded Microphone and speaker, adopts Snowboy Hotword Detection Engine. |
− | *75x75mm spacing mounting holes (M4 screw hole) for general wall mount | + | *75x75mm spacing mounting holes (M4 screw hole) for a general wall mount. |
− | *Comes with 75° tilt angle stand | + | *Comes with a 75° tilt angle stand. |
− | == | + | |
− | + | ==Writing Image== | |
+ | *[[Write Image for Compute Module Boards eMMC version]] | ||
+ | *[[Wrote Image for Compute Module Boards Lite version |Write Image for Compute Module Boards Lite version]] | ||
+ | ==USB2.0== | ||
+ | The USB port is disabled by default on the CM4 to save power. If you need to start, you need to add the following demo to the config.txt file: | ||
+ | dtoverlay=dwc2,dr_mode=host | ||
+ | Then restart.<br> | ||
+ | |||
+ | <font color="#ff00ff"> | ||
+ | If you use the latest Raspberry Pi OS (image after October 30, 2021) USB2.0 is OTG mode by default, and CM4 will report an error: <br> | ||
+ | config failed, hub doesn't have any ports! (err -19) | ||
+ | However, USB can still be used. If you want to remove this error, remove otg_mode=1 in [cm4] of config.txt, and add dtoverlay=dwc2, dr_mode=host (USB cannot be recognized without adding it). <br> | ||
+ | [[FILE:CM4 Burn EMMC_12.png|800px]]<br> | ||
+ | </font> | ||
+ | You can use Magic Mirros in two ways: <br> | ||
+ | Method one, using a pre-configured mirror. The second method is to configure the environment running the program on the original image of the Raspberry Pi.<br> | ||
+ | <font color="#FF0000">It is recommended to install pre-configured images for newbies or first-time installations. The pre-configured images have already installed the required libraries and drivers, and the program runs automatically after booting.</font> | ||
===Method 1. Pre-configured image=== | ===Method 1. Pre-configured image=== | ||
− | ;1. Download the pre-configured image and write it to your | + | ;1. Download the pre-configured image and write it to your TF card. |
*[https://1drv.ms/u/s!AjQhuE4TeXmAltNPYioynEHlEMVpoQ?e=Dl5REk Image for 13.3inch Magic Mirror] | *[https://1drv.ms/u/s!AjQhuE4TeXmAltNPYioynEHlEMVpoQ?e=Dl5REk Image for 13.3inch Magic Mirror] | ||
− | ;2. Add the following lines to wpa_supplicat.conf files in the BOOT directory. (if you didn't find the files, create | + | ;2. Add the following lines to wpa_supplicat.conf files in the BOOT directory. (if you didn't find the files, create them.) |
<pre> | <pre> | ||
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev | ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev | ||
Line 24: | Line 40: | ||
} | } | ||
</pre> | </pre> | ||
− | Note: you need to change your_real_wifi_ssid and your_real_password" to the real ssid and password | + | Note: you need to change your_real_wifi_ssid and your_real_password" to the real ssid and password. |
− | ;3. Inset the card to Raspberry Pi and power on it | + | ;3. Inset the card to Raspberry Pi and power on it. |
===Method 2. Configure image manually=== | ===Method 2. Configure image manually=== | ||
;1. Write Raspbian image | ;1. Write Raspbian image | ||
: Download the lasted Raspbian image from the Rasberry Pi website and write it to an empty micro SD card. | : Download the lasted Raspbian image from the Rasberry Pi website and write it to an empty micro SD card. | ||
− | : Create a new | + | : Create a new Txt file under the BOOT directory of the micro SD card and name it SSH. |
− | : Modify config.txt file which is located | + | : Modify the config.txt file which is located in the BOOT directory, and add the following lines to the config.txt file. |
<pre> | <pre> | ||
hdmi_group=2 | hdmi_group=2 | ||
Line 37: | Line 53: | ||
hdmi_cvt 1920 1080 60 6 0 0 0 | hdmi_cvt 1920 1080 60 6 0 0 0 | ||
</pre> | </pre> | ||
− | : Save and insert the micro SD card | + | : Save and insert the micro SD card into Raspberry Pi. |
− | : Connect the Magic mirror to network and power on Raspberry Pi. | + | : Connect the Magic mirror to the network and power on Raspberry Pi. |
− | : After booting, you can access Raspberry Pi via SSH, or directly connect keyboard and mouse. | + | : After booting, you can access Raspberry Pi via SSH, or directly connect the keyboard and mouse. |
− | ;2. Install WM8960 sound card driver | + | ;2. Install WM8960 sound card driver. |
− | : Open the terminal and use the following commands to install | + | : Open the terminal and use the following commands to install. |
<pre> | <pre> | ||
git clone https://github.com/waveshare/WM8960-Audio-HAT | git clone https://github.com/waveshare/WM8960-Audio-HAT | ||
cd WM8960-Audio-HAT | cd WM8960-Audio-HAT | ||
− | sudo ./install.sh | + | sudo ./install.sh |
+ | sudo reboot | ||
</pre> | </pre> | ||
− | : Modify config.txt file, remove the following line from the file or comment it. | + | : Modify the config.txt file, remove the following line from the file, or comment on it. |
<pre> | <pre> | ||
#dtparam=audio=on | #dtparam=audio=on | ||
</pre> | </pre> | ||
− | : Then reboot Raspberry Pi | + | : Then reboot Raspberry Pi. |
<pre> | <pre> | ||
sudo reboot | sudo reboot | ||
</pre> | </pre> | ||
− | : After rebooting, check the driver by the following command | + | : After rebooting, check the driver by the following command. |
<pre> | <pre> | ||
sudo dkms status | sudo dkms status | ||
</pre> | </pre> | ||
− | : If you can get the information | + | : If you can get the information below, it means that the driver was installed successfully. |
<pre> | <pre> | ||
+ | pi@raspberrypi:~ $ sudo dkms status | ||
wm8960-soundcard, 1.0, 4.19.58-v7l+, armv7l: installed | wm8960-soundcard, 1.0, 4.19.58-v7l+, armv7l: installed | ||
</pre> | </pre> | ||
− | :Test the sound card | + | : Test the sound card. |
*Test playing: aplay -l | *Test playing: aplay -l | ||
<pre> | <pre> | ||
Line 80: | Line 98: | ||
Subdevice #0: subdevice #0 | Subdevice #0: subdevice #0 | ||
</pre> | </pre> | ||
− | ;3. Install Magic Mirror driver | + | ;3. Install Magic Mirror driver. |
− | : Open terminal and type the following commands | + | : Open the terminal and type the following commands. |
<pre> | <pre> | ||
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - | curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - | ||
Line 89: | Line 107: | ||
npm install | npm install | ||
</pre> | </pre> | ||
− | :After installing, run the command to display | + | : After installing, run the command to display. |
<pre> | <pre> | ||
DISPLAY=:0 npm start | DISPLAY=:0 npm start | ||
</pre> | </pre> | ||
:[[File:MgicMirror-1.png|600px]] | :[[File:MgicMirror-1.png|600px]] | ||
− | : Install MMM-VoiceAssistant model and display | + | : Install MMM-VoiceAssistant model and display. |
<pre> | <pre> | ||
cd ~/MagicMirror/modules | cd ~/MagicMirror/modules | ||
git clone https://github.com/waveshare/MMM-VoiceAssistant.git | git clone https://github.com/waveshare/MMM-VoiceAssistant.git | ||
cd MMM-VoiceAssistant | cd MMM-VoiceAssistant | ||
− | cp config/config.js.en ~/MagicMirror/config/config.js # | + | cp config/config.js.en ~/MagicMirror/config/config.js #Display English |
− | #cp config/config.js.cn ~/MagicMirror/config/config.js # | + | #cp config/config.js.cn ~/MagicMirror/config/config.js #Display Chinese |
cd ~/MagicMirror | cd ~/MagicMirror | ||
DISPLAY=:0 npm star | DISPLAY=:0 npm star | ||
</pre> | </pre> | ||
:[[File:MgicMirror-2.png|700px]] | :[[File:MgicMirror-2.png|700px]] | ||
− | ;4. Install Python3 virtual environment | + | ;4. Install Python3 virtual environment. |
<pre> | <pre> | ||
sudo apt-get update | sudo apt-get update | ||
Line 113: | Line 131: | ||
source env/bin/activate | source env/bin/activate | ||
</pre> | </pre> | ||
− | :'''Note: The following steps should be | + | :''' Note: The following steps should be taken in the virtual environment, if you close the terminal and restart it, you should use the command below to enter the environment again first.''' |
<pre> | <pre> | ||
source ~/env/bin/activate | source ~/env/bin/activate | ||
</pre> | </pre> | ||
− | ;5. Install | + | ;5. Install Snowboy. |
− | :Install libraries | + | : Install libraries: |
<pre> | <pre> | ||
sudo apt-get install swig | sudo apt-get install swig | ||
Line 127: | Line 145: | ||
pip3 install SpeechRecognition | pip3 install SpeechRecognition | ||
</pre> | </pre> | ||
− | :Download | + | : Download Snowboy: |
<pre> | <pre> | ||
git clone https://github.com/Kitt-AI/snowboy.git | git clone https://github.com/Kitt-AI/snowboy.git | ||
Line 134: | Line 152: | ||
cd ../../examples/Python3 | cd ../../examples/Python3 | ||
</pre> | </pre> | ||
− | :Modify snowbiydecoder.py file. Change '''from.import snowboydetect''' to '''import snowboydetect'''. Save and enable snowboy | + | : Modify snowbiydecoder.py file. Change ''' from.import snowboydetect''' to '''import snowboydetect'''. Save and enable snowboy |
<pre> | <pre> | ||
cd ~/snowboy/examples/Python3 | cd ~/snowboy/examples/Python3 | ||
python3 demo.py resources/models/smart_mirror.umdl | python3 demo.py resources/models/smart_mirror.umdl | ||
</pre> | </pre> | ||
− | :Try to say ''' | + | :Try to say '''snowboy''', you will hear '''ding''' and the information below are printed on the mirror'''. |
<pre> | <pre> | ||
INFO:snowboy:Keyword 1 detected at time: 2019-12-03 11:30:16 | INFO:snowboy:Keyword 1 detected at time: 2019-12-03 11:30:16 | ||
</pre> | </pre> | ||
;6. Install Google Assistant Service | ;6. Install Google Assistant Service | ||
− | :Create .asoundrc file in /home/pi directory | + | : Create .asoundrc file in /home/pi directory (the user directory) |
<pre> | <pre> | ||
nano .asoundrc | nano .asoundrc | ||
</pre> | </pre> | ||
− | :Add the following lines to the .asoundrc file | + | : Add the following lines to the .asoundrc file. |
<pre> | <pre> | ||
pcm.!default { | pcm.!default { | ||
Line 168: | Line 186: | ||
} | } | ||
</pre> | </pre> | ||
− | : | + | : According to the official guide to installing Google Assistant Service |
*https://developers.google.com/assistant/sdk/guides/service/python | *https://developers.google.com/assistant/sdk/guides/service/python | ||
− | :Please follow the third step of the official guide to configure and create OAuth Client ID JSON file. Don't forget to copy the JSON file to your Raspberry Pi. | + | : Please follow the third step of the official guide to configure and create the OAuth Client ID JSON file. Don't forget to copy the JSON file to your Raspberry Pi. |
− | :Following the fourth step of the guide to register device model | + | : Following the fourth step of the guide to register the device model. |
− | : Install Google Assistant SDK | + | : Install Google Assistant SDK. |
<pre> | <pre> | ||
(env) $ sudo apt-get install portaudio19-dev libffi-dev libssl-dev | (env) $ sudo apt-get install portaudio19-dev libffi-dev libssl-dev | ||
Line 181: | Line 199: | ||
(env) $ python -m pip install --upgrade google-auth-oauthlib[tool] | (env) $ python -m pip install --upgrade google-auth-oauthlib[tool] | ||
</pre> | </pre> | ||
− | : Genegrate credential | + | : Genegrate credential. |
<pre> | <pre> | ||
(env) $ google-oauthlib-tool --scope https://www.googleapis.com/auth/assistant-sdk-prototype \ | (env) $ google-oauthlib-tool --scope https://www.googleapis.com/auth/assistant-sdk-prototype \ | ||
--save --headless --client-secrets /path/to/client_secret_ client-id .json | --save --headless --client-secrets /path/to/client_secret_ client-id .json | ||
</pre> | </pre> | ||
− | : Then you will get an URL, please copy it and open it on browser of your PC. | + | : Then you will get an URL, please copy it and open it on the browser of your PC. |
<pre> | <pre> | ||
Please visit this URL to authorize this application: https://... | Please visit this URL to authorize this application: https://... | ||
</pre> | </pre> | ||
− | : Go to the URL, you are asked to log in your Google Account and get the authorization code by following guides, Copy the code to the terminal | + | : Go to the URL, you are asked to log in to your Google Account and get the authorization code by following the guides, Copy the code to the terminal: |
<pre> | <pre> | ||
Please go to this URL: https://... | Please go to this URL: https://... | ||
Enter the authorization code: | Enter the authorization code: | ||
</pre> | </pre> | ||
− | : If the authorization process is done successfully, you will get the information | + | : If the authorization process is done successfully, you will get the information below: |
<pre> | <pre> | ||
credentials saved: /path/to/.config/google-oauthlib-tool/credentials.json | credentials saved: /path/to/.config/google-oauthlib-tool/credentials.json | ||
</pre> | </pre> | ||
− | :Use the following | + | : Use the following command to test. |
<pre> | <pre> | ||
googlesamples-assistant-pushtotalk --project-id my-dev-project --device-model-id my-model | googlesamples-assistant-pushtotalk --project-id my-dev-project --device-model-id my-model | ||
</pre> | </pre> | ||
− | : | + | : Run the following command to test that my-dev-project is the Google Cloud Platform project ID of the Actions Console project created. To find the project ID in the Actions Console, my-model is the name of the device model registered in the previous step. |
− | :Press Enter, and try to ask something. | + | googlesamples-assistant-pushtotalk --project-id my-dev-project --device-model-id my-model |
− | ;7. Set auto-run | + | : Press Enter, and try to ask something. |
− | :Install PM2 | + | ;7. Set auto-run. |
+ | : Install PM2. | ||
<pre> | <pre> | ||
sudo npm install -g pm2 | sudo npm install -g pm2 | ||
Line 214: | Line 233: | ||
pm2 startup | pm2 startup | ||
</pre> | </pre> | ||
− | :You will get | + | : You will get the information below, please copy the command and run it on the terminal. |
<pre> | <pre> | ||
[PM2] To setup the Startup Script, copy/paste the following command: | [PM2] To setup the Startup Script, copy/paste the following command: | ||
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi | sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi | ||
</pre> | </pre> | ||
− | :Run Magic mirror by PM2 | + | : Run Magic mirror by PM2 |
<pre> | <pre> | ||
cd MagicMirror/modules/MMM-VoiceAssistant/pi | cd MagicMirror/modules/MMM-VoiceAssistant/pi | ||
pm2 start mm.sh | pm2 start mm.sh | ||
</pre> | </pre> | ||
− | :Run | + | : Run Snowboy by PM2 |
<pre> | <pre> | ||
cd MagicMirror/modules/MMM-VoiceAssistant/pi | cd MagicMirror/modules/MMM-VoiceAssistant/pi | ||
pm2 start snowboy.sh | pm2 start snowboy.sh | ||
</pre> | </pre> | ||
− | :Set auto-run | + | : Set auto-run: |
<pre> | <pre> | ||
pm2 save | pm2 save | ||
</pre> | </pre> | ||
− | :If you want to disable the | + | : If you want to disable the services, you can also use the following command: |
<pre> | <pre> | ||
pm2 stop mm | pm2 stop mm | ||
pm2 stop snowboy | pm2 stop snowboy | ||
</pre> | </pre> | ||
− | ;8. | + | ;8. Keep display lighting all the time. |
− | :Modify lightdm.conf | + | : Modify lightdm.conf. |
<pre> | <pre> | ||
sudo nano /etc/lightdm/lightdm.conf | sudo nano /etc/lightdm/lightdm.conf | ||
</pre> | </pre> | ||
− | :Find the line "Xserver-command" below [SeatDefaults] section and change it from | + | : Find the line "Xserver-command" below [SeatDefaults] section and change it from |
<pre> | <pre> | ||
#xserver-command=X | #xserver-command=X | ||
Line 251: | Line 270: | ||
xserver-command=X -s 0 -dpms | xserver-command=X -s 0 -dpms | ||
</pre> | </pre> | ||
− | : Then save and reboot | + | *-s # – set screen saver not enabled. |
+ | *dpms turn off power saving management. | ||
+ | : Then save and reboot. | ||
<pre> | <pre> | ||
sudo reboot | sudo reboot | ||
</pre> | </pre> | ||
− | == | + | |
− | ;1. If the wakeup word is unworkable for you, please log in | + | ==Note== |
+ | ;1. If the wakeup word is unworkable for you, please log in Snowboy website: https://snowboy.kitt.ai, And add the new wakeup word. | ||
:[[File:MgicMirror-3.png|600px]] | :[[File:MgicMirror-3.png|600px]] | ||
− | :Click recording icon to record voice and test if the voice model is workable | + | : Click the recording icon to record voice and test if the voice model is workable. |
:[[File:MgicMirror-4.png|500px]] | :[[File:MgicMirror-4.png|500px]] | ||
− | :Download the model file and copy it to ~/MagicMirror/modules/MMM-VoiceAssistant/pi | + | : Download the model file and copy it to ~/MagicMirror/modules/MMM-VoiceAssistant/pi directory. |
− | :Modify | + | : Modify Snowboy.sh file. |
<pre> | <pre> | ||
nano snowboy.sh | nano snowboy.sh | ||
</pre> | </pre> | ||
− | :Modify the name to | + | : Modify the name to the one you download, for English, you need to modify the snowboy.umdl to yours. |
<pre> | <pre> | ||
cd ~/MagicMirror/modules/MMM-VoiceAssistant/pi | cd ~/MagicMirror/modules/MMM-VoiceAssistant/pi | ||
~/env/bin/python3 demo.py smart_mirror.umdl snowboy.umdl | ~/env/bin/python3 demo.py smart_mirror.umdl snowboy.umdl | ||
</pre> | </pre> | ||
− | :2. Google Assistant Service can only support 500 | + | :2. Google Assistant Service can only support 500 requests every day. |
+ | Open ~/MagicMirror/modules/MMM-VoiceAssistant/pi/audiofileinput.py. You can enter the following code.<br/> | ||
+ | [[File:13.3inch mmirror.png]]<br/> | ||
+ | |||
+ | Follow the previous Google Assistant Service installation section to register an account, device model, and install authorization.<br/> | ||
+ | Finally, replace DEVICE_ID and DEVICE_MODEL_ID in the program with the corresponding values.<br/> | ||
+ | |||
+ | ==About the Buttons== | ||
+ | [[File:Buttons.png]]<br/> | ||
+ | 1. Turn on or off the LCD display. If the LCD is not used for a long time, it can be turned off through this button to reduce power consumption.<br/> | ||
+ | |||
+ | 2. Direction keys.<br/> | ||
+ | |||
+ | 3. Enter.<br/> | ||
+ | |||
+ | 4. Menu and Return.<br/> | ||
+ | |||
+ | =Resource= | ||
+ | ==Drawing== | ||
+ | *[https://files.waveshare.com/upload/2/27/13.3inch_HDMI_LCD_3D_file.rar 13.3inch HDMI LCD 3D drawing] | ||
+ | ==Software== | ||
+ | *[https://files.waveshare.com/upload/5/56/Putty.zip putty] | ||
+ | *[https://files.waveshare.com/upload/d/d7/Panasonic_SDFormatter.zip Panasonic_SDFormatter] | ||
+ | *[https://files.waveshare.com/upload/7/76/Win32DiskImager.zip Win32DiskImager] | ||
+ | ==Authentication Information== | ||
+ | *[https://files.waveshare.com/upload/4/46/13.3inch_HDMI_LCD_%28H%29_Certification.rar CE RoHS] |
Latest revision as of 05:56, 4 September 2023
Features
- 13.3inch IPS screen,1920 x 1080 high resolution.
- Embed Raspberry Pi 3A+ as controller.
- One-way mirror, can display news, weather, and time.
- Toughened glass capacitive touch panel, 6H hardness, supports up to 10-points touch.
- Embedded ferrite Hi-Fi speaker.
- Embedded Microphone and speaker, adopts Snowboy Hotword Detection Engine.
- 75x75mm spacing mounting holes (M4 screw hole) for a general wall mount.
- Comes with a 75° tilt angle stand.
Writing Image
- Write Image for Compute Module Boards eMMC version
- Write Image for Compute Module Boards Lite version
USB2.0
The USB port is disabled by default on the CM4 to save power. If you need to start, you need to add the following demo to the config.txt file:
dtoverlay=dwc2,dr_mode=host
Then restart.
If you use the latest Raspberry Pi OS (image after October 30, 2021) USB2.0 is OTG mode by default, and CM4 will report an error:
config failed, hub doesn't have any ports! (err -19)
However, USB can still be used. If you want to remove this error, remove otg_mode=1 in [cm4] of config.txt, and add dtoverlay=dwc2, dr_mode=host (USB cannot be recognized without adding it).
You can use Magic Mirros in two ways:
Method one, using a pre-configured mirror. The second method is to configure the environment running the program on the original image of the Raspberry Pi.
It is recommended to install pre-configured images for newbies or first-time installations. The pre-configured images have already installed the required libraries and drivers, and the program runs automatically after booting.
Method 1. Pre-configured image
- 1. Download the pre-configured image and write it to your TF card.
- 2. Add the following lines to wpa_supplicat.conf files in the BOOT directory. (if you didn't find the files, create them.)
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=US network={ ssid="your_real_wifi_ssid" psk="your_real_password" }
Note: you need to change your_real_wifi_ssid and your_real_password" to the real ssid and password.
- 3. Inset the card to Raspberry Pi and power on it.
Method 2. Configure image manually
- 1. Write Raspbian image
- Download the lasted Raspbian image from the Rasberry Pi website and write it to an empty micro SD card.
- Create a new Txt file under the BOOT directory of the micro SD card and name it SSH.
- Modify the config.txt file which is located in the BOOT directory, and add the following lines to the config.txt file.
hdmi_group=2 hdmi_mode=82 hdmi_cvt 1920 1080 60 6 0 0 0
- Save and insert the micro SD card into Raspberry Pi.
- Connect the Magic mirror to the network and power on Raspberry Pi.
- After booting, you can access Raspberry Pi via SSH, or directly connect the keyboard and mouse.
- 2. Install WM8960 sound card driver.
- Open the terminal and use the following commands to install.
git clone https://github.com/waveshare/WM8960-Audio-HAT cd WM8960-Audio-HAT sudo ./install.sh sudo reboot
- Modify the config.txt file, remove the following line from the file, or comment on it.
#dtparam=audio=on
- Then reboot Raspberry Pi.
sudo reboot
- After rebooting, check the driver by the following command.
sudo dkms status
- If you can get the information below, it means that the driver was installed successfully.
pi@raspberrypi:~ $ sudo dkms status wm8960-soundcard, 1.0, 4.19.58-v7l+, armv7l: installed
- Test the sound card.
- Test playing: aplay -l
pi@raspberrypi:~ $ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: wm8960soundcard [wm8960-soundcard], device 0: bcm2835-i2s-wm8960-hifi wm8960-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0
- Test recording: arecord -l
pi@raspberrypi:~ $ arecord -l **** List of CAPTURE Hardware Devices **** card 0: wm8960soundcard [wm8960-soundcard], device 0: bcm2835-i2s-wm8960-hifi wm8960-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0
- 3. Install Magic Mirror driver.
- Open the terminal and type the following commands.
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - sudo apt install -y nodejs git clone https://github.com/MichMich/MagicMirror cd MagicMirror/ npm install
- After installing, run the command to display.
DISPLAY=:0 npm start
cd ~/MagicMirror/modules git clone https://github.com/waveshare/MMM-VoiceAssistant.git cd MMM-VoiceAssistant cp config/config.js.en ~/MagicMirror/config/config.js #Display English #cp config/config.js.cn ~/MagicMirror/config/config.js #Display Chinese cd ~/MagicMirror DISPLAY=:0 npm star
sudo apt-get update sudo apt-get install python3-dev python3-venv python3 -m venv env env/bin/python -m pip install --upgrade pip setuptools wheel source env/bin/activate
- Note: The following steps should be taken in the virtual environment, if you close the terminal and restart it, you should use the command below to enter the environment again first.
source ~/env/bin/activate
- 5. Install Snowboy.
- Install libraries:
sudo apt-get install swig sudo apt-get install libatlas-base-dev sudo apt-get install portaudio19-dev sudo apt-get install flac pip3 install PyAudio pip3 install SpeechRecognition
- Download Snowboy:
git clone https://github.com/Kitt-AI/snowboy.git cd snowboy/swig/Python3 make cd ../../examples/Python3
- Modify snowbiydecoder.py file. Change from.import snowboydetect to import snowboydetect. Save and enable snowboy
cd ~/snowboy/examples/Python3 python3 demo.py resources/models/smart_mirror.umdl
- Try to say snowboy, you will hear ding and the information below are printed on the mirror.
INFO:snowboy:Keyword 1 detected at time: 2019-12-03 11:30:16
- 6. Install Google Assistant Service
- Create .asoundrc file in /home/pi directory (the user directory)
nano .asoundrc
- Add the following lines to the .asoundrc file.
pcm.!default { type asym capture.pcm "mic" playback.pcm "speaker" } pcm.mic { type plug slave { pcm "hw:0,0" } } pcm.speaker { type plug slave { pcm "hw:0,0" } }
- According to the official guide to installing Google Assistant Service
- Please follow the third step of the official guide to configure and create the OAuth Client ID JSON file. Don't forget to copy the JSON file to your Raspberry Pi.
- Following the fourth step of the guide to register the device model.
- Install Google Assistant SDK.
(env) $ sudo apt-get install portaudio19-dev libffi-dev libssl-dev (env) $ python -m pip install --upgrade google-assistant-sdk[samples]
- Authorize model
(env) $ python -m pip install --upgrade google-auth-oauthlib[tool]
- Genegrate credential.
(env) $ google-oauthlib-tool --scope https://www.googleapis.com/auth/assistant-sdk-prototype \ --save --headless --client-secrets /path/to/client_secret_ client-id .json
- Then you will get an URL, please copy it and open it on the browser of your PC.
Please visit this URL to authorize this application: https://...
- Go to the URL, you are asked to log in to your Google Account and get the authorization code by following the guides, Copy the code to the terminal:
Please go to this URL: https://... Enter the authorization code:
- If the authorization process is done successfully, you will get the information below:
credentials saved: /path/to/.config/google-oauthlib-tool/credentials.json
- Use the following command to test.
googlesamples-assistant-pushtotalk --project-id my-dev-project --device-model-id my-model
- Run the following command to test that my-dev-project is the Google Cloud Platform project ID of the Actions Console project created. To find the project ID in the Actions Console, my-model is the name of the device model registered in the previous step.
googlesamples-assistant-pushtotalk --project-id my-dev-project --device-model-id my-model
- Press Enter, and try to ask something.
- 7. Set auto-run.
- Install PM2.
sudo npm install -g pm2
- Setup pm2
pm2 startup
- You will get the information below, please copy the command and run it on the terminal.
[PM2] To setup the Startup Script, copy/paste the following command: sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
- Run Magic mirror by PM2
cd MagicMirror/modules/MMM-VoiceAssistant/pi pm2 start mm.sh
- Run Snowboy by PM2
cd MagicMirror/modules/MMM-VoiceAssistant/pi pm2 start snowboy.sh
- Set auto-run:
pm2 save
- If you want to disable the services, you can also use the following command:
pm2 stop mm pm2 stop snowboy
- 8. Keep display lighting all the time.
- Modify lightdm.conf.
sudo nano /etc/lightdm/lightdm.conf
- Find the line "Xserver-command" below [SeatDefaults] section and change it from
#xserver-command=X
to
xserver-command=X -s 0 -dpms
- -s # – set screen saver not enabled.
- dpms turn off power saving management.
- Then save and reboot.
sudo reboot
Note
- 1. If the wakeup word is unworkable for you, please log in Snowboy website
- https://snowboy.kitt.ai, And add the new wakeup word.
- Click the recording icon to record voice and test if the voice model is workable.
- Download the model file and copy it to ~/MagicMirror/modules/MMM-VoiceAssistant/pi directory.
- Modify Snowboy.sh file.
nano snowboy.sh
- Modify the name to the one you download, for English, you need to modify the snowboy.umdl to yours.
cd ~/MagicMirror/modules/MMM-VoiceAssistant/pi ~/env/bin/python3 demo.py smart_mirror.umdl snowboy.umdl
- 2. Google Assistant Service can only support 500 requests every day.
Open ~/MagicMirror/modules/MMM-VoiceAssistant/pi/audiofileinput.py. You can enter the following code.
Follow the previous Google Assistant Service installation section to register an account, device model, and install authorization.
Finally, replace DEVICE_ID and DEVICE_MODEL_ID in the program with the corresponding values.
About the Buttons
1. Turn on or off the LCD display. If the LCD is not used for a long time, it can be turned off through this button to reduce power consumption.
2. Direction keys.
3. Enter.
4. Menu and Return.