Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import speech_recognition as sr
- from time import ctime
- import os
- from gtts import gTTS
- import requests
- import json
- import pyautogui
- def listen():
- r = sr.Recognizer()
- with sr.Microphone() as source:
- print("SPEAK NOW...")
- audio = r.listen(source)
- data = ""
- try:
- data = r.recognize_google_cloud(audio)
- print("I heard :" + data)
- except sr.UnknownValueError:
- print("Im sorry I didnt understand you!")
- except sr.RequestError as e:
- print("Request Failed; {0}".format(e))
- return data
- def respond(audiostring):
- print(audiostring)
- tts = gTTS(text=audiostring, lang='en')
- tts.save("speech.mp3")
- os.system("mpg321 speech.mp3")
- def nebula(data):
- if "What is your name"in data:
- listening = True
- respond("My name is Nebula")
- if "how are you?" or "how are you doing?" or "How's it going" or "hows it hanging?" in data:
- listening = True
- respond("I'm Great! Enough about me Lets get to work!")
- if "Nebula" or "Hey Nebula" in data:
- listening = True
- respond("Hello Sir, What can I do for you?")
- if "What is the time?" or "Time" or "Gimme the time now" in data:
- listening = True
- respond(ctime())
- if "Screenshot" or "Take a picture of the screen" in data:
- listening = True
- pyautogui.keyDown('Fn')
- pyautogui.keyDown('winleft')
- pyautogui.keyDown('space')
- pyautogui.keyUp('Fn')
- pyautogui.keyUp('winleft')
- pyautogui.keyUp('space')
- respond("Screenshot Taken")
- if "fullscreen" or "disable fullscreen" in data:
- listening = True
- pyautogui.press('F11')
- respond("Window is now in Fullscreen")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement