Update app.py
Browse files
app.py
CHANGED
@@ -36,7 +36,7 @@ def exctrator(sentence, phrase="show me your image"):
|
|
36 |
return extracted_text
|
37 |
|
38 |
def switching(text):
|
39 |
-
command = re.search("show me your image", text.lower(), re.IGNORECASE) if text is not None else "Error because your voice
|
40 |
result = None
|
41 |
|
42 |
if command:
|
@@ -57,7 +57,6 @@ def switching(text):
|
|
57 |
print(f"Prompt:\n{prompt}")
|
58 |
return result
|
59 |
|
60 |
-
|
61 |
def get_text():
|
62 |
try:
|
63 |
mic = mic_recorder(start_prompt="Record", stop_prompt="Stop", just_once=True, use_container_width=True)
|
@@ -67,11 +66,12 @@ def get_text():
|
|
67 |
print(f"Text from A2T:\n{text}")
|
68 |
execution_time = time.perf_counter() - start_time
|
69 |
print(f"App.py -> get_text() -> time of execution A2T -> {execution_time}s")
|
|
|
70 |
|
71 |
return text
|
72 |
except Exception as e:
|
73 |
-
print(f"An error occurred in get_text function,
|
74 |
-
|
75 |
|
76 |
def speaking(text):
|
77 |
try:
|
@@ -84,21 +84,22 @@ def speaking(text):
|
|
84 |
execution_time_t2a = time.perf_counter() - start_time_t2a
|
85 |
print(f"App.py -> speaking() -> time of execution T2A -> {execution_time_t2a}s")
|
86 |
print(ic.pil_image)
|
87 |
-
|
88 |
if response:
|
89 |
st.markdown(f"Your input: {text}")
|
90 |
st.markdown(f"Chelsea response: {response}")
|
91 |
|
92 |
except Exception as e:
|
93 |
-
print(f"An error occurred in speaking function,
|
94 |
|
95 |
def main():
|
96 |
-
text = get_text()
|
97 |
-
|
98 |
-
if text:
|
99 |
-
text_dict['text']
|
100 |
-
|
101 |
print(f"Text dict: {text_dict}")
|
|
|
102 |
speaking(text)
|
103 |
print(f"Checking for execution main func {random.randint(0, 10)}")
|
104 |
|
|
|
36 |
return extracted_text
|
37 |
|
38 |
def switching(text):
|
39 |
+
command = re.search("show me your image", text.lower(), re.IGNORECASE) if text is not None else "Error because your voice request is None"
|
40 |
result = None
|
41 |
|
42 |
if command:
|
|
|
57 |
print(f"Prompt:\n{prompt}")
|
58 |
return result
|
59 |
|
|
|
60 |
def get_text():
|
61 |
try:
|
62 |
mic = mic_recorder(start_prompt="Record", stop_prompt="Stop", just_once=True, use_container_width=True)
|
|
|
66 |
print(f"Text from A2T:\n{text}")
|
67 |
execution_time = time.perf_counter() - start_time
|
68 |
print(f"App.py -> get_text() -> time of execution A2T -> {execution_time}s")
|
69 |
+
text_dict['text'] = text
|
70 |
|
71 |
return text
|
72 |
except Exception as e:
|
73 |
+
print(f"An error occurred in get_text function, reason is: {e}")
|
74 |
+
return None # Повертаємо None у випадку помилки
|
75 |
|
76 |
def speaking(text):
|
77 |
try:
|
|
|
84 |
execution_time_t2a = time.perf_counter() - start_time_t2a
|
85 |
print(f"App.py -> speaking() -> time of execution T2A -> {execution_time_t2a}s")
|
86 |
print(ic.pil_image)
|
87 |
+
|
88 |
if response:
|
89 |
st.markdown(f"Your input: {text}")
|
90 |
st.markdown(f"Chelsea response: {response}")
|
91 |
|
92 |
except Exception as e:
|
93 |
+
print(f"An error occurred in speaking function, reason is: {e}")
|
94 |
|
95 |
def main():
|
96 |
+
text = get_text()
|
97 |
+
|
98 |
+
if text is None and 'text' in text_dict:
|
99 |
+
text = text_dict['text']
|
100 |
+
|
101 |
print(f"Text dict: {text_dict}")
|
102 |
+
print(f"Print text: s{text}s")
|
103 |
speaking(text)
|
104 |
print(f"Checking for execution main func {random.randint(0, 10)}")
|
105 |
|