-
Notifications
You must be signed in to change notification settings - Fork 0
/
J.A.R.V.I.S..py
34 lines (30 loc) · 1.11 KB
/
J.A.R.V.I.S..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
import speech_recognition
sr = speech_recognition.Recognizer()
sr.pause_threshold = 0.5
def listen_comand():
try:
with speech_recognition.Microphone() as mic:
sr.adjust_for_ambient_noise(source=mic, duration=0.5)
audio = sr.listen(source=mic)
query = sr.recognize_google(audio_data=audio, language='ru-RU').lower()
return query
except speech_recognition.UnknownValueError:
return 'Damn... Не понял что ты сказал'
def greeting():
return 'Привет!'
def create_task():
print('Что добавим в список дел?')
query = listen_comand()
with open('todo-list.txt','a') as file:
file.write(f'{query}\n')
return f'Задача {query} добавлена в todo-list!'
def main():
query = listen_comand()
if query == 'привет друг':
print(greeting())
elif query == 'добавить задачу':
print(create_task())
else:
print('Прожуй потом разговаривай!')
if __name__=='__main__':
main()