diff --git a/lib/src/models/speech_recognition_result.dart b/lib/src/models/speech_recognition_result.dart index 8770559..70b0a75 100644 --- a/lib/src/models/speech_recognition_result.dart +++ b/lib/src/models/speech_recognition_result.dart @@ -3,24 +3,14 @@ class SpeechRecognitionResult { /// 识别出的文字内容 final String recognizedWords; - /// 识别置信度(0.0 到 1.0) - final double confidence; - - /// 备选识别结果 - final List alternatives; - const SpeechRecognitionResult({ required this.recognizedWords, - this.confidence = 0.0, - this.alternatives = const [], }); /// 从 Map 创建 [SpeechRecognitionResult] 实例 factory SpeechRecognitionResult.fromMap(Map map) { return SpeechRecognitionResult( recognizedWords: map['recognizedWords'] as String? ?? '', - confidence: (map['confidence'] as num?)?.toDouble() ?? 0.0, - alternatives: List.from(map['alternatives'] as List? ?? []), ); } @@ -28,31 +18,23 @@ class SpeechRecognitionResult { Map toMap() { return { 'recognizedWords': recognizedWords, - 'confidence': confidence, - 'alternatives': alternatives, }; } @override String toString() { - return 'SpeechRecognitionResult(recognizedWords: $recognizedWords, ' - 'confidence: $confidence, alternatives: $alternatives)'; + return 'SpeechRecognitionResult(recognizedWords: $recognizedWords)'; } @override bool operator ==(Object other) { if (identical(this, other)) return true; return other is SpeechRecognitionResult && - other.recognizedWords == recognizedWords && - other.confidence == confidence && - other.alternatives.length == alternatives.length && - other.alternatives.every((alt) => alternatives.contains(alt)); + other.recognizedWords == recognizedWords; } @override int get hashCode { - return recognizedWords.hashCode ^ - confidence.hashCode ^ - alternatives.hashCode; + return recognizedWords.hashCode; } } diff --git a/lib/src/yx_asr_service.dart b/lib/src/yx_asr_service.dart index 5c7b560..d8da4a1 100644 --- a/lib/src/yx_asr_service.dart +++ b/lib/src/yx_asr_service.dart @@ -750,8 +750,6 @@ class YxAsrService implements SpeechRecognitionService { _lastRecognizedText = result.text; // 更新最后识别的文本 _sendResult( recognizedWords: result.text, - confidence: 0.8, - alternatives: [], ); } else if (result.text.isNotEmpty && result.text == _lastRecognizedText) { @@ -771,14 +769,10 @@ class YxAsrService implements SpeechRecognitionService { /// 发送识别结果到结果流 void _sendResult({ required String recognizedWords, - required double confidence, - required List alternatives, }) { debugPrint('📤 [YxAsr] 发送识别结果: "$recognizedWords"'); final result = SpeechRecognitionResult( recognizedWords: recognizedWords, - confidence: confidence, - alternatives: alternatives, ); _resultController.add(result); }