Jump to: navigation, search

Product name

RPI_ WM8960 audio decoding module dual microphone intelligent speech recognition.


LC WM8960 module is equipped with the original British Wolfson audio decoding chip and dual silicon microphone array. Audio sound card expansion board specially designed for Raspberry Pi, low power consumption, stereo codec,Support high-quality playback and recording, and can directly drive speakers to play music. It can also be used for DIY similar to smart speakers such as Tmall Genie and Google Assistant.

Functions feature

  • Based on Raspberry Pi 40pin interface, suitable for Raspberry Pi series motherboards
  • Support Raspberry Pi Zero/Zero W/2B/3B/3B+/4 and other development boards
  • Using WM8960 low-power stereo codec chip, can communicate through I2S interface
  • Onboard 2 high-quality MEMS silicon microphones for left and right channel recording
  • Onboard standard 3.5mm headphone jack, output power: 40mW (16Ω@3.3V)
  • Onboard dual-channel speaker interface, which can directly drive the speaker, output power: 2X1W
  • Support stereo, 3D surround and other audio output
  • Onboard 3 programmable APA-102-2020 full-color LEDs
  • Supply voltage: 5V
  • Logic voltage: 3.3V
  • Raspberry Pi control interface: I2C
  • Audio interface: I2S
  • DAC SNR: 98db, ADC SNR: 94db
  • Provide complete reference materials, with the Raspberry Pi, you can DIY a smart speaker similar to Tmall Elf, Xiaodu Speaker, and Google Assistant


Board size:65*30.2mm Weight:16g

Introduce for interface
1. Raspberry Pi 2*20P socket: support Raspberry Pi Zero/Zero W/2B/3B/3B+/4, etc.
2. MIC_L&MIC_R: left and right MEMS silicon microphones
3. WM8960: low-power stereo codec chip
4. POWER: When the output is connected to the speaker, the Micro USB| needs to be connected to provide sufficient current
5. KF301-4P terminal: left and right channel speaker output, power 2X1W
6. PH2.0-4P seat: left and right channel speaker output, power 2X1W
7. 3.5MM headphone output port: power 40mW (16Ω@3.3V)
8. RGB LED: 3 APA102 full-color LEDs, connected to the SPI interface of the Raspberry Pi
9. 6X6mm button: connect to GPIO17 of Raspberry Pi

Hardware connection

1. System configuration and driver installation
(1)Preparations First, make sure that the Raspbian operating system running on the Pi is updated on or after 2018.06.27, then insert the WM8960 module into the Pi, connect the keyboard, monitor and other necessary peripherals, and connect the Pi to WiFi/wired network, as shown below:

(2)Change the source Before installing the driver, please switch the source to Tsinghua according to the following process:
①Enter: sudo nano /etc/apt/sources.list

②Use # to comment out the content of the original file and replace it with the following content
deb stretch main non-free contrib
deb-src stretch main non-free contrib

After typing, press Ctrl+X to save and exit

(3) Driver download and install
Enter: git clone #Download driver
Enter: cd seen-voicecard #Open folder
Enter: sudo ./ #Install sound card driver
Enter: sudo reboot #restart Pi



(4)Check that the sound card name matches the source code seeed-voicecard
Enter: arecord -L

2.Install Python and virtual environment
This is to isolate the relationship between the SDK and the system Python package
Enter: cd /home/pi
Enter: git clone
Enter: cd /home/pi/4mics_hat
Enter: sudo apt install python-virtualenv #Install Python2 virtual environment
Enter: virtualenv --system-site-packages ~/env #Create a virtual environment, named env
Enter: source ~/env/bin/activate #Activate virtual environment
Enter: pip install spidev gpiozero #Install the required toolkit

3.Example of controlling APA102 LED
(1) APA102 LED interface configuration
The onboard APA102 LED is controlled through the Pi's SPI interface, so the Pi's SPI interface needs to be configured first.
Proceed as follows:
●Enter: sudo raspi-config
●Select "SPI"
●Select "Yes"
●Select "OK"
●Select "Finish"

(2) Run the APA102 LED
Enter: cd /home/pi
Enter: git clone
Enter: cd /home/pi/4mics_hat
Enter: sudo apt install python-virtualenv #Install Python virtual environment
Enter: virtualenv --system-site-packages ~/env #Create a Python virtual environment
Enter: source ~/env/bin/activate #Activate the Python virtual environment
Enter: pip install spidev gpiozero #install spidev and gpiozero

