Ejemplo n.º 1
0
def listen():
    r = sr.recognizer()
    with sr.Microphone as source:
        audio = r.listen(source)
        try:
            text = r.recognize_googel(audio)
            return True, text
        except:
            return False, 'error'
Ejemplo n.º 2
0
def takeCommand():
    r = sr.recognizer()
    with sr.Microphone() as source:
        r.pause_threshold = 1
        audio = r.listen(source)
        try:
            query = r.recognize_google(audio, language='en-in')  # Using google for voice recognition.

        except Exception as e:
            print("Say that again please...")  # Say that again will be printed in case of improper voice

        return query
Ejemplo n.º 3
0
def take_command():
    with sr.Microphone as source:
        r = sr.recognizer()
        print("listening....")
        r.pause_threshold = 1
        audio = r.listen(source)
    try:
        print("recognizing.....")
        query = r.recognize_google(audio, language='en_in')
        print(f"users said: {query}\n")
    except Exception as e:
        print('again say')
        return None
    return query
Ejemplo n.º 4
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
Ejemplo n.º 5
0
def recordAudio():
    rec = sr.recognizer()
    with sr.Microphone() as source:
        print("Speak up please")
    audio = rec.listen(source)

    #store data

    data_stored = ""

    #check error and exception

    try:
        data_stored = rec.recognize_google(audio)  #use googleAPI
        print("You said: " + data_stored)
    except sr.UnknownValueError:
        print("Repeat please, I can not understand you")
    except sr.RequestError as e:  #In case a file is missing on demand
        print("Couldn't request results; {0}".format(e))
        return data_stored
import speech_recognition as sr

r=sr.recognizer()

with r.Microphone() as mr:
    audio=r.listen(mr)

    try:
        text=r.recognize_google(audio)
        print(text)
    except:
        print("cantpython")