-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
31 lines (26 loc) · 781 Bytes
/
main.py
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
!pip install PyAudio
!pip install SpeechRecognition
import speech_recognition as sr
import pyaudio
import webbrowser as wb
r1 = sr.Recognizer()
r2 = sr.Recognizer()
r3 = sr.Recognizer()
with sr.Microphone() as source:
print("[search Google : search Youtube]")
print("Speak Now!!")
audio = r3.listen(source)
if 'video' in r1.recognize_google(audio):
r1 = sr.Recognizer()
url = 'https://www.youtube.com/results?search_query='
with sr.Microphone() as source:
print("Search for video")
audio = r1.listen(source)
try:
get = r1.recognize_google(audio)
print(get)
wb.get().open_new(url+get)
except sr.UnknownValueError:
print("Couldn't understand")
except sr.RequestError as e:
print("Failed to get results".format(e))