Answers for "speech to text recognition using pyttsx3 in python"

5

python speech recognition

import speech_recognition as sr

def take_command():
    r = sr.Recognizer()
    with sr.Microphone() as source:
        print('Listening...')
        r.pause_threshold = 1
        r.energy_threshold = 50
        audio = r.listen(source)

    try:
        print('Recognizing...')
        qry = r.recognize_google(audio, language='en-in')
        print(f"user said: {qry}n")
        
#     if any error occurs this line will run
    except Exeption as e:
    # if you don't want to print the error comment the bottom line
        print(e)
        print('Say that again pleasen')
        return 'None'

    return qry
  
if __name__ == '__main__':
	while True:
  		qry = takecommand().lower()
  
# now you can use the takecommand function where you want to recognize speech
# And please experiment with the above code 
# like what pause_threshold and energy_threshold do 
///////////---  *HAPPYCODING*  ---///////////
Posted by: Guest on February-25-2021
1

how to use speech recognition in python

import speech_recognition as sr
recognizer = sr.Recognizer()
microphone = sr.Microphone()
with microphone as source:
    recognizer.adjust_for_ambient_noise(source)
    audio = recognizer.listen(source)
    command = recognizer.recognize_google(audio)
    print(command)
Posted by: Guest on October-26-2021

Code answers related to "speech to text recognition using pyttsx3 in python"

Python Answers by Framework

Browse Popular Code Answers by Language