Merge branch 'release/1.0.1'

This commit is contained in:
Max 2025-09-09 17:49:25 +08:00
commit 988d343cfa
7 changed files with 13 additions and 26 deletions

View File

@ -8,6 +8,7 @@ import '../models/speech_recognition_error.dart';
///
///
/// API
///
class RecordingButton extends StatefulWidget {
/// YxAsrService
final SpeechRecognitionService? speechService;
@ -45,6 +46,12 @@ class RecordingButton extends StatefulWidget {
///
final String? tooltip;
///
final IconData? idleIcon;
///
final IconData? recordingIcon;
const RecordingButton({
super.key,
this.speechService,
@ -59,6 +66,8 @@ class RecordingButton extends StatefulWidget {
this.disabledColor,
this.enabled = true,
this.tooltip,
this.idleIcon,
this.recordingIcon,
});
@override
@ -224,7 +233,9 @@ class _RecordingButtonState extends State<RecordingButton>
bottom: 0,
top: 0,
child: Icon(
_isListening ? Icons.stop_rounded : Icons.mic_rounded,
_isListening
? (widget.recordingIcon ?? Icons.stop_rounded)
: (widget.idleIcon ?? Icons.mic_rounded),
size: widget.size * 0.55,
color: iconColor,
),

View File

@ -1,6 +1,6 @@
name: yx_asr
description: 基于 sherpa_onnx 的 Flutter 语音识别插件,提供完全离线的实时语音转文字功能。
version: 1.0.0
version: 1.0.1
homepage: https://github.com/yuanxuan/yx_asr
environment:

View File

@ -25,8 +25,6 @@ class MockSpeechService implements SpeechRecognitionService {
void mockResult(String text, {double confidence = 1.0}) {
_resultController.add(SpeechRecognitionResult(
recognizedWords: text,
confidence: confidence,
alternatives: [],
));
}

View File

@ -175,8 +175,6 @@ void main() {
final result = SpeechRecognitionResult(
recognizedWords: '这是一个测试结果',
confidence: 0.95,
alternatives: ['备选1', '备选2', '备选3'],
);
stopwatch.start();

View File

@ -43,8 +43,6 @@ class TestHelper {
}) {
return SpeechRecognitionResult(
recognizedWords: text,
confidence: confidence,
alternatives: alternatives,
);
}

View File

@ -6,20 +6,14 @@ void main() {
test('应该正确创建结果对象', () {
final result = SpeechRecognitionResult(
recognizedWords: '测试文本',
confidence: 0.95,
alternatives: ['备选1', '备选2'],
);
expect(result.recognizedWords, '测试文本');
expect(result.confidence, 0.95);
expect(result.alternatives, ['备选1', '备选2']);
});
test('应该正确转换为 Map', () {
final result = SpeechRecognitionResult(
recognizedWords: '测试',
confidence: 0.8,
alternatives: [],
);
final map = result.toMap();
@ -38,8 +32,6 @@ void main() {
final result = SpeechRecognitionResult.fromMap(map);
expect(result.recognizedWords, '从Map创建');
expect(result.confidence, 0.9);
expect(result.alternatives, ['备选']);
});
test('应该处理空的 Map', () {
@ -47,8 +39,6 @@ void main() {
final result = SpeechRecognitionResult.fromMap(map);
expect(result.recognizedWords, '');
expect(result.confidence, 0.0);
expect(result.alternatives, []);
});
});

View File

@ -88,20 +88,14 @@ void main() {
test('应该正确创建结果对象', () {
final result = SpeechRecognitionResult(
recognizedWords: '测试文本',
confidence: 0.95,
alternatives: ['备选1', '备选2'],
);
expect(result.recognizedWords, '测试文本');
expect(result.confidence, 0.95);
expect(result.alternatives, ['备选1', '备选2']);
});
test('应该正确转换为 Map', () {
final result = SpeechRecognitionResult(
recognizedWords: '测试',
confidence: 0.8,
alternatives: [],
);
final map = result.toMap();
@ -120,8 +114,6 @@ void main() {
final result = SpeechRecognitionResult.fromMap(map);
expect(result.recognizedWords, '从Map创建');
expect(result.confidence, 0.9);
expect(result.alternatives, ['备选']);
});
});