-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.py
More file actions
23 lines (21 loc) · 755 Bytes
/
Copy pathcommand.py
File metadata and controls
23 lines (21 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from texttospeach import speak
import wikipedia # type: ignore
import pywhatkit # type: ignore
from datetime import datetime
def process_command(command):
if 'wikipedia' in command:
topic = command.replace("wikipedia", "").strip()
summary = wikipedia.summary(topic, sentences=2)
speak(f"According to Wikipedia, {summary}")
elif 'play' in command:
song = command.replace("play", "").strip()
speak(f"Playing {song}")
pywhatkit.playonyt(song)
elif 'time' in command:
time = datetime.now().strftime("%I:%M %p")
speak(f"The time is {time}")
else:
speak("Sorry, I didn't understand that command.")
# Example usage
command = "play Imagine Dragons"
process_command(command)