Skip to content

Commit f7952c0

Browse files
authored
Create PlayTasks.py
1 parent 83f6981 commit f7952c0

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src_A2/PlayTasks.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pywhatkit.misc as kit
2+
import VoiceEngine
3+
import webbrowser as web
4+
import re
5+
import SpeechRecogniter
6+
7+
def play(strcommand):
8+
strcommand.replace("play", "")
9+
if "spotify" in strcommand:
10+
spotify(strcommand)
11+
elif "youtube" in strcommand:
12+
youtube(strcommand)
13+
else:
14+
VoiceEngine.say("Sorry, I can't Determine The PlatForm To Play . I support only YouTube and Spotify.")
15+
VoiceEngine.say("Can You Tell Me Which PlatForm Do You Like To Play The Song")
16+
command = str(SpeechRecogniter.getinput()).lower()
17+
if "youtube" in command or "spotify" in command : play(command)
18+
else : VoiceEngine.say("Sorry I Unable To Play It.")
19+
20+
def youtube(strcommand):
21+
strcommand = re.sub(r"(play|youtube|on)", "", strcommand)
22+
VoiceEngine.say("Starting YouTube to play " + strcommand)
23+
kit.playonyt(strcommand)
24+
25+
def spotify( strcommand):
26+
strcommand = re.sub(r"(play|spotify|on)", "", strcommand)
27+
VoiceEngine.say("Starting Spotify to play " + strcommand)
28+
web.open_new_tab("https://open.spotify.com/search/" + strcommand)

0 commit comments

Comments
 (0)