Spaces:
Build error
Build error
Add comprehensive debug logging throughout _diarize_action
Browse files
app.py
CHANGED
|
@@ -54,21 +54,29 @@ def _diarize_action(
|
|
| 54 |
device: str,
|
| 55 |
url: str | None = None,
|
| 56 |
):
|
|
|
|
|
|
|
|
|
|
| 57 |
if not audio_path and not url:
|
| 58 |
empty_state = ["", "", "", ""]
|
| 59 |
-
return "Vui lòng tải file âm thanh hoặc nhập URL.", None, None, [], [], empty_state,
|
| 60 |
try:
|
| 61 |
downloaded_path = None
|
| 62 |
download_tmp = None
|
| 63 |
audio_input = audio_path
|
| 64 |
if url:
|
|
|
|
| 65 |
downloaded_path, download_tmp = download_audio_from_url(url)
|
| 66 |
audio_input = str(downloaded_path)
|
|
|
|
| 67 |
|
|
|
|
| 68 |
engine = _get_engine(_token_key(hf_token), device)
|
|
|
|
| 69 |
diarization, prepared_path, prep_tmpdir = engine.diarize(
|
| 70 |
audio_input, show_progress=False, keep_audio=True
|
| 71 |
)
|
|
|
|
| 72 |
segments = engine.to_segments(diarization)
|
| 73 |
dict_segments = [
|
| 74 |
{"start": float(seg.start), "end": float(seg.end), "speaker": seg.speaker}
|
|
@@ -119,8 +127,11 @@ def _diarize_action(
|
|
| 119 |
audio_file_output,
|
| 120 |
)
|
| 121 |
except Exception as exc: # pragma: no cover - hiển thị lỗi cho người dùng giao diện
|
|
|
|
|
|
|
|
|
|
| 122 |
empty_state = ["", "", "", ""]
|
| 123 |
-
return f"Lỗi: {exc}", None, None, [], [], empty_state,
|
| 124 |
|
| 125 |
|
| 126 |
def _normalize_label(value: Any) -> str:
|
|
|
|
| 54 |
device: str,
|
| 55 |
url: str | None = None,
|
| 56 |
):
|
| 57 |
+
import sys
|
| 58 |
+
print(f"DEBUG START: audio_path={audio_path}, url={url}", file=sys.stderr)
|
| 59 |
+
|
| 60 |
if not audio_path and not url:
|
| 61 |
empty_state = ["", "", "", ""]
|
| 62 |
+
return "Vui lòng tải file âm thanh hoặc nhập URL.", None, None, [], [], empty_state, None
|
| 63 |
try:
|
| 64 |
downloaded_path = None
|
| 65 |
download_tmp = None
|
| 66 |
audio_input = audio_path
|
| 67 |
if url:
|
| 68 |
+
print(f"DEBUG: Downloading from URL: {url}", file=sys.stderr)
|
| 69 |
downloaded_path, download_tmp = download_audio_from_url(url)
|
| 70 |
audio_input = str(downloaded_path)
|
| 71 |
+
print(f"DEBUG: Downloaded to: {audio_input}, tmp={download_tmp}", file=sys.stderr)
|
| 72 |
|
| 73 |
+
print(f"DEBUG: Getting engine...", file=sys.stderr)
|
| 74 |
engine = _get_engine(_token_key(hf_token), device)
|
| 75 |
+
print(f"DEBUG: Running diarization on: {audio_input}", file=sys.stderr)
|
| 76 |
diarization, prepared_path, prep_tmpdir = engine.diarize(
|
| 77 |
audio_input, show_progress=False, keep_audio=True
|
| 78 |
)
|
| 79 |
+
print(f"DEBUG: Diarization done. prepared_path={prepared_path}, prep_tmpdir={prep_tmpdir}", file=sys.stderr)
|
| 80 |
segments = engine.to_segments(diarization)
|
| 81 |
dict_segments = [
|
| 82 |
{"start": float(seg.start), "end": float(seg.end), "speaker": seg.speaker}
|
|
|
|
| 127 |
audio_file_output,
|
| 128 |
)
|
| 129 |
except Exception as exc: # pragma: no cover - hiển thị lỗi cho người dùng giao diện
|
| 130 |
+
import traceback
|
| 131 |
+
print(f"DEBUG ERROR: {exc}", file=sys.stderr)
|
| 132 |
+
traceback.print_exc(file=sys.stderr)
|
| 133 |
empty_state = ["", "", "", ""]
|
| 134 |
+
return f"Lỗi: {exc}", None, None, [], [], empty_state, None
|
| 135 |
|
| 136 |
|
| 137 |
def _normalize_label(value: Any) -> str:
|