Esempio n. 1
0
def get_info():
    try:
        with sr.microphone() as source:
            print('Listening.....')
            voice = listener.listen(source)
            info = listener.recognize_google(voice)
            print(info)
            return info.lower()
    except:
        pass
Esempio n. 2
0
def TakeCommand():
    r=sr.Recognizer()
    with sr.microphone() as source:
        print('listening.........')
        audio=r.listen(sourse)#start listening

    try:
        print('recognising...........')
        query = r.recognize_google(audio)
        print(f"you said {query}")
    except Exception as e:
        print('plz try again something may wrong happend...........')
    return query.lower()
Esempio n. 3
0
def mycomand():
    r = sr.recognizer()

    with sr.microphone() as source:
        print("your slave is ready to listen to you ")
        r.pause_threshold = 2
        r.adjust_ambient_noise(source, duration=2)
        audio = r.listen(source)
    try:
        command = r.recognize_google(audio)
        print(" shen mitxari" + command + "\n")

    #loop avs mosmenas ro gaagrdzelos mosmena tu ver mixvda ra vitxarit comandshi
    except sr.UnknownValueError:
        asistent(mycomand())
    return comand
def takeCommand():
    # It takes microphone input from the user and return string output
    r = sr.Recognizer()
    with sr.microphone() as source:
        print("Listening...")
        r.pause_threshold = 1
        audio = r.listen(source)

    try:
        print("Recognizing/...")
        query = r.recognize_google(audio, Language='en-in')
        print(f"User said: {query}\n")
    except Exception as e:
        # print(e)
        print("please Pardon...")
        return "None"
    return query
Esempio n. 5
0
import speech_recognition as sr

#record audio
r = sr.Recognizer()
with sr.microphone() as source:
	r.adjust_for_ambient_noise(source,duration=5)
	r.dynamic_energy_threshold = True
	print("say something!")
	audio = r.listen(source)

# speech recognition using google speech recognition
try:
	# for testing purposes, we're just using the default api key
	# to use another api key, use r.recognise_google(audio, key="google_speech_recognition_api_key")
	# instead of 'r.recognise_google(audio)'
	print("you said: " + r.recognise_google(audio))
except sr.UnknownValueError:
	print("google speech Recognition could not understand audio")
except sr.RequestError as e:
PRINT("cloud not request results from google speech recognition service; {0}" ,format(e))