Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -54,10 +54,10 @@ def predict(_chatbot, task_history, user_input):
|
|
54 |
audio_idx = 1
|
55 |
pre = ""
|
56 |
last_audio = None
|
57 |
-
for
|
58 |
if len(item) != 2:
|
59 |
print(f"Error: Expected a tuple of length 2, but got {item}")
|
60 |
-
continue
|
61 |
q, a = item
|
62 |
if isinstance(q, (tuple, list)):
|
63 |
last_audio = q[0]
|
@@ -115,28 +115,24 @@ def regenerate(_chatbot, task_history):
|
|
115 |
_chatbot.append((chatbot_item[0], None))
|
116 |
return predict(_chatbot, task_history)
|
117 |
|
|
|
118 |
def add_text(history, task_history, text):
|
119 |
-
history
|
120 |
-
task_history
|
121 |
return history, task_history, ""
|
122 |
|
123 |
def add_file(history, task_history, file):
|
124 |
-
history
|
125 |
-
task_history
|
126 |
return history, task_history
|
127 |
|
128 |
def add_mic(history, task_history, file):
|
129 |
if file is None:
|
130 |
return history, task_history
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
# history = history + [((file.name,), None)]
|
136 |
-
# task_history = task_history + [((file.name,), None)]
|
137 |
-
task_history = task_history + [((file + '.wav',), None)]
|
138 |
-
history = history + [((file + '.wav',), None)]
|
139 |
-
print("task_history", task_history)
|
140 |
return history, task_history
|
141 |
|
142 |
def reset_user_input():
|
|
|
54 |
audio_idx = 1
|
55 |
pre = ""
|
56 |
last_audio = None
|
57 |
+
for item in task_history:
|
58 |
if len(item) != 2:
|
59 |
print(f"Error: Expected a tuple of length 2, but got {item}")
|
60 |
+
continue
|
61 |
q, a = item
|
62 |
if isinstance(q, (tuple, list)):
|
63 |
last_audio = q[0]
|
|
|
115 |
_chatbot.append((chatbot_item[0], None))
|
116 |
return predict(_chatbot, task_history)
|
117 |
|
118 |
+
|
119 |
def add_text(history, task_history, text):
|
120 |
+
history.append((_parse_text(text), None))
|
121 |
+
task_history.append((text, None))
|
122 |
return history, task_history, ""
|
123 |
|
124 |
def add_file(history, task_history, file):
|
125 |
+
history.append(((file.name,), None))
|
126 |
+
task_history.append(((file.name,), None))
|
127 |
return history, task_history
|
128 |
|
129 |
def add_mic(history, task_history, file):
|
130 |
if file is None:
|
131 |
return history, task_history
|
132 |
+
file_with_extension = file + '.wav'
|
133 |
+
os.rename(file, file_with_extension)
|
134 |
+
history.append(((file_with_extension,), None))
|
135 |
+
task_history.append(((file_with_extension,), None))
|
|
|
|
|
|
|
|
|
|
|
136 |
return history, task_history
|
137 |
|
138 |
def reset_user_input():
|