-
Notifications
You must be signed in to change notification settings - Fork 4
/
Identification_Name.py
97 lines (47 loc) · 1.77 KB
/
Identification_Name.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import configparser
import random
from speech_recognition import Microphone, Recognizer, AudioFile, UnknownValueError, RequestError
import Speak
def voice_Text():
recognition = Recognizer()
mic = Microphone()
with mic:
recognition.adjust_for_ambient_noise(mic, duration=0.2)
print("Talk")
audio = recognition.record(mic, 5)
try:
recognized = recognition.recognize_google(audio)
print('You Said : ', recognized)
return recognized
except UnknownValueError:
print('Unable to Recognize audio')
return 'None'
except RequestError as error:
print('Error Detected : ', error)
return 'None'
return recognized
response: list = ["your name is", "you are", "i know your name"]
donut_know: list = ["i still don't know you so what is your name", "i am still learning please tell me your name", "i don't know but i love to know that, so whats your name"]
got_it: list = ["got it", "ok now i know it", "thank you for help me for learn"]
def name_operations():
parser = configparser.ConfigParser()
parser.read("config.ini")
name = parser.get("config", "user_name")
if name == "notset_yet":
Speak.Speak(random.choice(donut_know))
names = voice_Text().lower()
if names == 'none':
names = voice_Text().lower()
else:
update_name(names)
else:
Speak.Speak(random.choice(response))
Speak.Speak(name)
def update_name(name):
edit = configparser.ConfigParser()
edit.read("config.ini")
user_section = edit["config"]
user_section["user_name"] = name
with open('config.ini', 'w') as configfile:
edit.write(configfile)
Speak.Speak(random.choice(got_it))