-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
76 lines (58 loc) · 2.03 KB
/
utils.py
File metadata and controls
76 lines (58 loc) · 2.03 KB
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
from services.general_services.language_translate import LanguageTranslate
from speech_recognition_engine import SpeechTextEngine
from speech_text_client import speechTextClient
sr = speechTextClient
def recheck(type: str, value: str):
'''
description:
it affirming the input text; is that a valid input or not ?
inputs:
type = "what type of input is this";
eg:- if it's checking for the affirmation of
project name then: type = "project name"
value = text / the input from speech recoginition
outputs:
if text != empty then:
return text
else:
repeatly asking for the text until get a "none empty text"
'''
while True:
sr.speak(f'your {type} is ' + value)
sr.speak(" is that right?")
command = sr.speech_recognition()
command = nullcheck(command)
command = yes_or_no(command)
if command == "yes":
return value
sr.speak(f"ok tell me the {type} once more sir!")
value = sr.speech_recognition()
value = nullcheck(value)
def nullcheck(value: str):
'''
description:
it check if the text is empty or not
inputs:
value = text / the input from speech recoginition
outputs:
if text != empty then:
return text
else:
repeatly asking for the text until get a "none empty text"
'''
while value == "":
sr.speak("i didn't get it sir, please tell me once more")
value = sr.speech_recognition()
sr.speak("ok")
return value
def yes_or_no(command: str):
yes = ["yes", "yea", "i want", "do it", "yeah", "yee", "ya", "yaa" "z", "yep", "yeap"
"that's right", "proceed", "ok", "ahaa", "go on", "i want", "yeh", "doit", "create"]
no = ["nah", "no", "don't", "not", "na", "n", "don't", "never"]
for word in no:
if word in command:
return "no"
for word in yes:
if word in command:
return "yes"
return "nan"