Skip to content

Latest commit

 

History

History
95 lines (71 loc) · 3.41 KB

File metadata and controls

95 lines (71 loc) · 3.41 KB

b# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

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 Commands

Building the Project

# Build the project
./gradlew build

# Build debug APK
./gradlew assembleDebug

# Build release APK
./gradlew assembleRelease

# Install debug build to connected device/emulator
./gradlew installDebug

Testing

# 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"

Code Quality

# Run lint checks
./gradlew lint

# Clean build artifacts
./gradlew clean

Architecture & Core Components

Main Architecture

  • 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

Data Models

  • LightLine: Represents a line of script with tokens and metadata
  • LightToken: Individual word/token with multiple pronunciation keys for ASR matching

Key Features

  1. Multi-language Support: Handles both English and Chinese text with number-to-word conversion
  2. Real-time Highlighting: Highlights current reading position based on ASR input
  3. Auto-scrolling: Smooth scrolling to keep highlighted content visible
  4. Noise Tolerance: ASR matching accounts for background noise and speech variations
  5. Performance Optimized: Processes large scripts efficiently with coroutines

Script Processing Pipeline

  1. Load text from app/src/main/assets/script.txt
  2. Tokenize by words and characters using regex [a-zA-Z0-9]+|[\\u4e00-\\u9fa5]
  3. Generate pronunciation keys (lowercase, Chinese numbers, English number words)
  4. Display in RecyclerView with real-time highlighting
  5. Process ASR input through sliding window matching algorithm

Development Notes

Adding New Scripts

Place new script files in app/src/main/assets/ and update the filename in MainActivity.kt:64.

ASR Matching Logic

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.

UI Components

  • Uses RecyclerView with LinearLayoutManager for efficient scrolling
  • Custom LinearSmoothScroller for smooth auto-scrolling (150ms duration)
  • Highlighting updates handled in TeleprompterAdapter.updateHighlight()

Testing Strategy

  • Unit tests for parsing logic in ScriptEngine
  • Instrumented tests for UI components
  • ASR simulation included for testing without actual speech recognition

Performance Considerations

  • Script parsing runs on background thread using coroutines
  • RecyclerView optimized with increased cache size (10 views)
  • Pre-allocated ArrayList capacity based on text length