1

I have a problem that when I use SpeechRecognition library in python and when I want to put r.listen(source)in while loop my code drasticly slows down.

import speech_recognition as sr
import pyttsx3 as p
import random
from talk import *


r = sr.Recognizer()
engine = p.init()


    
with sr.Microphone() as source:
    while 0<1:
        text = r.listen(source)
        try:
            recognised_text = r.recognize_google(text)
            print(recognised_text)
            if (recognised_text =="hello" or recognised_text =="hi"):
                greeting()
        except sr.UnknownValueError:
            print("")
        except sr.RequestError as e:
            print("")

0 Answers0