Skip to content

Latest commit

 

History

History

raspberry-pi-speech-recognition

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Raspberry Pi Speech Recognition

Raspberry Pi Setup

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install python3

Install VS Code

$ sudo apt install code
$ code .

Then:

  • Install Python Extension
  • Preferences: Configure Runtime Arguments --> Set "disable-hardware-acceleration": true

Install PyAudio

$ sudo apt install libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev flac
$ python3 -m venv venv
$ . venv bin activate
$ pip install pyaudio requests websockets

Configure USB micophone

$ lsusb
$ arecord -l
$ cat /proc/asound/cards
$ cat /proc/asound/modules

Set the default card in:

$ sudo nano /usr/share/alsa/alsa.conf

E.g. for card 2:

defaults.ctl.card 2
defaults.pcm.card 2

Save the file and reboot:

$ sudo reboot

Test sound recording

$ arecord -d 5 -r 48000 test.wav
$ aplay test.wav

Test PyAudio code

import pyaudio
p = pyaudio.PyAudio()

for i in range(p.get_device_count()):
    print(p.get_device_info_by_index(i).get('name'))

Real-Time Speech Recognition

Run sr.py:

$ python sr.py