Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import wikipedia
- import speech_recognition as sr
- import datetime
- import time
- import os
- import requests
- import json
- import pyautogui
- import pyttsx3
- import webbrowser
- import google
- engine = pyttsx3.init('sapi5')
- voices = engine.getProperty('voices')
- for voice in voices:
- engine.getProperty('voices')
- engine.setProperty('voice', voices[1].id)
- rate = engine.setProperty('rate', 170)
- def speak(audio):
- engine.say(audio)
- engine.runAndWait()
- def Greet_1():
- speak('Hello sir! My name is Nebula, How may I assist you?')
- def greeting():
- hour = int(datetime.datetime.now().hour)
- if hour >= 0 and hour<12:
- speak('Good Morning Nic!')
- elif hour>12 and hour<16:
- speak('Good Afternoon Mr. Decker!')
- else:
- speak('Good Evening Sir')
- speak('How may I assist you?')
- def listening():
- # takes microphone input and converts it to text
- r = sr.Recognizer()
- with sr.Microphone() as source:
- r.adjust_for_ambient_noise(source)
- print('Speak Now...')
- r.pause_threshold = 1
- audio = r.listen(source)
- try:
- print('Thinking...')
- query = r.recognize_google(audio, language = 'en-in')
- print('User said:\n')
- print(query)
- except Exception as e:
- print("Sorry I couldnt understand you.")
- return'None'
- return query
- if __name__ == "__main__":
- greeting()
- while True:
- query = listening().lower()
- if 'wikipedia' in query:
- speak('Getting Knowledge')
- query = query.replace('wikipedia', '')
- results = wikipedia.summary(query, sentences = 3)
- speak('here is what i found on wikipedia.')
- speak(results)
- print(results)
- elif 'your name' in query:
- speak('My name is Nebula')
- elif 'shut down' in query:
- speak('shutting down system')
- os.system("shutdown /s /t 1")
- elif 'restart' in query:
- speak('restarting system')
- os.system("shutdown /r /t 1")
- elif 'close' in query:
- pyautogui.hotkey('alt','f4')
- speak('Program closed!')
- elif 'time' in query:
- speak('Nic, the time is')
- elif 'Steam' in query:
- speak("steam running")
- elif 'your day' in query:
- speak('My day is good')
- speak('How is your day going')
- elif 'my day is going good' in query:
- speak('Im glad to hear that! Lets keep having a good day!')
- elif 'my day was bad' in query:
- speak('Im sorry to hear that! Can i be of any assistance?')
- elif 'google' in query:
- webbrowser.open("google.com")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement