import Rand as p import speech_recognition as sr from web import * from YT_auto import * from News import * import randfacts from jokes import * from weather import * import datetime
engine = p.init() rate = engine.getProperty('rate') engine.setProperty('rate',180) voices = engine.getProperty('voices') engine.setProperty('voice',voices[1].id)
def speak(text): engine.say(text) engine.runAndWait()
r = sr.Recognizer() speak("hello sir, I'm your voice assistant") speak("now the temperature in your area is " + str(temp())+"degree celcius" + " and with " + str(des())) speak("how are you")
with sr.Microphone() as source: r.energy_threshold = 10000 r.adjust_for_ambient_noise(source,1.0) print("listening..") audio = r.listen(source) text = r.recognize_google(audio) print(text) if "what" and "about" and "you" in text: speak("I'm doing fine") speak("what can i do for you")
with sr.Microphone() as source: r.energy_threshold = 10000 r.adjust_for_ambient_noise(source,1.0) print("Listening..") audio = r.listen(source) text2 = r.recognize_google(audio) print(text2)
if "information" in text2: speak("which topic you want to search for?")
with sr.Microphone() as source:
r.energy_threshold = 10000
r.adjust_for_ambient_noise(source, 1.0)
print("Listening..")
audio = r.listen(source)
infor = r.recognize_google(audio)
speak("searching in wikipedia...")
print("searching in wikipedia...")
assist = infow()
assist.get_info(infor)
elif "play" and "video" in text2: speak("you want me to play which video?") with sr.Microphone() as source: r.energy_threshold = 10000 r.adjust_for_ambient_noise(source, 1.0) print("Listening..") audio = r.listen(source) vid = r.recognize_google(audio) speak("Playing on Youtube") print("Playing on Youtube") assist = music() assist.play(vid)
elif "news" in text2: print("Here are some latest news for you") speak("Here are some latest news for you") arr=news() for i in range(len(arr)): print(arr[i]) speak(arr[i])
elif "fact" in text2: speak("sure sir,") x=randfacts.get_fact() print(x) speak("Did you know that,"+x)
elif "joke" in text2: speak("sure sir, get ready for some chuckles") ar=joke() print(ar[0]) speak(ar[0]) print(ar[1]) speak(ar[1])
import requests from ss import *
api_address='http://api.openweathermap.org/data/2.5/weather?q=Delhi&appid='+key2 json_data=requests.get(api_address).json()
def temp(): temprature = round(json_data["main"]["temp"]-273,1) return temprature def des(): description=json_data["weather"][0]["description"] return description
#print(temp()) #print(des())
import requests
url = "https://official-joke-api.appspot.com/random_joke" json_data=requests.get(url).json()
arr=["",""] arr[0]=json_data["setup"] arr[1]=json_data["punchline"] def joke(): return arr
#print(arr[0]) #print(arr[1])
import requests from ss import *
api_address= "https://newsapi.org/v2/top-headlines?country=us&apikey="+key json_data = requests.get(api_address).json()
ar=[]
def news(): for i in range(3): ar.append("Number" + str(i+1) + json_data["articles"][i]["title"]+".")
return ar
key = "56e00db26ae549119ff485314e75bbf8"
key2="029050a08162d0af2cce3b7beae3885b"