Commit Graph

38 Commits

Author SHA1 Message Date
Max 9ae0344757 Merge branch 'release/1.0.5' 2026-01-18 00:10:04 +08:00
Max 4817b1c8f8 chore(release): 1.0.5
Improve init responsiveness with recognizer isolate; update RecordingButton lazy-init UX
2026-01-17 23:48:36 +08:00
Max 6ab8852b42 feat: update .gitignore for macOS 2025-11-18 10:44:04 +08:00
Max a31279b3a5 Merge branch 'release/1.0.4' 2025-10-23 18:15:01 +08:00
Max cec88de659 Merge tag '1.0.4' into develop
1.0.4
2025-10-23 18:15:01 +08:00
Max 5e61eed30f feat: 新增多实例会话管理支持 v1.0.4
🎉 **重大功能更新**
- 支持同一页面多个独立的录音会话
- 每个 RecordingButton 可以有独立的 sessionId
- 智能会话切换,同一时间只有一个会话活跃

🆕 **YxAsrService 新增API**
- registerSession() - 注册新会话
- unregisterSession() - 注销会话
- startListeningForSession() - 会话级录音控制
- stopListeningForSession() - 会话级停止控制
- getResultStreamForSession() - 获取会话结果流
- getStatusStreamForSession() - 获取会话状态流
- getRegisteredSessions() - 获取所有会话列表
- getActiveSessionId() - 获取当前活跃会话

🔧 **RecordingButton 增强**
- 新增 sessionId 参数支持多实例场景
- 自动会话注册和资源清理
- 独立的流订阅机制
- 完全向后兼容

 **解决的问题**
- 同一页面多个录音按钮状态同步问题
- 识别结果精确分发到对应按钮
- 会话间状态互相干扰问题

📈 **版本升级**
- 版本号: 1.0.2 → 1.0.4
- 无破坏性更改,现有代码无需修改
2025-10-23 18:06:01 +08:00
Max f0b643e48b Merge branch 'release/1.0.3' 2025-09-10 20:48:52 +08:00
Max cd6d31457f Merge tag '1.0.3' into develop
1.0.3
2025-09-10 20:48:52 +08:00
Max e6ce7f4183 重大架构优化:移除不必要的平台特定代码
🎯 **架构简化**
- 删除整个 ios/ 文件夹和所有 Swift/Objective-C 代码
- 删除整个 android/ 文件夹和所有 Kotlin/Java 代码
- 移除 pubspec.yaml 中的插件平台配置

🚀 **技术优势**
- 从 Flutter 插件转换为纯 Dart 包
- 完全依赖成熟的跨平台包:sherpa_onnx, record, permission_handler
- 大幅简化代码维护和调试复杂度
- 避免平台特定的构建错误和兼容性问题

 **解决的问题**
- 修复 iOS 构建中的重复类定义错误
- 消除 Objective-C/Swift 桥接代码的复杂性
- 提高代码可维护性和跨平台一致性

📦 **新架构**
基于 sherpa_onnx 的纯 Dart 实现,所有平台功能通过现有包处理
2025-09-10 20:47:54 +08:00
Max e7af556512 Merge branch 'release/1.0.2' 2025-09-10 09:33:53 +08:00
Max 06a2be00a0 Merge tag '1.0.2' into develop
1.0.2
2025-09-10 09:33:53 +08:00
Max 7ed4511643 feat: update version 2025-09-10 09:33:21 +08:00
Max ec003dcd4b feat: 为RecordingButton组件增加自定义图标和图标大小设置
- 添加 idleIcon 参数支持自定义空闲状态图标
- 添加 recordingIcon 参数支持自定义录音状态图标
- 添加 iconSize 参数支持自定义图标大小
- 保持向后兼容性,使用默认图标和大小
- 更新组件文档注释
2025-09-10 09:32:02 +08:00
Max 988d343cfa Merge branch 'release/1.0.1' 2025-09-09 17:49:25 +08:00
Max c6b3396345 Merge tag '1.0.1' into develop
1.0.1
2025-09-09 17:49:25 +08:00
Max 5c42a449d6 feat: 增加自定义icon支持 2025-09-09 17:48:45 +08:00
Max e7ea348bda Merge tag '1.0.0' into develop
1.0.0
2025-09-09 17:22:57 +08:00
Max ae3a951950 Merge branch 'release/1.0.0' 2025-09-09 17:22:56 +08:00
Max 508244fac3 Remove unused confidence and alternatives fields from SpeechRecognitionResult
Complete removal of unused fields to simplify data structure:

