-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
54 lines (33 loc) · 1.18 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import pyttsx3 as tts
import speech_recognition as sr
import gpt
import pywhatkit as pt
def starts():
engine=tts.init()
rate=engine.getProperty('rate')
engine.setProperty('rate',120)
voice=engine.getProperty('voices')
engine.setProperty('voice',voice[1].id)
def speak(output_text):
engine.say(output_text)
engine.runAndWait()
r=sr.Recognizer()
while True:
with sr.Microphone() as scr:
r.energy_threshold=10000
r.adjust_for_ambient_noise(scr,1.2)
print("listening to you...")
try:
audio_input=r.listen(scr)
text_from_audio=r.recognize_google(audio_input)
print(text_from_audio)
if "play" and "video" and "song" in text_from_audio:
pt.playonyt(text_from_audio)
else:
output_text=gpt.palm_output(text_from_audio)
print(output_text)
speak(output_text)
except Exception or RuntimeError:
speak("BYE")
print("BYE")
break