-
Notifications
You must be signed in to change notification settings - Fork 2
/
input_engine.py
39 lines (35 loc) · 1.26 KB
/
input_engine.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
import speech_recognition as sr
import sys
import colorama
import winsound
from chronicle_engine import chronicle_log
from colorama import Fore, Back
colorama.init(autoreset=True)
def casper_input(input_src, log_var):
if input_src == 1:
print()
text = input(Fore.CYAN + " Enter prompt: ")
try:
u_said = text
print()
chronicle_log(f"[text] {u_said}".center(100), var=log_var)
return u_said
except:
return 0
r = sr.Recognizer()
audio = ""
with sr.Microphone() as source:
# print("")
# print(Fore.YELLOW + "Listening...".center(100))
audio = r.listen(source, phrase_time_limit=15)
#print(Fore.BLUE + "Processing...".center(100))
try:
u_said = r.recognize_google(audio, language='en-US')
print(f"(●) {u_said}".center(100))
print(Fore.LIGHTBLACK_EX + "Processing...".center(100))
chronicle_log(f"(●) {u_said}".center(100), var=log_var)
chronicle_log(Fore.LIGHTBLACK_EX + "Processing...".center(100), var=log_var)
return u_said
except:
#print(Fore.LIGHTBLACK_EX + "Awaiting command.".center(100))
return 0