-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyt.py
More file actions
68 lines (52 loc) · 1.61 KB
/
Copy pathyt.py
File metadata and controls
68 lines (52 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import pyttsx3
import pywhatkit
import webbrowser as web
import webbrowser
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from time import sleep
import speech_recognition as sr #pip install speechrecognition
from googletrans import Translator #pip install googletrans==3.1.0a0
def Listen():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.pause_threshold = 1
r.energy_threshold = 300
audio = r.listen(source,0,5) # Listening Mode.....
try:
print("Recognizing...")
query = r.recognize_google(audio,language="en")
except:
return ""
query = str(query).lower()
return query
# 2 - Translation
# 3 - Connect
def MicExecution():
query = Listen()
data = query
return data
MicExecution()
def Speak(Text):
engine = pyttsx3.init("sapi5")
voices = engine.getProperty('voices')
engine.setProperty('voice',voices[0].id)
engine.setProperty('rate',170)
print("")
print(f"You : {Text}.")
print("")
engine.say(Text)
engine.runAndWait()
def searchYoutube(query):
if "youtube" in query:
Speak("This is what I found for your search!")
query = query.replace("youtube search","")
query = query.replace("youtube","")
query = query.replace("jarvis","")
web = "https://www.youtube.com/results?search_query=" + query
webbrowser.open(web)
pywhatkit.playonyt(query)
Speak("Done, Sir")