b# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is an Intelligent Teleprompter Android application written in Kotlin that provides real-time script following functionality using simulated Automatic Speech Recognition (ASR). The app parses text scripts and highlights the current position based on voice input simulation.
# Build the project
./gradlew build
# Build debug APK
./gradlew assembleDebug
# Build release APK
./gradlew assembleRelease
# Install debug build to connected device/emulator
./gradlew installDebug# Run unit tests
./gradlew test
# Run instrumented tests (requires connected device/emulator)
./gradlew connectedAndroidTest
# Run a specific test class
./gradlew test --tests "com.cxb.intelligent.teleprompter.ExampleUnitTest"# Run lint checks
./gradlew lint
# Clean build artifacts
./gradlew clean- MainActivity: Core UI controller that orchestrates the teleprompter functionality
- ScriptEngine: Text parsing and ASR matching algorithms with O(1) complexity sliding window
- AsrSimulator: Simulates ASR input with realistic noise and timing
- TeleprompterAdapter: RecyclerView adapter for displaying script lines with highlighting
- ScriptUtils: Utility for reading script files from assets
- LightLine: Represents a line of script with tokens and metadata
- LightToken: Individual word/token with multiple pronunciation keys for ASR matching
- Multi-language Support: Handles both English and Chinese text with number-to-word conversion
- Real-time Highlighting: Highlights current reading position based on ASR input
- Auto-scrolling: Smooth scrolling to keep highlighted content visible
- Noise Tolerance: ASR matching accounts for background noise and speech variations
- Performance Optimized: Processes large scripts efficiently with coroutines
- Load text from
app/src/main/assets/script.txt - Tokenize by words and characters using regex
[a-zA-Z0-9]+|[\\u4e00-\\u9fa5] - Generate pronunciation keys (lowercase, Chinese numbers, English number words)
- Display in RecyclerView with real-time highlighting
- Process ASR input through sliding window matching algorithm
Place new script files in app/src/main/assets/ and update the filename in MainActivity.kt:64.
The sliding window algorithm in ScriptEngine.findMatch() searches forward from the current position with a configurable window size (default: 50 tokens) to find the best match for ASR input.
- Uses RecyclerView with LinearLayoutManager for efficient scrolling
- Custom LinearSmoothScroller for smooth auto-scrolling (150ms duration)
- Highlighting updates handled in
TeleprompterAdapter.updateHighlight()
- Unit tests for parsing logic in
ScriptEngine - Instrumented tests for UI components
- ASR simulation included for testing without actual speech recognition
- Script parsing runs on background thread using coroutines
- RecyclerView optimized with increased cache size (10 views)
- Pre-allocated ArrayList capacity based on text length