feat(voice-input): handle iOS simulator speech recognition

This commit is contained in:
cogwheel0
2025-11-21 13:38:45 +05:30
parent 390b818916
commit 4b0c16b522

View File

@@ -65,6 +65,9 @@ class VoiceInputService {
SttPreference get preference => _preference;
bool get prefersServerOnly => _preference == SttPreference.serverOnly;
bool get prefersDeviceOnly => _preference == SttPreference.deviceOnly;
bool get _isIosSimulator =>
Platform.isIOS &&
Platform.environment.containsKey('SIMULATOR_DEVICE_NAME');
VoiceInputService({ApiService? api, Ref? ref}) : _api = api, _ref = ref;
@@ -75,13 +78,20 @@ class VoiceInputService {
Future<bool> initialize() async {
if (_isInitialized) return true;
if (!isSupportedPlatform) return false;
final deviceTag = WidgetsBinding.instance.platformDispatcher.locale
.toLanguageTag();
if (_isIosSimulator) {
_localSttAvailable = false;
_ensureFallbackLocale(deviceTag);
_isInitialized = true;
return true;
}
// Prepare local speech recognizer
try {
// Check permission and supported status
_localSttAvailable = await _speech.isSupported();
if (_localSttAvailable) {
final deviceTag = WidgetsBinding.instance.platformDispatcher.locale
.toLanguageTag();
await _loadLocales(deviceTag);
}
} catch (_) {