File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ import pyttsx3
2+ import webbrowser
3+
4+ # Initialize the text-to-speech engine
5+ search = pyttsx3 .init ("sapi5" )
6+
7+ # Set the voice to a female voice
8+ voices = search .getProperty ("voices" )
9+ search .setProperty ("voice" , voices [1 ].id )
10+
11+ while True :
12+ # Get user input
13+ user_input = input ("Enter your text: " ).lower ()
14+
15+ # Open YouTube if the user wants to go to YouTube
16+ if "youtube" in user_input :
17+ search .say ("Opening YouTube, just wait a while" )
18+ search .runAndWait ()
19+ webbrowser .open ("https://www.youtube.com/" )
20+
21+ # Search Google if the user wants to search for something
22+ elif "search" in user_input :
23+ search .say ("What do you want to search from Google?" )
24+ search .runAndWait ()
25+ search_items = input ("Give your search keyword: " ).lower ()
26+ search .say ("Opening your search items, just wait a while" )
27+ search .runAndWait ()
28+ webbrowser .open (f"https://www.google.com/search?q={ search_items } " )
29+
30+ # If the user input doesn't match any of the above, ask them to try again
31+ else :
32+ search .say ("Oops! Please try again." )
33+ search .runAndWait ()
You can’t perform that action at this time.
0 commit comments