Fetches HPR's own metadata, audio, and official transcripts live; falls back to local speech recognition (tiny model, matching HPR's own hpr-get-and-transcribe.bash tooling) only when needed, and to correlation against vendored reference clips or sibling episodes otherwise. License-aware, resumable, and never guesses -- flags anything it isn't confident about for manual review rather than producing a plausible-looking wrong cut.
26 lines
994 B
Python
26 lines
994 B
Python
import unittest
|
|
from unittest import mock
|
|
|
|
from hpr_stripper import asr
|
|
|
|
|
|
class TestAsrResilience(unittest.TestCase):
|
|
def test_missing_binary_returns_empty_list_not_exception(self):
|
|
# Regression test: subprocess.run(["whisper", ...]) raises
|
|
# FileNotFoundError when the binary isn't installed/on PATH, which
|
|
# used to propagate and crash the whole detection pipeline instead
|
|
# of being treated like any other "ASR unavailable" case.
|
|
with mock.patch("subprocess.run", side_effect=FileNotFoundError("no such file")):
|
|
result = asr.transcribe_clip("/tmp/does-not-matter.wav")
|
|
self.assertEqual(result, [])
|
|
|
|
def test_nonzero_returncode_returns_empty_list(self):
|
|
fake_result = mock.Mock(returncode=1)
|
|
with mock.patch("subprocess.run", return_value=fake_result):
|
|
result = asr.transcribe_clip("/tmp/does-not-matter.wav")
|
|
self.assertEqual(result, [])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|