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
View File
@@ -1,3 +1,4 @@
import 'sherpa_stt_service.dart';
import 'dart:io';
import 'dart:convert';
@@ -118,6 +119,12 @@ class AiService {
required String endpoint,
required String model,
}) async {
if (filePath.toLowerCase().endsWith('.wav')) {
final localText = await SherpaSttService.instance.transcribeWav(filePath);
if (localText != null && localText.trim().isNotEmpty) {
return localText.trim();
}
}
if (provider == AiProviderType.mock) return null;
final file = File(filePath);
if (!await file.exists()) return null;