├── amigo.py └── requirements.txt /amigo.py: -------------------------------------------------------------------------------- 1 | import pyttsx3 2 | import speech_recognition as sr 3 | import wikipedia 4 | import webbrowser 5 | import os 6 | 7 | # init pyttsx 8 | engine = pyttsx3.init("sapi5") 9 | voices = engine.getProperty("voices") 10 | 11 | engine.setProperty('voice', voices[1].id) # 1 for female and 0 for male voice 12 | 13 | 14 | def speak(audio): 15 | engine.say(audio) 16 | engine.runAndWait() 17 | 18 | 19 | def take_command(): 20 | r = sr.Recognizer() 21 | with sr.Microphone() as source: 22 | print("Listening...") 23 | r.pause_threshold = 1 24 | audio = r.listen(source) 25 | try: 26 | print("Recognizing...") 27 | query = r.recognize_google(audio, language='en-in') 28 | print("User said:" + query + "\n") 29 | except Exception as e: 30 | print(e) 31 | speak("I didnt understand") 32 | return "None" 33 | return query 34 | 35 | 36 | if __name__ == '__main__': 37 | 38 | speak("Amigo assistance activated ") 39 | speak("How can i help you") 40 | while True: 41 | query = take_command().lower() 42 | if 'wikipedia' in query: 43 | speak("Searching Wikipedia ...") 44 | query = query.replace("wikipedia", '') 45 | results = wikipedia.summary(query, sentences=2) 46 | speak("According to wikipedia") 47 | speak(results) 48 | elif 'are you' in query: 49 | speak("I am amigo developed by Jaspreet Singh") 50 | elif 'open youtube' in query: 51 | speak("opening youtube") 52 | webbrowser.open("youtube.com") 53 | elif 'open google' in query: 54 | speak("opening google") 55 | webbrowser.open("google.com") 56 | elif 'open github' in query: 57 | speak("opening github") 58 | webbrowser.open("github.com") 59 | elif 'open stackoverflow' in query: 60 | speak("opening stackoverflow") 61 | webbrowser.open("stackoverflow.com") 62 | elif 'open spotify' in query: 63 | speak("opening spotify") 64 | webbrowser.open("spotify.com") 65 | elif 'open whatsapp' in query: 66 | speak("opening whatsapp") 67 | loc = "C:\\Users\\jaspr\\AppData\\Local\\WhatsApp\\WhatsApp.exe" 68 | os.startfile(loc) 69 | elif 'play music' in query: 70 | speak("opening music") 71 | webbrowser.open("spotify.com") 72 | elif 'play music' in query: 73 | speak("opening music") 74 | webbrowser.open("spotify.com") 75 | elif 'local disk d' in query: 76 | speak("opening local disk D") 77 | webbrowser.open("D://") 78 | elif 'local disk c' in query: 79 | speak("opening local disk C") 80 | webbrowser.open("C://") 81 | elif 'local disk e' in query: 82 | speak("opening local disk E") 83 | webbrowser.open("E://") 84 | elif 'sleep' in query: 85 | exit(0) 86 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | beautifulsoup4==4.12.2 2 | certifi==2023.11.17 3 | charset-normalizer==3.3.2 4 | comtypes==1.2.1 5 | idna==3.6 6 | pyttsx3==2.90 7 | requests==2.31.0 8 | soupsieve==2.5 9 | SpeechRecognition==3.10.1 10 | typing_extensions==4.9.0 11 | urllib3==2.1.0 12 | wikipedia==1.4.0 13 | --------------------------------------------------------------------------------