fix: mic permissions

This commit is contained in:
cogwheel0
2025-08-28 19:48:35 +05:30
parent fe7c7758ba
commit b9f41e0d07
3 changed files with 19 additions and 19 deletions

View File

@@ -1998,16 +1998,11 @@ class _VoiceInputSheetState extends ConsumerState<_VoiceInputSheet> {
);
try {
// Ensure service is initialized (local STT will request permissions itself)
// Ensure service is initialized
final ok = await _voiceService.initialize();
if (!ok) {
throw Exception('Voice service unavailable');
}
// Only check mic permission when falling back to recording
if (!_voiceService.hasLocalStt) {
final mic = await _voiceService.checkPermissions();
if (!mic) throw Exception('Microphone permission not granted');
}
// Start elapsed timer for UX
_elapsedTimer?.cancel();
@@ -2019,7 +2014,8 @@ class _VoiceInputSheetState extends ConsumerState<_VoiceInputSheet> {
setState(() => _elapsedSeconds += 1);
});
final stream = _voiceService.startListening();
// Centralized permission + start
final stream = await _voiceService.beginListening();
_intensitySub = _voiceService.intensityStream.listen((value) {
if (!mounted) return;
setState(() => _intensity = value);