CineAI commited on
Commit
5a785fa
1 Parent(s): 3e2a726

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -68
app.py CHANGED
@@ -57,16 +57,23 @@ def switching(text):
57
  return result
58
 
59
 
60
- def main():
61
  try:
62
  mic = mic_recorder(start_prompt="Record", stop_prompt="Stop", just_once=True, use_container_width=True)
63
  start_time = time.perf_counter()
64
- a2t = A2T(mic["bytes"]) if mic else None
65
  text = a2t.predict()
66
  print(f"Text from A2T:\n{text}")
67
  execution_time = time.perf_counter() - start_time
68
  print(f"App.py -> main() -> time of execution A2T -> {execution_time}s")
69
 
 
 
 
 
 
 
 
70
  if text and text.strip() != "":
71
  print(f"Checking for execution this part {random.randint(0, 5)}")
72
  output = switching(text)
@@ -80,72 +87,14 @@ def main():
80
  if response:
81
  st.markdown(f"Your input: {text}")
82
  st.markdown(f"Chelsea response: {response}")
83
-
84
  except Exception as e:
85
- print(f"An error occurred in main finction, reasone is: {e}")
 
 
 
 
 
86
 
87
  if __name__ == "__main__":
88
- main()
89
- footer="""
90
- <style>
91
- /* Common styles for the footer */
92
- .footer {
93
- position: fixed;
94
- left: 0;
95
- bottom: 0;
96
- width: 100%;
97
- height: 60px; /* Set a fixed height for consistency */
98
- font-size: 14px; /* Adjust font size for readability */
99
- text-align: center;
100
- padding: 15px 0; /* Reduced padding */
101
- transition: color 0.3s, background-color 0.3s;
102
- }
103
-
104
- .footer p {
105
- margin: 0; /* Remove default margins */
106
- font-size: 18px; /* Adjust font size as needed */
107
- }
108
-
109
- a:link, a:visited {
110
- text-decoration: dotted;
111
- color: inherit; /* Use current text color */
112
- }
113
-
114
- a:hover, a:active {
115
- background: linear-gradient(to right, #ffe44d, #ffdd1a, #ffd700, #ffd900);
116
- -webkit-text-fill-color: transparent;
117
- -webkit-background-clip: text;
118
- }
119
-
120
- .footer a:hover {
121
- color: #ff4500; /* Different hover color */
122
- }
123
-
124
- /* Light mode styles */
125
- @media (prefers-color-scheme: light) {
126
- a:link, a:visited {
127
- color: #0056b3; /* Blue color for links */
128
- }
129
-
130
- .footer a:hover {
131
- color: #ff4500; /* Hover color for light mode */
132
- }
133
- }
134
-
135
- /* Dark mode styles */
136
- @media (prefers-color-scheme: dark) {
137
- a:link, a:visited {
138
- color: #ffd700; /* Gold color for links in dark mode */
139
- }
140
-
141
- .footer a:hover {
142
- color: #ffa500; /* Hover color for dark mode */
143
- }
144
- }
145
- </style>
146
-
147
- <div class="footer">
148
- <p>Please support the project on <a href="https://buymeacoffee.com/cineai" target="_blank">Buy Me a Coffee</a></p>
149
- </div>
150
- """
151
- # st.markdown(footer,unsafe_allow_html=True)
 
57
  return result
58
 
59
 
60
+ def get_text():
61
  try:
62
  mic = mic_recorder(start_prompt="Record", stop_prompt="Stop", just_once=True, use_container_width=True)
63
  start_time = time.perf_counter()
64
+ a2t = A2T(mic["bytes"])
65
  text = a2t.predict()
66
  print(f"Text from A2T:\n{text}")
67
  execution_time = time.perf_counter() - start_time
68
  print(f"App.py -> main() -> time of execution A2T -> {execution_time}s")
69
 
70
+ return text
71
+ except Exception as e:
72
+ print(f"An error occurred in get_text function, reasone is: {e}")
73
+
74
+
75
+ def speaking(text):
76
+ try:
77
  if text and text.strip() != "":
78
  print(f"Checking for execution this part {random.randint(0, 5)}")
79
  output = switching(text)
 
87
  if response:
88
  st.markdown(f"Your input: {text}")
89
  st.markdown(f"Chelsea response: {response}")
90
+
91
  except Exception as e:
92
+ print(f"An error occurred in get_response function, reasone is: {e}")
93
+
94
+ def main():
95
+ text = get_text()
96
+ speaking(text)
97
+ print(f"Checking for execution main func {random.randint(0, 10)}")
98
 
99
  if __name__ == "__main__":
100
+ main()