Speech Recognition is an important feature in several applications used such as home automation, artificial intelligence, etc. This article aims to provide an introduction on how to make use of the SpeechRecognition and pyttsx3 library of Python.
For speech recognition we need to install SpeechRecognition package via PIP
pip install SpeechRecognition
After installing the package we need to copy and paste following code an run our program
import speech_recognition as sr # importing pachage r=sr.Recognizer() print(sr.Microphone.list_microphone_names()) # checking for microphone with sr.Microphone() as source: r.adjust_for_ambient_noise(source,duration=1) # r.energy_threshold() print("say anything : ") audio= r.listen(source) try: text = r.recognize_google(audio) print(text) except: print("sorry, could not recognise")