add sentences borders enable in pc player

This commit is contained in:
2026-09-10 08:58:33 +08:00
parent 39896a5c24
commit 9980f78cfc
7 changed files with 556 additions and 23 deletions

View File

@@ -80,6 +80,42 @@ def test_invalid_hash_is_rejected(tmp_path):
assert response.status_code == 422
def test_adhoc_audio_boundaries_do_not_persist_audio(tmp_path, monkeypatch):
client = make_client(tmp_path)
upload = tmp_path / "audio.wav"
upload.write_bytes(b"not-a-real-audio")
import sentence_api.processing as processing_module
monkeypatch.setattr(processing_module, "detect_sentence_boundaries", lambda path: [0.0, 1.0])
monkeypatch.setattr(processing_module, "media_duration_ms", lambda path: 2000)
response = client.post(
"/api/v1/audio/sentence-boundaries",
files={"file": ("audio.wav", upload.read_bytes(), "audio/wav")},
)
assert response.status_code == 200, response.text
payload = response.json()
assert payload["algorithm_version"] == "silence-rms-v1"
assert payload["duration_ms"] == 2000
assert [(item["start_ms"], item["end_ms"]) for item in payload["sentences"]] == [(0, 1000), (1000, 2000)]
assert not (tmp_path / "data" / "work").exists() or not any((tmp_path / "data" / "work").iterdir())
assert not (tmp_path / "data" / "v").exists() or not any((tmp_path / "data" / "v").iterdir())
def test_adhoc_audio_boundaries_require_login(tmp_path):
client = make_client(tmp_path)
client.headers.clear()
response = client.post(
"/api/v1/audio/sentence-boundaries",
files={"file": ("audio.wav", b"audio", "audio/wav")},
)
assert response.status_code == 401
def test_sentence_explanation_requires_login(tmp_path):
index_path = tmp_path / "boundaries.json"
index_path.write_text("{}", encoding="utf-8")