How huisam1611/voice3 works
1. This is a Flutter mobile app with a thin platform layer for Android and iOS. The main product logic lives in lib/, while android/ and ios/ provide native packaging, platform entry points, and speech-related integrations.
2. The app is organized as a feature-first Flutter UI. Major screens are home, learning, theme_detail, result, review, progress, and settings, each with its own screen file and local widgets. That layout suggests the app flow is primarily user-driven through a learning journey rather than a generic CRUD app.
3. The central domain appears to be a guided language/voice learning experience. The learning flow is backed by models such as ThemePack, Question, Level, LearningRecord, and ScoringResult, which indicate content packs, step-based progression, and post-attempt evaluation.
4. lib/core/database contains a local persistence layer, including database_helper.dart and table definitions. This is the main storage boundary for user progress and learning history; the presence of progress and review screens implies the database is used to reconstruct prior attempts and aggregate statistics offline.
5. lib/core/bridge/native_bridge.dart is the key cross-platform boundary. It likely mediates between Flutter and native Android/iOS capabilities, especially speech input/output and possibly model execution, so it is the architectural seam where Dart UI logic hands off to platform code.
6. Speech processing is split into dedicated native services on Android under android/app/src/main/kotlin/com/example/voice3/services/: SttService, TtsService, and ScoringEngine. This strongly suggests recognition, synthesis, and answer scoring are handled outside Dart for performance and/or native SDK access.
7. Android bundles a local speech model stack: android/app/libs/sherpa-onnx-1.12.28.aar and assets under android/app/src/main/assets/models/sherpa-onnx-paraformer-zh/. The included tokens.txt and placeholder for model files indicate on-device STT using Sherpa-ONNX rather than a cloud speech API.
8. The asset tree shows the app is content-heavy and likely driven by packaged learning materials. assets/data/themes/*.json defines themed lesson content, while assets/images/scenes, assets/images/words, assets/audio, and assets/animations supply the visual and audio content shown during learning.
9. lib/features/learning/learning_controller.dart is probably the primary orchestration point for session state: loading theme content, moving through prompts, invoking speech services, scoring responses, and updating progress records. The nearby widgets (mic_button, feedback_overlay, progress_indicator_bar, scene_intro, word_card) imply a real-time interaction loop around voice capture and feedback.
10. The result and progress areas form the app’s feedback/reporting loop. result presents per-attempt scoring details and ratings, while progress summarizes longer-term performance using a calendar heatmap and stats widgets; both likely read from the local database rather than remote analytics.
11. lib/app/ contains the app shell: routing, theming, and top-level composition. routes.dart and theme.dart define navigation and visual system boundaries, while main.dart bootstraps the Flutter app.
12. Platform-specific entry points are standard but still important for architecture. Android uses a custom MainActivity.kt and an app-level Gradle setup; iOS uses AppDelegate.swift, Runner-Bridging-Header.h, and the usual Xcode project structure. These files indicate the Flutter shell delegates to native code where needed, rather than reimplementing the full app natively.
13. The repository is intentionally offline-first. Content packs are local, speech models are bundled locally on Android, and progress appears to be stored in SQLite via the app’s database layer. That means the main runtime dependency is device resources, not network connectivity.
14. In diagram terms, the main flow is: Flutter home/theme selection → learning session controller → native speech bridge/services for recording, recognition, synthesis, and scoring → local database writes for progress/result history → result/progress/review screens for user feedback. The major boundaries are UI vs domain logic, Dart vs native speech implementation, and content/assets vs persisted user state.
Main entry points: learning_controller.dart Session controller · native_bridge.dart Native bridge · MainActivity.kt MainActivity · app.dart App shell
Components 22
Flutter app
Dart shell, routing, and feature UI
Domain & data
Learning models, persistence, and native bridge
- Native bridge · Dart boundary to native speech capabilities
lib/core/bridge/native_bridge.dart - Database · SQLite helper and table access
lib/core/database/database_helper.dart - Learning models · Theme packs, questions, levels, records, and scores
lib/core/models/theme_pack.dart
Feature screens
User-facing learning journey screens
- Home · Entry screen for theme selection
lib/features/home/home_screen.dart - Theme detail · Theme overview and level selection
lib/features/theme_detail/theme_detail_screen.dart - Learning · Interactive voice learning session UI
lib/features/learning/learning_screen.dart - Session controller · Loads content, advances prompts, scores input, and persists progress
lib/features/learning/learning_controller.dart - Result · Per-attempt scoring and feedback view
lib/features/result/result_screen.dart - Progress · Long-term stats and history overview
lib/features/progress/progress_screen.dart - Review · Past attempt review and recap
lib/features/review/review_screen.dart - Settings · App preferences and configuration
lib/features/settings/settings_screen.dart
Android native
Platform speech and packaging layer
- STT service · Android on-device speech recognition
android/app/src/main/kotlin/com/example/voice3/services/SttService.kt - TTS service · Android text-to-speech output
android/app/src/main/kotlin/com/example/voice3/services/TtsService.kt - Scoring engine · Android answer evaluation and scoring
android/app/src/main/kotlin/com/example/voice3/services/ScoringEngine.kt - MainActivity · Flutter host activity and plugin boundary
android/app/src/main/kotlin/com/example/voice3/MainActivity.kt
iOS native
Platform entry and bridge layer
- AppDelegate · iOS host entry and bridge setup
ios/Runner/AppDelegate.swift
Packaged content
Local lesson assets and media
- Theme packs · Packaged lesson JSON content
assets/data/themes/hobbies.json - Media assets · Packaged scenes, words, audio, and animations
assets/images/scenes/.gitkeep
Connections 23
- Main → App shell: boots · Starts the app shell
- App shell → Routes: uses · Wires navigation between screens
- App shell → Theme: applies · Provides global styling
- Routes → Home: opens · Initial landing screen
- Home → Theme detail: selects · Moves into a theme
- Theme detail → Learning: starts · Begins a learning session
- Learning → Session controller: drives · UI is coordinated by session state
- Session controller → Learning models: loads · Reads theme packs, questions, levels, and results
- Session controller → Theme packs: uses · Consumes packaged lesson content
- Session controller → Media assets: renders · Shows scenes, words, audio, and animations
- Session controller → Native bridge: invokes · Hands off speech and scoring work to native layer
- Native bridge → STT service: calls · Requests speech recognition
- Native bridge → TTS service: calls · Requests spoken feedback
- Native bridge → Scoring engine: calls · Requests answer evaluation
- Session controller → Database: persists · Stores attempts and progress
- Database → Progress: feeds · Supplies history and summaries
- Database → Review: feeds · Reconstructs prior attempts
- Session controller → Result: publishes · Sends final attempt scoring
- Progress → Result: drills into · Detailed attempt feedback
- MainActivity → STT service: hosts · Android host for speech services
- MainActivity → TTS service: hosts · Android host for speech services
- MainActivity → Scoring engine: hosts · Android host for speech services
- AppDelegate → Native bridge: connects · iOS platform bridge setup