Input: python #run APA102 LED, the LED will flash

4.Alexa SDK and DuerOS SD
Since Google Assistant cannot be logged in in China, Alexa and Baidu DuerOs, which can be connected in China, are used as voice engines to develop a voice mutual assistance system that can be used by most people.
(1) Configuration and DOA testing
① Configure voice engine
Enter: source ~/env/bin/activate #Activate the Python virtual environment
Enter: cd ~/4mics_hat Input: sudo apt install libatlas-base-dev #Install snowboy depend
Enter: sudo apt install python-pyaudio #Install pyaudio audio processing package
Enter: pip install ./snowboy*.whl #install snowboy for KWS
Enter: pip install ./webrtc*.whl #install webrtc for DOA
Enter: cd ~/
Enter: git clone #write by seeed
Enter: cd voice-engine/
Enter: python install
Enter: cd examples

Run python in the virtual environment. Please use snowboy to wake up, we can see the location information.

5. Baidu Chinese voice interaction/Alexa English voice interaction
(1) Configure and install related dependencies Input: source ~/env/bin/activate #activate the virtual
Enter: cd ~/
Enter: git clone
Enter: cd avs #install Requirements
Enter: python install
Enter: sudo apt install gstreamer1.0
Enter: sudo apt install gstreamer1.0-plugins-good
Enter: sudo apt install gstreamer1.0-plugins-ugly
Enter: sudo apt install python-gi gir1.2-gstreamer-1.0
Enter: pip install tornado

(2)obtain authorization
Run alexa-auth on the terminal, and then log in to obtain authorization from Alexa, or run dueros-auth to obtain authorization from Baidu. Authorization files are automatically saved at /home/pi/.avs.jason.
In China, it is usually enough to obtain Baidu's authorization, the method is as follows:

①Select baidu dueros, and then enter your own Baidu account to complete the authorization
Note: If you want to switch between alexa-auth and dueros-auth, delete /home/pi/.avs.jason first. This is a hidden file, please use ls-la to display the file

(3)Install mpg123 player
Raspberry Pi has 3 players (mpv, mpg123 and gstreamer) available, and mpg123 has a good performance in voice interaction.
Enter: sudo apt install mpg123 #Install mpg123 player

6. Baidu Chinese voice interaction test
Plug the earphone/speaker terminal into the 3.5mm audio interface of the WM8960 module to connect to the speaker (if the monitor used has HDMI audio function, it will give priority to output audio from HDMI).
After the following steps are configured correctly, you only need to enter the following 3 commands to enter the voice interaction function.
Enter: cd /4mics_hat #Open folder
Enter: source ~/env/bin/activate #Activate virtual environment
Enter: PLAYER=mpg123 python

Then the terminal will print a lot of debug information. When we see status code: 204, say snowboy to the microphone on the WM8960 module to wake up the voice interaction function.After the WM8960 voice module successfully recognizes the voice of snowboy, it will print out a lot of debugging information (if snowboy is not recognized, there will be no debugging information output),Immediately say the operation you want to perform at this time, for example: play Jacky Cheung's song, and the intelligent voice module will immediately play Jacky Cheung's music.
(Hint: the word snowboy may be more recognizable when pronounced with mobile phone translation software than with your mouth)

7.APA102 LED test
After the above steps are configured correctly, you only need to enter the following 3 commands to test the LED function.
Enter: cd ~/4mics_hat #Open folder
Enter: source ~/env/bin/activate #Activate virtual environment
Enter: python #run LED

'8. WM8960 module output volume adjustment
The volume adjustment button on the Raspberry Pi desktop is used to adjust the volume of the built-in sound card by default. To adjust the volume of the WM8960 module, you must first set the WM8960 module (seeed-2mic-voicecard) as the default sound card.
(1) Click Preferences---Audio Device Settings

(2)Sound card: seeed-2mic-voicecard (Alsa mixer), then click Make Default and OK respectively
Kind tips:
① When the environment has been configured, you only need to perform the 7th and 8th steps above to test the voice interaction function and APA102 LED at the next boot;
②Because many files in the configuration process need to be downloaded from overseas Github/Raspberry official website, the speed may be slow, please wait patiently, if the download fails, you can try multiple times!