feat: upgrade local speech recognition engine to SenseVoice-Small with hardware audio enhancements
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:kouyu_english/core/sherpa_stt_service.dart';
|
||||
import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx;
|
||||
@@ -7,19 +6,19 @@ import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx;
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
test('SherpaSttService transcribes WAV audio file accurately', () async {
|
||||
test('SenseVoice-Small ONNX transcribes WAV audio file accurately', () async {
|
||||
const macosDir = '/Users/shen/.pub-cache/hosted/pub.dev/sherpa_onnx_macos-1.13.8/macos';
|
||||
|
||||
// Test direct Sherpa ASR initialization and decoding with bundled test audio
|
||||
// Test direct Sherpa ASR initialization and decoding with SenseVoice
|
||||
sherpa_onnx.initBindings(macosDir);
|
||||
|
||||
final modelConfig = sherpa_onnx.OfflineModelConfig(
|
||||
transducer: const sherpa_onnx.OfflineTransducerModelConfig(
|
||||
encoder: 'assets/models/sherpa/encoder-epoch-99-avg-1.int8.onnx',
|
||||
decoder: 'assets/models/sherpa/decoder-epoch-99-avg-1.int8.onnx',
|
||||
joiner: 'assets/models/sherpa/joiner-epoch-99-avg-1.int8.onnx',
|
||||
senseVoice: const sherpa_onnx.OfflineSenseVoiceModelConfig(
|
||||
model: 'assets/models/sense_voice/model.int8.onnx',
|
||||
language: 'auto',
|
||||
useInverseTextNormalization: true,
|
||||
),
|
||||
tokens: 'assets/models/sherpa/tokens.txt',
|
||||
tokens: 'assets/models/sense_voice/tokens.txt',
|
||||
numThreads: 2,
|
||||
debug: false,
|
||||
);
|
||||
@@ -40,8 +39,8 @@ void main() {
|
||||
stream.acceptWaveform(samples: wave.samples, sampleRate: wave.sampleRate);
|
||||
recognizer.decode(stream);
|
||||
final result = recognizer.getResult(stream);
|
||||
print("Transcribed result: ${result.text}");
|
||||
expect(result.text.contains("NIGHTFALL"), isTrue);
|
||||
print("SenseVoice transcribed result: ${result.text}");
|
||||
expect(result.text.toLowerCase().contains("nightfall"), isTrue);
|
||||
stream.free();
|
||||
}
|
||||
recognizer.free();
|
||||
|
||||
Reference in New Issue
Block a user