import speech_recognition as sr
import pyttsx3
import datetime
import wikipedia
import webbrowser
import pyjokes
def speak(text):
engine = [Link]()
[Link](text)
[Link]()
def take_command():
recognizer = [Link]()
with [Link]() as source:
audio = [Link](source)
command = recognizer.recognize_google(audio)
return [Link]()
def run_assistant():
speak("Hello! I am your voice assistant. How can I help you today?")
while True:
query = take_command()
if 'wikipedia' in query:
speak("Searching Wikipedia...")
query = [Link]("wikipedia", "")
result = [Link](query, sentences=2)
speak(result)
elif 'open youtube' in query:
[Link]("[Link]
speak("Opening YouTube...")
elif 'time' in query:
strTime = [Link]().strftime("%H:%M:%S")
speak(f"The current time is {strTime}")
elif 'joke' in query:
joke = pyjokes.get_joke()
speak(joke)
elif 'exit' in query:
speak("Goodbye!")
break
else:
speak("Sorry, I didn't understand that.")
run_assistant()