-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
45 lines (36 loc) · 1.05 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
import speech_recognition as sr
# empty string
note = ""
# Functions
def takeNotes():
'''It takes microphone input from the user and returns a string output'''
global note
recogniser = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
recogniser.pause_threshold = 1
audio = recogniser.listen(source)
try:
print("Recognizing...")
note = recogniser.recognize_google(audio, language="en-in")
# print(note)
except Exception as e:
print(e)
def writeNotes():
'''Writing the notee in the text file'''
global note
with open("notes.txt", "a+") as file:
file.writelines(note)
file.writelines("\n")
print("Notes written !")
if __name__ == '__main__':
takeNotes()
writeNotes()
while True:
ask = input("Do you want to take more inputs?[y/N]: ")
if ask == "y":
takeNotes()
writeNotes()
if ask == "N":
print("Thanks For using us !")
break