import datetime
from email.mime import audio
import webbrowser
import pyttsx3
import speech_recognition as sr
import wikipedia
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice',voices[1].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def wishMe():
hour = int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
speak("Good Morning!")
elif hour>=12 and hour<18:
speak("Good Afternoon!")
else:
speak("Good Evening!")
speak("I am jarvis sir. Please tell me how may i help you")
def takecommand():
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') #Using google for voice recognition.
print(f"User said: {query}\n")
except Exception as e:
print("Say that again please...")
return "None"
return query
if __name__=="_main_":
wishMe()
while True:
query = takecommand().lower()
if 'wikipedia' in query:
speak('searching wikipedia...')
query = query.replace("wikipedia","")
results = wikipedia.summary(query,sentences=2)
speak("According to wikipedia")
speak(results)
elif'open youtube' in query:
webbrowser.open("youtube.com")
elif'google' in query:
webbrowser.open("google.com")
(i have been trying to solve this problem for one week, I am using visual code for done my code and i am using Microsoft window 10 there 2 voices that is zira and David but both are not working) i have tried to add another voice from voicecoreone but after doing all procedure there is no voice is showing in my terminal except zira and david.