Speech to Text(Intel IoT)
Hi everyone this is a project
how to make intel edison as SpeechRecognition module
Overview:
This project is about making intel Edison Speech recognition system.
This is an module which can use any where in our IoT project
for example: you can use this module in a remote car , you can control the car using your voice instruction.
First of all configure your edison's ALSA configuration
choose your active microphone Intel can connect with microphone in two ways 1. via USB, 2. via Bluetooth.
I used Bluetooth first but I have some issues in my but device so I shifted to USB device.
Hardware Needed for This Experiment:
Intel Edison with extension board
USB sound card
Head set with microphone.
okay lets start hack..
First of all configure your edison's ALSA configuration
choose your active microphone Intel can connect with microphone in two ways 1. via USB, 2. via Bluetooth. I used Bluetooth first but I have some issues in my but device so I shifted to USB device.
Connect your USB sound card to edison
then,
root@edison1:~# lsusb
Bus 001 Device 002: ID 047f:da41 Plantronics, Inc. <<< This is my device Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
root@edison1:~# aplay -Ll
sysdefault:CARD=Headset
Plantronics USB Headset, USB Audio Default Audio Device **** List of PLAYBACK Hardware Devices **** card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM] Subdevices: 8/8 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 Subdevice #7: subdevice #7 card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
.....
......
root@edison1:~# cat /etc/asound.conf
pcm.!default sysdefault:Headset
test:
root@edison1:~# aplay /usr/share/sounds/alsa/erumbil.wav
Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono root@edison1:~#
if you her song you configure right else you should go through these steps again
How to Configure
First of all configure your edison's ALSA configuration
choose your active microphone Intel can connect with microphone in two ways 1. via USB, 2. via Bluetooth. I used Bluetooth first but I have some issues in my but device so I shifted to USB device. Connect your USB sound card to edison then, root@edison1:~# lsusb Bus 001 Device 002: ID 047f:da41 Plantronics, Inc. <<< This is my device Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub root@edison1:~# aplay -Ll sysdefault:CARD=Headset Plantronics USB Headset, USB Audio Default Audio Device **** List of PLAYBACK Hardware Devices **** card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM] Subdevices: 8/8 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 Subdevice #7: subdevice #7 card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM] ..... ...... root@edison1:~# cat /etc/asound.conf pcm.!default sysdefault:Headset test: root@edison1:~# aplay /usr/share/sounds/alsa/erumbil.wav Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono root@edison1:~# if you her song you configure right else you should go through these steps again
make sure you installed python
install python pip.
using pip install pypi,
install speech_recognition,
instal PyAudio.
Code
Then use this code and execute for speech recognition
import speech_recognition as sr
r = sr.Recognizer() with sr.WavFile("test.wav") as source: # use "test.wav" as the audio source
r.energy_threshold = 4000 audio = r.record(source) # extract audio data from the file
try:
print("You said " + r.recognize(audio)) # recognize speech using Google Speech Recognition except IndexError: # the API key didn't work
print("No internet connection")
except KeyError: # the API key didn't work
print("Invalid API key or quota maxed out")
except LookupError: # speech is unintelligible
print("Could not understand audio")
#************