0% found this document useful (0 votes)
18 views1 page

# Simple Desktop Assistant Example

The document presents a simple desktop assistant example using Python, which incorporates speech recognition and text-to-speech functionalities. It allows users to ask questions about Wikipedia topics, open Notepad, or exit the program. The assistant listens for voice commands and responds accordingly.

Uploaded by

ak9346332
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views1 page

# Simple Desktop Assistant Example

The document presents a simple desktop assistant example using Python, which incorporates speech recognition and text-to-speech functionalities. It allows users to ask questions about Wikipedia topics, open Notepad, or exit the program. The assistant listens for voice commands and responds accordingly.

Uploaded by

ak9346332
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

# Simple Desktop Assistant Example

import speech_recognition as sr
import pyttsx3
import wikipedia
import os

engine = [Link]()

def speak(text):
[Link](text)
[Link]()

def listen():
r = [Link]()
with [Link]() as source:
print("Listening...")
audio = [Link](source)
try:
command = r.recognize_google(audio)
print("You said:", command)
return [Link]()
except:
speak("Sorry, I didn't catch that.")
return ""

def main():
speak("How can I help you?")
while True:
command = listen()
if "wikipedia" in command:
topic = [Link]("wikipedia", "")
result = [Link](topic, sentences=2)
speak(result)
elif "open notepad" in command:
[Link]("[Link]")
elif "exit" in command:
speak("Goodbye!")
break

if __name__ == "__main__":
main()

You might also like