feat(live-captions): add ESP32 streaming captions app

This commit is contained in:
Adolfo Reyna
2026-08-21 22:41:01 -04:00
parent 03e65fb7f7
commit 52bf3e1870
8 changed files with 648 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
"""Source-level contract for the Live Captions external Tactility app.
The app is ELF-loaded firmware code, so this test guards the device protocol and
persistence requirements before an ESP32-S3 build/install test is available.
"""
from pathlib import Path
import unittest
ROOT = Path(__file__).resolve().parents[1]
APP = ROOT / "Apps" / "LiveCaptions"
class LiveCaptionsContractTests(unittest.TestCase):
def test_manifest_identifies_the_captions_app(self):
manifest = (APP / "manifest.properties").read_text()
self.assertIn("app.id=one.tactility.livecaptions", manifest)
self.assertIn("app.name=Live Captions", manifest)
self.assertIn("target.platforms=esp32s3", manifest)
def test_app_streams_audio_and_logs_final_caption_to_daily_text_file(self):
source = (APP / "main" / "Source" / "main.c").read_text()
self.assertIn("audio_stream_open_input", source)
self.assertIn("/sdcard/captions", source)
self.assertIn('"%Y-%m-%d.txt"', source)
self.assertIn("append_final_caption", source)
self.assertIn('"draft"', source)
self.assertIn('"interim_transcript"', source)
self.assertIn('"transcript"', source)
self.assertIn('"final"', source)
self.assertIn("const char* stop", source)
self.assertNotIn("i2s_controller_", source)
def test_connection_failure_stays_failed_until_user_starts_again(self):
source = (APP / "main" / "Source" / "main.c").read_text()
self.assertIn("CAPTION_FAILED", source)
self.assertIn("Fail to connect", source)
self.assertNotIn("retry_attempt", source)
self.assertNotIn("retry scheduled", source)
if __name__ == "__main__":
unittest.main()