Compare commits

..

No commits in common. "988d343cfaf025eea672c51a7e5a153e86f4eac1" and "ae3a9519503f4394e8025f9f120947b2df9bcd04" have entirely different histories.

7 changed files with 26 additions and 13 deletions

View File

@ -8,7 +8,6 @@ import '../models/speech_recognition_error.dart';
///
///
/// API
///
class RecordingButton extends StatefulWidget {
/// YxAsrService
final SpeechRecognitionService? speechService;
@ -46,12 +45,6 @@ class RecordingButton extends StatefulWidget {
///
final String? tooltip;
///
final IconData? idleIcon;
///
final IconData? recordingIcon;
const RecordingButton({
super.key,
this.speechService,
@ -66,8 +59,6 @@ class RecordingButton extends StatefulWidget {
this.disabledColor,
this.enabled = true,
this.tooltip,
this.idleIcon,
this.recordingIcon,
});
@override
@ -233,9 +224,7 @@ class _RecordingButtonState extends State<RecordingButton>
bottom: 0,
top: 0,
child: Icon(
_isListening
? (widget.recordingIcon ?? Icons.stop_rounded)
: (widget.idleIcon ?? Icons.mic_rounded),
_isListening ? Icons.stop_rounded : 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.1
version: 1.0.0
homepage: https://github.com/yuanxuan/yx_asr
environment:

View File

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

View File

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

View File

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

View File

@ -6,14 +6,20 @@ 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();
@ -32,6 +38,8 @@ void main() {
final result = SpeechRecognitionResult.fromMap(map);
expect(result.recognizedWords, '从Map创建');
expect(result.confidence, 0.9);
expect(result.alternatives, ['备选']);
});
test('应该处理空的 Map', () {
@ -39,6 +47,8 @@ void main() {
final result = SpeechRecognitionResult.fromMap(map);
expect(result.recognizedWords, '');
expect(result.confidence, 0.0);
expect(result.alternatives, []);
});
});

View File

@ -88,14 +88,20 @@ 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();
@ -114,6 +120,8 @@ void main() {
final result = SpeechRecognitionResult.fromMap(map);
expect(result.recognizedWords, '从Map创建');
expect(result.confidence, 0.9);
expect(result.alternatives, ['备选']);
});
});