Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Jarvis using python

import speech_recognition as sr
from random import choice
from utils import opening_text


def take_query():
    """Takes user input, recognizes it using Speech Recognition module and converts it into text"""

    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}')
        if not 'exit' in query or 'stop' in query:
            speak(choice(opening_text))
        else:
            hour = datetime.now().hour
            if hour >= 21 and hour < 6:
                speak("Good night sir, take care!")
            else:
                speak('Have a good day sir!')
            exit()
    except Exception:
        speak('Sorry, I could not understand. Could you please say that again?')
        take_query()
    return query
Comment

best jarvis code in python

import speech_recognition as sr
from random import choice
from utils import opening_text


def take_user_input():
    """Takes user input, recognizes it using Speech Recognition module and converts it into text"""

    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')
        if not 'exit' in query or 'stop' in query:
            speak(choice(opening_text))
        else:
            hour = datetime.now().hour
            if hour >= 21 and hour < 6:
                speak("Good night sir, take care!")
            else:
                speak('Have a good day sir!')
            exit()
    except Exception:
        speak('Sorry, I could not understand. Could you please say that again?')
        query = 'None'
    return query
Comment

PREVIOUS NEXT
Code Example
Python :: aws s3 sync boto3 
Python :: iloc[:,0:-1] 
Python :: add Elements to Python list Using append() method 
Python :: dictionary get all values 
Python :: find position of key in dictionary python 
Python :: time conversion in python 
Python :: python print array 
Python :: whitespace delimiter python 
Python :: python using shutil method 
Python :: firestore search query flutter 
Python :: python use cases 
Python :: sub function python 
Python :: minmax python 
Python :: set() python 
Python :: drop variable pandas 
Python :: python modules list 
Python :: python range 
Python :: range(n,n) python 
Python :: web3.py failing not installing 
Python :: sum two linked lists if numbers are reversed in linked list 
Python :: dataframe python diplay 2 tables on same line 
Python :: using pandas stack and subset to return a dataframe object of highly correated pairs 
Python :: python random number between x and y 
Python :: python specify multiple possible types 
Python :: osrm python 
Python :: how to find 6,6,77,8 in python 
Python :: save csv with today date pandas 
Python :: gdal warp and glob through directory 
Python :: ipython run script with command line arguments 
Python :: np random choice given distribution 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =