Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -75,15 +75,15 @@ def determine_pause(audio:np.ndarray,sampling_rate:int,state:AppState) -> bool:
|
|
75 |
|
76 |
def process_audio(audio:tuple, image: Image, state:AppState):
|
77 |
if audio is None:
|
78 |
-
|
79 |
-
|
80 |
-
else:
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
if image is None:
|
88 |
state.image = {"file":""}
|
89 |
else:
|
|
|
75 |
|
76 |
def process_audio(audio:tuple, image: Image, state:AppState):
|
77 |
if audio is None:
|
78 |
+
print("Lỗi: audio là None. Kiểm tra nguồn âm thanh.")
|
79 |
+
# Xử lý lỗi, ví dụ: thoát chương trình hoặc sử dụng giá trị mặc định cho audio
|
80 |
+
else:
|
81 |
+
try:
|
82 |
+
if state.stream is None:
|
83 |
+
state.stream = np.array([], dtype=audio.dtype) # Khởi tạo với cùng kiểu dữ liệu như audio
|
84 |
+
state.stream = np.concatenate((state.stream, audio[1]))
|
85 |
+
except IndexError:
|
86 |
+
print("Lỗi: Chỉ mục vượt quá giới hạn của audio. Kiểm tra kích thước của audio.")
|
87 |
if image is None:
|
88 |
state.image = {"file":""}
|
89 |
else:
|