feat: integrate Sherpa-ONNX local offline speech recognition engine

This commit is contained in:
shen
2026-09-15 22:22:32 +08:00
parent 82b1ecdf84
commit 9215931b13
12 changed files with 786 additions and 4 deletions
+7 -3
View File
@@ -77,8 +77,12 @@ class VoiceService {
if (!await recordings.exists()) await recordings.create(recursive: true);
final timestamp = DateTime.now().microsecondsSinceEpoch;
await _recorder.start(
const RecordConfig(encoder: AudioEncoder.aacLc),
path: '${recordings.path}/practice_$timestamp.m4a',
const RecordConfig(
encoder: AudioEncoder.wav,
sampleRate: 16000,
numChannels: 1,
),
path: '${recordings.path}/practice_$timestamp.wav',
);
return true;
}
@@ -118,7 +122,7 @@ class VoiceService {
if (!await recordings.exists()) return const [];
final files = await recordings
.list()
.where((item) => item is File && item.path.endsWith('.m4a'))
.where((item) => item is File && (item.path.endsWith('.wav') || item.path.endsWith('.m4a')))
.cast<File>()
.toList();
files.sort((left, right) => right.path.compareTo(left.path));