1. SpeechRecognitionResult Model Simplified:
   - Removed 'confidence' field (was always hardcoded to 0.8)
   - Removed 'alternatives' field (was always empty array)
   - Kept only 'recognizedWords' which is actually used
   - Updated constructor, fromMap, toMap, toString, ==, hashCode accordingly

2. YxAsrService Updates:
   - Simplified _sendResult() method signature
   - Removed unused confidence and alternatives parameters
   - Updated method call to only pass recognizedWords
   - Cleaner method invocation: _sendResult(recognizedWords: result.text)

3. Benefits Achieved:
   - 🧹 Simplified data structure - only essential fields remain
   - 🚀 Reduced memory usage - no unnecessary field storage/transmission
   - 💡 Cleaner API - method signatures reflect actual usage
   -  Better performance - less data serialization/deserialization
   - 🔍 Improved code clarity - no confusing unused parameters

4. Sherpa-ONNX Integration:
   - OnlineRecognizerResult only provides: text, tokens, timestamps
   - No confidence or alternatives data available from the library
   - Our simplified structure now aligns with actual data source

This optimization removes all the 'fake' hardcoded values and focuses
on the actual speech recognition text result that users need.
2025-09-09 17:03:43 +08:00
Max 75080d0c0d Fix duplicate recognition issue in _recognitionTimer
Critical fix for recognition logic to prevent duplicate processing:

1. Problem Identified:
   - _recognitionTimer was repeatedly calling decode() on same audio data
   - Same recognition results were being sent multiple times to UI
   - Caused redundant processing and potential performance issues

2. Solution Implemented:
   - Add _lastRecognizedText state variable to track previous results
   - Only send recognition results when text content actually changes
   - Reset _lastRecognizedText when starting new recording session

3. Logic Changes:
   - Enhanced recognition loop with duplicate detection:
     A command-line utility for Dart development.

Usage: dart <command|dart-file> [arguments]

Global options:
-v, --verbose               Show additional command output.
    --version               Print the Dart SDK version.
    --enable-analytics      Enable analytics.
    --disable-analytics     Disable analytics.
    --suppress-analytics    Disallow analytics for this `dart *` run without changing the analytics configuration.
-h, --help                  Print this usage information.

Available commands:
  analyze    Analyze Dart code in a directory.
  compile    Compile Dart to various formats.
  create     Create a new Dart project.
  devtools   Open DevTools (optionally connecting to an existing application).
  doc        Generate API documentation for Dart projects.
  fix        Apply automated fixes to Dart source code.
  format     Idiomatically format Dart source code.
  info       Show diagnostic information about the installed tooling.
  pub        Work with packages.
  run        Run a Dart program.
  test       Run tests for a project.

Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
   - Added debug logging for skipped duplicate results
   - Reset state on startListening() to ensure clean slate

4. Benefits:
   - Eliminates duplicate recognition results sent to UI
   - Reduces unnecessary computation and network overhead
   - Improves user experience with cleaner, non-repetitive updates
   - Better resource utilization and battery life

This fix addresses the core issue where the recognition timer was
processing the same audio stream content repeatedly, ensuring each
unique recognition result is only sent once to the application.
2025-09-09 16:58:47 +08:00
Max e961996ec6 Remove recognition history functionality
Complete removal of recognition history features:

1. State Variables Removed:
   - _recognitionHistory list variable
   - _realtimeResults list variable
   - All history-related state management

2. Methods Updated:
   - _clearHistory() renamed to _clearContent()
   - Simplified to only clear current text and base text
   - Removed history list operations

3. UI Components Removed:
   - _buildHistoryCard() method completely removed
   - History card from main layout removed
   - History-related ListView and ListTile widgets removed

4. Callback Logic Simplified:
   - onListeningStatusChanged callback cleaned up
   - Removed history insertion logic when recording stops
   - Removed _realtimeResults.clear() operations
   - Simplified state management to focus only on current text

5. App Bar Updated:
   - Clear button tooltip changed from '清除历史' to '清除内容'
   - Button now calls _clearContent() instead of _clearHistory()

The app now focuses purely on real-time speech recognition with
editable text input, without maintaining any recognition history.
This simplifies the codebase and improves performance by removing
unnecessary data storage and UI rendering.
2025-09-09 16:22:38 +08:00
Max aba8b44ab8 Update RecordingButton design with new visual style
Major design changes based on user requirements:

1. Background Style Changes:
   - Remove solid color background and shadows
   - Use semi-transparent background (alpha: 0.12) for subtle visual feedback
   - Maintain circular shape for both states

2. Icon Improvements:
   - Increase icon size to 55% of button size for better visibility
   - Use color-coded icons: blue for idle, red for recording
   - Remove white icon color, use theme-based colors instead

3. Loading Indicator Enhancement:
   - Show CircularProgressIndicator during both processing and listening states
   - Position indicator as overlay using Stack layout
   - Maintain white color for progress indicator for contrast

4. Color Logic Simplification:
   - Consolidate color logic into single iconColor variable
   - Remove complex state-based color transitions
   - Use consistent color scheme: blue (#2196F3) idle, red (#FF5252) recording
   - Darker disabled color (#212121) for better contrast

5. Layout Structure Update:
   - Replace Transform.scale animation wrapper with direct Container
   - Use Stack for layering icon and progress indicator
   - Positioned widgets for precise control over element placement

This creates a more modern, minimalist design with better visual hierarchy
and improved accessibility through higher contrast ratios.
2025-09-09 15:08:35 +08:00
Max ac234d99ec Fix RecordingButton shape: Both states should be circular
Correction based on user feedback:
- Both idle and recording states use circular shape (BoxShape.circle)
- Remove conditional rectangle shape logic
- Keep color differentiation: blue for idle, red for recording
- Maintain consistent circular InkWell ripple effect

Design now correctly matches the mockup:
🔵 Blue circle (idle/ready to record)
🔴 Red circle (actively recording)

Both buttons maintain the same circular shape with only color changes.
2025-09-09 14:23:47 +08:00
Max 3e8fe73e27 Update RecordingButton design to match UI mockup
Design improvements based on provided mockup:

1. Color Updates:
   - Idle state: Blue (#2196F3) - matches mockup's blue recording button
   - Recording state: Red (#FF5252) - matches mockup's red stop button
   - Disabled state: Light grey (#9E9E9E) for better visibility
   - Processing state: Semi-transparent versions of respective colors

2. Shape Changes:
   - Idle state: Circle (for recording button)
   - Recording state: Rounded rectangle (12px radius) for stop button
   - Smooth transitions between shapes using BoxShape

3. Icon Improvements:
   - Use rounded icons (mic_rounded, stop_rounded) for modern look
   - Adjust icon sizes: recording (40% of button), stop (35% of button)
   - Better proportions matching the design intent

4. Shadow Enhancements:
   - Increased blur radius for idle state (8→12px) for better depth
   - Dynamic shadow based on button state
   - Enhanced spread radius for better visual impact

5. Interactive Elements:
   - InkWell borderRadius adapts to button shape
   - Smooth transitions between circular and rectangular ripple effects

These changes create a modern, professional appearance that matches
common design patterns and provides clear visual feedback for different states.
2025-09-09 14:20:10 +08:00
Max 6146508bed Enhance RecordingButton with haptic feedback and debounce
Major UX improvements to RecordingButton:

1. Haptic Feedback (震动效果):
   - Add HapticFeedback.lightImpact() on button tap
   - Import flutter/services.dart for haptic support
   - Provides tactile confirmation for user interactions

2. Debounce Mechanism (防抖):
   - Add _isProcessing flag to prevent rapid consecutive taps
   - 300ms cooldown period after each tap
   - Protects against accidental double-taps and ensures stable operation

3. Enhanced Visual States:
   - Processing state with semi-transparent color
   - Loading spinner during async operations
   - Better visual feedback for different button states

4. Improved Animations:
   - Trigger scale animation on tap (not just on state change)
   - Smooth forward/reverse animation cycle
   - Better visual response to user interactions

5. Better Error Handling:
   - Proper mounted check before setState
   - Graceful cleanup with finally block
   - Prevents memory leaks and state corruption

These improvements provide:
- Better tactile feedback for users
- Prevention of UI race conditions
- Clearer visual indication of button states
- More responsive and professional user experience
2025-09-09 14:06:43 +08:00
Max 0af37c5b87 Remove final result logic from SDK library
Major SDK simplification by removing redundant final result processing:

1. YxAsrService changes:
   - Remove final result retrieval in stopListening()
   - Remove finalResult parameter from _sendResult()
   - Simplify stop logic to only reset stream state
   - Eliminate duplicate API calls that provided no additional value

2. SpeechRecognitionResult model changes:
   - Remove finalResult property and related logic
   - Update constructor, factory methods, toString, equals, hashCode
   - Remove finalResult from toMap/fromMap serialization
   - Simplify the model to focus on actual recognition data

3. Benefits:
   - Cleaner, more maintainable codebase
   - Reduced complexity and potential bugs
   - Better performance (no redundant API calls)
   - Simpler API for developers to use
   - Real-time text appending works seamlessly without artificial distinctions

The analysis showed that 'final results' were identical to the last real-time result,
making the distinction unnecessary. Now all results are treated uniformly as
real-time updates, providing a smoother and more intuitive user experience.
2025-09-09 11:29:19 +08:00
Max ed51fa89bd Implement real-time text appending to input field
1. Add _baseText variable to track text before recording starts
   - Preserves existing text when starting new recording session
   - Provides foundation for real-time appending

2. Update real-time result processing logic
   - Real-time results now immediately update the text field
   - Combine base text + current recognition text
   - Move cursor to end for better UX
   - Add intelligent spacing between segments

3. Improve final result handling
   - Final results update base text for next recording
   - Clean state management between recording sessions

4. Update recording status change logic
   - Capture base text when recording starts
   - Maintain proper state transitions

Now users can see their speech being converted to text in real-time directly in the input field, providing immediate visual feedback during speech recognition.
2025-09-09 11:24:53 +08:00
Max d1ab67e60e Fix real-time speech recognition display
1. Update UI to show actual _currentText instead of fixed 'realtime recognizing...' text
   - Use Flexible widget to handle text overflow
   - Show actual recognition text when available
   - Fallback to 'realtime recognizing...' when text is empty

2. Fix final result processing logic
   - Don't update _currentText when processing final results
   - Final results only append to text field, don't interfere with real-time display

3. Improve listening status management
   - Clear _currentText when recording stops
   - Ensure clean state transitions between recording sessions

This fixes the issue where users could only see final results without real-time feedback.
2025-09-09 11:22:37 +08:00
Max d63124203b Fix critical bugs in speech recognition system
1. Add finalResult property to SpeechRecognitionResult class
   - Distinguish between real-time and final recognition results
   - Update factory methods, toString, equals, and hashCode
   - Update toMap and fromMap methods

2. Update YxAsrService to support finalResult flag
   - Add finalResult parameter to _sendResult method
   - Mark final results with finalResult: true
   - Keep real-time results as finalResult: false (default)

3. Remove unused methods to clean up codebase
   - Remove unused _toggleRecording method
   - Remove unused _updateTextController method
   - Clean up orphaned comments

These fixes resolve linter errors and ensure proper text appending functionality.
2025-09-09 11:17:13 +08:00
Max ea32370fcc Improve text input behavior: append recognition results to text field
- Change from replacing current text to appending final results
- Distinguish between real-time results (display only) and final results (append to text)
- Add proper spacing between appended text segments
- Maintain history of individual recognition segments
- Clear current text when starting new recording session
2025-09-09 11:08:44 +08:00
Max 36fa796c10 Improve demo: use RecordingButton component instead of custom implementation
- Replace custom FloatingActionButton with RecordingButton widget
- Simplify code by using built-in speech recognition integration
- Demonstrate proper usage of RecordingButton component
- Reduce demo code complexity from 80+ lines to ~40 lines
- Better showcase the plugin's provided components
2025-09-09 11:04:27 +08:00
Max c47ad5c435 Fix Flutter assets configuration: explicitly specify all model files in pubspec.yaml 2025-09-06 17:36:54 +08:00
Max d18c3fc607 Switch back to zh2023 model to fix filename mismatch issue 2025-09-06 17:30:54 +08:00
Max 9053132874 Fix model loading: switch to zh2025 model as recommended by logs 2025-09-06 17:29:11 +08:00
Max 58056c6c09 Fix Kotlin null safety issue: add null check for context in isAvailable method 2025-09-06 17:26:24 +08:00
Max 80d99d6bdd Fix Android namespace issues: add namespace to build.gradle, update AGP and Kotlin versions 2025-09-06 17:25:05 +08:00
Max ae1ec191a8 Fix build issues: remove duplicate gradle files, increase heap size, fix plugin configuration 2025-09-06 17:23:14 +08:00
Max 5c9a8ea6e6 Initial commit: Flutter speech-to-text plugin with Sherpa-ONNX integration 2025-08-27 17:09:36 +08:00