-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
44 lines (34 loc) · 1.15 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
import speech_recognition as sr
import pyttsx3
import find_function
def with_mic(r):
"""
function for reading data from the microphone
:param r - Recognizer:
:return void :
"""
string = ''
with sr.Microphone(device_index=1) as source: # speech recognition
audio = r.listen(source)
try:
string = r.recognize_google(audio, language="ru-RU")
except sr.UnknownValueError:
pass
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))
return string
if __name__ == "__main__":
string = ''
while 1:
r = sr.Recognizer()
string = with_mic(r)
if string.lower() == "friday" or string.lower() == "пятница":
tts = pyttsx3.init()
voices = tts.getProperty('voices')
for voice in voices:
if voice.name == "Microsoft Zira Desktop - English (United States)":
tts.setProperty('voice', voice.id)
tts.say('Yes')
tts.runAndWait()
string = with_mic(r)
find_function.find_function(string)